[release/13.0] Fix hang when trying to deploy single compute resource#12800
[release/13.0] Fix hang when trying to deploy single compute resource#12800joperezr merged 2 commits intorelease/13.0from
Conversation
- Add PipelineConfigurationAnnotation to AzureBicepResource to set up dependencies - Add ProcessAzureReferences helper methods to find Azure resource dependencies - Add test DeployAsync_WithAzureResourceDependencies_DoesNotHang (adapted for release/13.0) - Update snapshot for DeployAsync_WithMultipleComputeEnvironments_Works - Tests adjusted to work without IContainerRuntime.LoginToRegistryAsync (not in release/13.0) Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12800Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12800" |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a deployment hang issue by ensuring Azure Bicep resources properly depend on referenced Azure resources (like KeyVault). The fix adds automatic dependency tracking that walks the reference graph to identify Azure resource dependencies.
Key changes:
- Added
PipelineConfigurationAnnotationtoAzureBicepResourcethat automatically discovers and sets up dependencies on referenced Azure resources - Implemented
ProcessAzureReferenceshelper methods to recursively walk theIValueWithReferencesgraph - Added comprehensive test case
DeployAsync_WithAzureResourceDependencies_DoesNotHangto verify the fix
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Aspire.Hosting.Azure/AzureBicepResource.cs | Added pipeline configuration annotation to discover Azure resource references in Bicep parameters and set up provision step dependencies, plus helper methods to recursively process the reference graph |
| tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs | Added test that recreates the hang scenario (compute resource referencing KeyVault secret) to verify correct dependency setup |
| tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithAzureResourceDependencies_DoesNotHang_step=diagnostics.verified.txt | New snapshot showing the expected dependency graph structure for the test scenario |
| tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithMultipleComputeEnvironments_Works_step=diagnostics.verified.txt | Updated snapshot reflecting dependency order changes from the fix |
| ProcessAzureReferences(azureReferences, value, []); | ||
| } | ||
|
|
||
| private static void ProcessAzureReferences(HashSet<IAzureResource> azureReferences, object? value, HashSet<object> visited) |
There was a problem hiding this comment.
The overloaded ProcessAzureReferences method is missing XML documentation. According to the coding guidelines, internal methods should have brief <summary> tags. Add a summary explaining this overload handles cycle detection via the visited set, and document the visited parameter.
Description
Backports the deployment hang fix from PR #12797 to release/13.0, adapted to work without
IContainerRuntime.LoginToRegistryAsync(added in commit 7d74cf2, not present in release/13.0).Problem: Deploying subsets of Azure resources (e.g.,
aspire do deploy-api-agent) hangs because Bicep resources don't declare dependencies on other Azure resources referenced in their parameters.Solution:
AzureBicepResourcenow addsPipelineConfigurationAnnotationthat walks parameter values viaIValueWithReferences, findsIAzureResourcedependencies, and establishes provision step dependenciesprovision-api-websitedepends onprovision-kvwhen the app service references a KeyVault secretTest Adaptation:
The test from PR #12797 was modified to exclude the
fakeContainerRuntimeparameter sinceConfigureTestServicesin release/13.0 doesn't acceptIContainerRuntime. This parameter was only needed for ACR login verification, which is unrelated to the dependency graph fix being tested.Fixes #12793
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplateWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms/usr/local/bin/bicep build /tmp/aspiregsHYkF/env.module.bicep --stdout(dns block)/usr/local/bin/bicep build /tmp/aspireXD8rRP/teststorage.module.bicep --stdout(dns block)/usr/local/bin/bicep build /tmp/aspire8tqhlO/teststorage.module.bicep --stdout(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.