microsoft/aspire · critical · ProvisioningFailedException
Deployment failed
Error message
Deployment failed: {errorMessage} What it means
When provisioning a Bicep resource fails with an Azure RequestFailedException, ProvisionAzureBicepResourceAsync extracts a detailed error message from the response, reports it to the provisioning task, and rethrows it as a ProvisioningFailedException with message 'Deployment failed: {errorMessage}'.
Solutions
- Read the embedded errorMessage (extracted from the RequestFailedException detail) for the exact ARM error code.
- Fix template/parameter issues flagged by the message (validation errors, invalid values).
- Check the identity's RBAC role on the target resource group and Azure CLI login state.
- Resolve name conflicts or quota/region issues, and register missing resource providers.
Example fix
try
{
await provisioner.ProvisionAsync(...);
}
catch (ProvisioningFailedException ex)
{
logger.LogError(ex, "Bicep deployment failed: {Message}", ex.Message); // message carries ARM detail
throw;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: verify login & resource group access before deployment
var rgExists = await armClient.GetResourceGroups().ExistsAsync(rgName);
if (!rgExists) throw new InvalidOperationException($"Resource group '{rgName}' does not exist or is not accessible."); Try / catch
try { await provisioningPipeline.RunAsync(ct); }
catch (ProvisioningFailedException ex)
{
// ex.Message embeds the ARM error detail extracted from RequestFailedException
logger.LogError(ex, "Azure deployment failed");
throw;
} Prevention
- Ensure the signed-in identity has Contributor on the target resource group.
- Validate templates/parameters with az bicep build / what-if before deploy.
- Use unique resource names to avoid collisions.
- Register required resource providers on the subscription.
- Retry transient ARM errors (429/5xx) with backoff.
When it happens
Trigger: The underlying Azure ARM deployment request fails during provisionStep: invalid template (ARM template validation error), resource-name conflicts, quota exceeded, missing permissions, invalid parameters, or resource provider not registered.
Common situations: Wrong subscription/resource group permissions on the signed-in identity; bicep parameter type mismatches; name collisions with existing resources; region unavailability; unregistered resource providers on the subscription.
Related errors
- Azure deployment for
- Azure deployment for
- AzureProvisioningFailureException (deployment failure…
- A of type cannot be assigned to a BicepValue< >.
- An Azure principal parameter was not supplied a value…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/fa606e5d9d960121.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure/AzureBicepResource.cs:387
new MarkdownString($"Successfully provisioned **{resource.Name}**"),
CompletionState.Completed,
context.CancellationToken).ConfigureAwait(false);
}
}
catch (Exception ex)
{
var errorMessage = ex switch
{
RequestFailedException requestEx =>
$"Deployment failed: {ExtractDetailedErrorMessage(requestEx)}",
_ => $"Deployment failed: {ex.Message}"
};
resource.ProvisioningTaskCompletionSource?.TrySetException(ex);
await resourceTask.CompleteAsync(
new MarkdownString($"Failed to provision **{resource.Name}**: {errorMessage}"),
CompletionState.CompletedWithError,
context.CancellationToken).ConfigureAwait(false);
throw new ProvisioningFailedException(errorMessage, ex);
}
}
}
/// <summary>
/// Extracts detailed error information from Azure RequestFailedException responses.
/// Parses the following JSON error structures:
/// 1. Standard Azure error format: { "error": { "code": "...", "message": "...", "details": [...] } }
/// 2. Deployment-specific error format: { "properties": { "error": { "code": "...", "message": "..." } } }
/// 3. Nested error details with recursive parsing for deeply nested error hierarchies
/// </summary>
/// <param name="requestEx">The Azure RequestFailedException containing the error response</param>
/// <returns>The most specific error message found, or the original exception message if parsing fails</returns>
internal static string ExtractDetailedErrorMessage(RequestFailedException requestEx)
=> AzureProvisioningFailureDetails.FromRequestFailedException(requestEx).ToDetailedMessage();
/// <summary>
/// Known parameters that will be filled in automatically by the host environment.View on GitHub (pinned to 25830f84bd)