Skip to content

[release/13.0] Fix hang when trying to deploy single compute resource#12800

Merged
joperezr merged 2 commits intorelease/13.0from
copilot/adjust-tests-for-release-13-0
Nov 7, 2025
Merged

[release/13.0] Fix hang when trying to deploy single compute resource#12800
joperezr merged 2 commits intorelease/13.0from
copilot/adjust-tests-for-release-13-0

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

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:

  • AzureBicepResource now adds PipelineConfigurationAnnotation that walks parameter values via IValueWithReferences, finds IAzureResource dependencies, and establishes provision step dependencies
  • Ensures provision-api-website depends on provision-kv when the app service references a KeyVault secret

Test Adaptation:
The test from PR #12797 was modified to exclude the fakeContainerRuntime parameter since ConfigureTestServices in release/13.0 doesn't accept IContainerRuntime. This parameter was only needed for ACR login verification, which is unrelated to the dependency graph fix being tested.

Fixes #12793

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Warning

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
    • Triggering command: /usr/local/bin/bicep build /tmp/aspiregsHYkF/env.module.bicep --stdout (dns block)
    • Triggering command: /usr/local/bin/bicep build /tmp/aspireXD8rRP/teststorage.module.bicep --stdout (dns block)
    • Triggering command: /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

Make the changes from #12797 but in a way that is compatible with the release/13.0 branch. Specifically, this change 7d74cf2 is not in release/13.0 so we can't backport as is, the tests need to be adjusted.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- 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>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12800

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12800"

@davidfowl davidfowl marked this pull request as ready for review November 7, 2025 10:27
Copilot AI review requested due to automatic review settings November 7, 2025 10:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 PipelineConfigurationAnnotation to AzureBicepResource that automatically discovers and sets up dependencies on referenced Azure resources
  • Implemented ProcessAzureReferences helper methods to recursively walk the IValueWithReferences graph
  • Added comprehensive test case DeployAsync_WithAzureResourceDependencies_DoesNotHang to 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)
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

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.

Copilot generated this review using guidance from repository custom instructions.
Copilot AI changed the title [WIP] Adjust tests for compatibility with release/13.0 Backport PR #12797 fix for deployment hang to release/13.0 Nov 7, 2025
Copilot AI requested a review from davidfowl November 7, 2025 10:38
@captainsafia captainsafia changed the title Backport PR #12797 fix for deployment hang to release/13.0 [release/13.0] Fix hang when trying to deploy single compute resource Nov 7, 2025
@joperezr joperezr merged commit 18a8fc1 into release/13.0 Nov 7, 2025
592 of 597 checks passed
@joperezr joperezr deleted the copilot/adjust-tests-for-release-13-0 branch November 7, 2025 21:41
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants