Skip to content

Commit 36afb32

Browse files
authored
Fix how we retrieve the installation id form AzCLI and AzPSH profile (#260)
1 parent c9a8ecc commit 36afb32

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

shell/agents/Microsoft.Azure.Agent/Telemetry.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@ internal static void Initialize()
1717
{
1818
InstallationId = null;
1919

20-
string azureConfigDir = Environment.GetEnvironmentVariable("AZURE_CONFIG_DIR")
21-
?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".azure");
22-
string azCLIProfilePath = Path.Combine(azureConfigDir, "azureProfile.json");
23-
string azPSHProfilePath = Path.Combine(azureConfigDir, "AzureRmContextSettings.json");
20+
string azCLIProfilePath, azPSHProfilePath;
21+
string azureConfigDir = Environment.GetEnvironmentVariable("AZURE_CONFIG_DIR");
22+
string userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
23+
24+
if (string.IsNullOrEmpty(azureConfigDir))
25+
{
26+
azCLIProfilePath = Path.Combine(userProfile, ".azure", "azureProfile.json");
27+
azPSHProfilePath = Path.Combine(userProfile, ".Azure", "AzureRmContextSettings.json");
28+
}
29+
else
30+
{
31+
azCLIProfilePath = Path.Combine(azureConfigDir, "azureProfile.json");
32+
azPSHProfilePath = Path.Combine(azureConfigDir, "AzureRmContextSettings.json");
33+
}
2434

2535
try
2636
{

0 commit comments

Comments
 (0)