Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand All @@ -108,6 +109,7 @@ await CommandTestBuilder.CreateAsync<DeployAzureBicepTemplateCommand, Program>()
}

[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()
{
Expand Down
17 changes: 15 additions & 2 deletions source/Calamari.AzureResourceGroup/Bicep/BicepCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down