diff --git a/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs b/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs index 6ce8922365..b74c7b3467 100644 --- a/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs +++ b/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs @@ -18,7 +18,7 @@ namespace Calamari.AzureResourceGroup.Tests { [TestFixture] - [WindowsTest] // NOTE: We should look at having the Azure CLI installed on Linux boxes so that these steps can be tested there, particularly if we're moving cloud to a Ubuntu Default Worker. + // NOTE: We should look at having the Azure CLI installed on Linux boxes so that these steps can be tested there, particularly if we're moving cloud to a Ubuntu Default Worker. class DeployAzureBicepTemplateCommandFixture { string clientId; @@ -93,6 +93,7 @@ await armClient.GetResourceGroupResource(ResourceGroupResource.CreateResourceIde } [Test] + [WindowsTest] [RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")] public async Task DeployAzureBicepTemplate_PackageSource() { @@ -108,6 +109,7 @@ await CommandTestBuilder.CreateAsync() } [Test] + [WindowsTest] [RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")] public async Task DeployAzureBicepTemplate_GitSource() { diff --git a/source/Calamari.AzureResourceGroup/Bicep/BicepCli.cs b/source/Calamari.AzureResourceGroup/Bicep/BicepCli.cs index dc5ea17491..22e892af40 100644 --- a/source/Calamari.AzureResourceGroup/Bicep/BicepCli.cs +++ b/source/Calamari.AzureResourceGroup/Bicep/BicepCli.cs @@ -50,10 +50,23 @@ void SetAz() ? ExecuteRawCommandAndReturnOutput("where", "az.cmd") : ExecuteRawCommandAndReturnOutput("which", "az"); - var infoMessages = result.Output.Messages.Where(m => m.Level == Level.Verbose).Select(m => m.Text).ToArray(); + var allMessages = result.Output.Messages.Select(m => $"[{m.Level}] {m.Text}").ToArray(); + log.Verbose($"which/where az exit code: {result.Result.ExitCode}"); + log.Verbose($"which/where az output:\n{string.Join("\n", allMessages)}"); + log.Verbose($"PATH: {Environment.GetEnvironmentVariable("PATH")}"); + log.Verbose($"Working directory: {workingDirectory}"); + + var infoMessages = result.Output.Messages + .Where(m => m.Level == Level.Verbose) + .Select(m => m.Text) + .ToArray(); + var foundExecutable = infoMessages.FirstOrDefault(); if (string.IsNullOrEmpty(foundExecutable)) - throw new CommandException("Could not find az. Make sure az is on the PATH."); + throw new CommandException( + $"Could not find az. Make sure az is on the PATH.\n" + + $"PATH was: {Environment.GetEnvironmentVariable("PATH")}\n" + + $"which/where output: {string.Join("; ", allMessages)}"); azCliLocation = foundExecutable.Trim(); }