Skip to content

Improved azure error logging - #2151

Merged
bec-callow-oct merged 5 commits into
mainfrom
bec/hpy-1405-improve-azure-error-log-v2
Sep 7, 2026
Merged

bec-callow-oct merged 5 commits into
mainfrom
bec/hpy-1405-improve-azure-error-log-v2

Conversation

@bec-callow-oct

@bec-callow-oct bec-callow-oct commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes: HPY-1405

When an Azure deployment fails, Calamari currently logs Azure's DeploymentFailed status, but this does not provide users with any useful information about what went wrong and how the issue might be resolved. This PR improves error logging by retrieving the deployment operation results from Azure and providing detailed logging when more specific error messages are available.

Results

Single resource failure

image

Multiple resource failures

image

Successful deployment (unchanged)

image

@bec-callow-oct
bec-callow-oct force-pushed the bec/hpy-1405-improve-azure-error-log-v2 branch from 8183115 to de48c4c Compare September 3, 2026 05:13
{
log.Error("Error polling for deployment completion");
throw;
throw new CommandException(await BuildDeploymentFailureMessage(resourceGroupResource, deploymentName, ex), ex);

@bec-callow-oct bec-callow-oct Sep 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing a CommandException allows this to be handled as a known error and prevents stack trace logging. The stack trace shouldn't be needed here since the failure is an Azure error


throw;
}
catch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connection errors, etc should fall back to the original path

{
using var errorLoggingCancellation = new CancellationTokenSource(FailureLoggingTimeout);

var deploymentResponse = await resourceGroupResource.GetArmDeploymentAsync(deploymentName, errorLoggingCancellation.Token);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial azure failure response does not contain failure information, so we need to request the deployment and failed resource details


var report = await CollectFailedOperations(deploymentResponse.Value, errorLoggingCancellation.Token);

if (report.FailureCount == 0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Azure lists no resources as having failed, we need to rely on its base exception message to tell the user what went wrong

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new RequestFailedException handling can regress logging by emitting no Calamari error context when detailed failure retrieval returns null.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Improves the diagnostic output for failed Azure Resource Group deployments by querying ARM deployment operation results and formatting a concise failure summary that highlights the specific resources and errors involved.

Changes:

  • Adds failure-detail retrieval on RequestFailedException during deployment polling, with a time-bounded attempt to collect failed deployment operations.
  • Introduces formatting helpers (FormatFailedOperation, ExtractAzureErrorInfo) to produce actionable, user-facing failure summaries.
  • Adds NUnit coverage for the new formatting/error-extraction helpers.
File summaries
File Description
source/Calamari.AzureResourceGroup/AzureResourceGroupOperator.cs Adds deployment-failure detail collection from ARM deployment operations and improved error formatting/logging.
source/Calamari.AzureResourceGroup.Tests/AzureResourceGroupOperatorFixture.cs Adds unit tests for the new failure formatting and error extraction helpers.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread source/Calamari.AzureResourceGroup/AzureResourceGroupOperator.cs
@bec-callow-oct
bec-callow-oct requested a review from a team September 3, 2026 06:51

@benPearce1 benPearce1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This looks like a really useful improvement.

@bec-callow-oct
bec-callow-oct merged commit 2712899 into main Sep 7, 2026
29 checks passed
@bec-callow-oct
bec-callow-oct deleted the bec/hpy-1405-improve-azure-error-log-v2 branch September 7, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants