You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix AKS AcrPull for existing cross-resource-group registries - #20919
AKS can now pull application images from an existing ACR in another resource group or subscription using role assignments at the actual registry scope. No new public API or dependency is introduced.
Following review feedback, the cluster now uses separate pre-created user-assigned identities for the control plane and kubelets. Standard Azure role preparation grants kubelet AcrPull on the selected registry and control-plane Managed Identity Operator on the kubelet identity. For environment and node-pool WithSubnet selections, the control plane receives Network Contributor on the selected virtual networks. AKS manages its normal control-plane permissions in the node resource group.
The assignments precede cluster creation in both Aspire's deployment pipeline and generated main.bicep. Registry selection is resolved after model configuration, preparation is idempotent, excluded environments create no identities, and explicit resource scopes take precedence over existing-resource annotation scopes. Both identities inherit the cluster's final deployment scope, including scope selected through infrastructure callbacks. AKS-specific security remarks were moved out of generic AsExisting documentation into the AKS README.
Existing AKS deployments transition from a system-assigned control-plane identity and AKS-created kubelet identity to the new user-assigned identities. Kubelet identity changes can upgrade node pools and disrupt workloads; schedule the migration appropriately. Custom permissions are not transferred automatically, and the control plane can continue using its previous identity while cached tokens expire. The README describes the migration and required permission handling. Existing-cluster migration has not been live-validated.
Security considerations
Only the kubelet identity receives registry AcrPull; the control-plane identity does not receive registry access. No ACR administrator credentials or image-pull secrets are introduced. AcrPull is registry-wide and requires RBAC Registry Permissions mode, not ABAC Repository Permissions mode. A separate kubelet UAMI does not isolate its IMDS tokens from workloads; Workload Identity alone does not block this access. External registry role assignments still require separate cleanup after aspire destroy. Additional customized external networking/DNS resources require corresponding control-plane permissions. Formal security review has not been performed.
Validation
dotnet test --project tests/Aspire.Hosting.Azure.Kubernetes.Tests/Aspire.Hosting.Azure.Kubernetes.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — 124 passed at 833f64395c, including final cluster-scope inheritance coverage.
dotnet test --project tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — 1,946 passed, 5 skipped at 693435bb65.
dotnet build tests/Aspire.Deployment.EndToEnd.Tests/Aspire.Deployment.EndToEnd.Tests.csproj --no-restore --verbosity quiet — passed, no warnings or errors, after the final scope correction.
Generated literal cross-group and parameterized cross-subscription main.bicep templates compiled with Azure CLI Bicep. The new complete scoped-cluster snapshot bundles also compiled using az bicep build --file <bundle>/main.bicep for both literal and parameter-valued cluster scopes. Only unused standard provisioning-parameter warnings were reported. Cross-subscription behavior and custom cluster scope have artifact coverage, not live deployment coverage.
Azure E2E run 38328663624 — failed before deployment: the generated AppHost omitted suppression of ASPIREAZURE003 for experimental Azure networking APIs. Commit e499003d6b adds the suppression and an explicit AppHost build so compilation failures fail promptly.
Azure E2E run 38333538328 at e499003d6b — passed. Downloaded TRX confirms the deployment scenario executed and passed in 12m46s.
The E2E uses an external private ACR and a custom VNet, checks the complete direct role sets for both identities (including AKS-managed node-group Contributor), verifies private-image pulls and an HTTP response, repeats deployment to verify identity and assignment stability, then destroys the application and confirms the external registry survives before final cleanup.
gh workflow run deployment-tests.yml --repo microsoft/aspire --ref mitchdenny-aks-cross-group-acr -f pr_number=20919 -f test_filter=AksCrossResourceGroupRegistryDeploymentTests — passed at 833f64395c: Azure E2E run 38336886787. Downloaded TRX confirms the actual deployment test passed in 12m11s, including repeat deployment and resource-group cleanup.
gh workflow run deployment-tests.yml --repo microsoft/aspire --ref mitchdenny-aks-cross-group-acr -f pr_number=20919 — completed, overall failed at current head 100128e96e: Full deployment E2E run 38339704524. All 54 deployment matrix jobs ran; 53 jobs succeeded and one failed. Downloaded and inspected every job's TRX: 60 tests passed, 1 failed, 1 skipped, with no missing result files. All AKS, ACA, scoped-resource, and run-mode role-assignment scenarios passed.
The sole failure is FoundryDotnetProjectDeploymentTests: deployment, hosted agent version checks, and published image verification succeeded, but constructing the response client at FoundryDotnetProjectDeploymentTests.cs:117 threw MissingMethodException for OpenAI.Responses.ResponsesClient(ClientPipeline, OpenAIClientOptions) from Azure.AI.Extensions.OpenAI.ProjectResponsesClient. This is an SDK binary-compatibility failure after provisioning; the Foundry test and dependency manifests are unchanged by this PR. It has not been fixed or rerun here.
AzureConnectorNamespaceDeploymentTests was skipped by its existing environment gate: the deployment environment lacks required Connector Namespace preview enrollment. The job ran successfully but did not execute the deployment scenario.
Run 38217840141 passed for the earlier scoped-role spike; it does not validate this UAMI refactor.
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?
Preserve deployment state for Aspire teardown in the isolated test workspace.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: aa93f73f-c514-4794-8eb1-6522875bf176
Log the expected principal and returned assignments so deployment failures retain actionable RBAC evidence.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: aa93f73f-c514-4794-8eb1-6522875bf176
A subshell cannot wait for the parent shell port-forward process. Keep wait in the command shell with a brace group.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: aa93f73f-c514-4794-8eb1-6522875bf176
The hard-coded host port can make this deployment test fail when port 18080 is already occupied. Allocate an available loopback port and interpolate it into both the kubectl port-forward and curl commands, as AksPersistentVolumeDeploymentTests.GetAvailablePort() does.
Share existing-resource remarks across AsExisting and PublishAsExisting resource-group surfaces, and explain AKS registry-wide pull access, IMDS isolation, and external assignment cleanup in the README.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: aa93f73f-c514-4794-8eb1-6522875bf176
Make role deployment wait for its target resource so callback-configured scopes are resolved before provisioning. Add a frozen system-assigned AKS baseline and verify upgrade to separate managed identities and external-registry image pulls. Remove the redundant AppHost prebuild now that the test uses AddDotnetProject.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: de26b94e-818b-43a7-ae02-6f6be2ddca94
Preserve the separate AKS identities while adopting main's typed ingress profile and updated provisioning API versions.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: de26b94e-818b-43a7-ae02-6f6be2ddca94
Use short RG-scoped physical cluster and network names and isolate fresh and upgrade scenarios by resource group.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: de26b94e-818b-43a7-ae02-6f6be2ddca94
Validation: 22 focused shared Azure regressions and 16 focused AKS regressions passed locally. Inspected the current-head deployment TRX from run 38819691848: both fresh deployment and legacy-cluster upgrade passed. A broader shared Azure run passed 111 tests and failed 8 because existing verified snapshots contain CRLF line endings.
Retain target provisioning dependencies for role scope resolution without propagating grants held by that target. Cover reciprocal managed-identity grants and update the AKS dependency snapshots.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: de26b94e-818b-43a7-ae02-6f6be2ddca94
Updated the AKS hosting integration reference (integrations/cloud/azure/aks/index.mdx) to document the cross-resource-group registry fix. Triggered signals: integration_readme_changed (README added "Existing container registries" and "Cluster identities and permissions" sections, mirrored here), pr_label_breaking_change and pr_body_has_breaking_change_marker-adjacent content (new "Updating existing clusters" caution documents the control-plane/kubelet identity migration), pr_body_has_user_facing_section (new "Use an existing container registry" section reproduces the WithContainerRegistry/PublishAsExisting C#/TypeScript usage example from the PR body), and pr_body_has_cli_flag_mention (covered incidentally via existing aspire destroy behavior notes, no new CLI flags were introduced). Added sections: existing-registry usage and AcrPull scoping/destroy caveats, a cluster identities/permissions table (kubelet AcrPull, control-plane Managed Identity Operator/Network Contributor), and a breaking-change callout for migrating pre-existing clusters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
area-integrationsIssues pertaining to Aspire Integrations packagesbreaking-changeIssue or PR that represents a breaking API or functional change over a prerelease.
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #18277.
AKS can now pull application images from an existing ACR in another resource group or subscription using role assignments at the actual registry scope. No new public API or dependency is introduced.
Following review feedback, the cluster now uses separate pre-created user-assigned identities for the control plane and kubelets. Standard Azure role preparation grants kubelet
AcrPullon the selected registry and control-planeManaged Identity Operatoron the kubelet identity. For environment and node-poolWithSubnetselections, the control plane receivesNetwork Contributoron the selected virtual networks. AKS manages its normal control-plane permissions in the node resource group.The assignments precede cluster creation in both Aspire's deployment pipeline and generated
main.bicep. Registry selection is resolved after model configuration, preparation is idempotent, excluded environments create no identities, and explicit resource scopes take precedence over existing-resource annotation scopes. Both identities inherit the cluster's final deployment scope, including scope selected through infrastructure callbacks. AKS-specific security remarks were moved out of genericAsExistingdocumentation into the AKS README.User-facing usage
C#:
TypeScript:
Breaking changes
Existing AKS deployments transition from a system-assigned control-plane identity and AKS-created kubelet identity to the new user-assigned identities. Kubelet identity changes can upgrade node pools and disrupt workloads; schedule the migration appropriately. Custom permissions are not transferred automatically, and the control plane can continue using its previous identity while cached tokens expire. The README describes the migration and required permission handling. Existing-cluster migration has not been live-validated.
Security considerations
Only the kubelet identity receives registry
AcrPull; the control-plane identity does not receive registry access. No ACR administrator credentials or image-pull secrets are introduced.AcrPullis registry-wide and requires RBAC Registry Permissions mode, not ABAC Repository Permissions mode. A separate kubelet UAMI does not isolate its IMDS tokens from workloads; Workload Identity alone does not block this access. External registry role assignments still require separate cleanup afteraspire destroy. Additional customized external networking/DNS resources require corresponding control-plane permissions. Formal security review has not been performed.Validation
dotnet test --project tests/Aspire.Hosting.Azure.Kubernetes.Tests/Aspire.Hosting.Azure.Kubernetes.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— 124 passed at833f64395c, including final cluster-scope inheritance coverage.dotnet test --project tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— 1,946 passed, 5 skipped at693435bb65.dotnet build tests/Aspire.Deployment.EndToEnd.Tests/Aspire.Deployment.EndToEnd.Tests.csproj --no-restore --verbosity quiet— passed, no warnings or errors, after the final scope correction.main.biceptemplates compiled with Azure CLI Bicep. The new complete scoped-cluster snapshot bundles also compiled usingaz bicep build --file <bundle>/main.bicepfor both literal and parameter-valued cluster scopes. Only unused standard provisioning-parameter warnings were reported. Cross-subscription behavior and custom cluster scope have artifact coverage, not live deployment coverage.ASPIREAZURE003for experimental Azure networking APIs. Commite499003d6badds the suppression and an explicit AppHost build so compilation failures fail promptly.e499003d6b— passed. Downloaded TRX confirms the deployment scenario executed and passed in 12m46s.gh workflow run deployment-tests.yml --repo microsoft/aspire --ref mitchdenny-aks-cross-group-acr -f pr_number=20919 -f test_filter=AksCrossResourceGroupRegistryDeploymentTests— passed at833f64395c: Azure E2E run 38336886787. Downloaded TRX confirms the actual deployment test passed in 12m11s, including repeat deployment and resource-group cleanup.gh workflow run deployment-tests.yml --repo microsoft/aspire --ref mitchdenny-aks-cross-group-acr -f pr_number=20919— completed, overall failed at current head100128e96e: Full deployment E2E run 38339704524. All 54 deployment matrix jobs ran; 53 jobs succeeded and one failed. Downloaded and inspected every job's TRX: 60 tests passed, 1 failed, 1 skipped, with no missing result files. All AKS, ACA, scoped-resource, and run-mode role-assignment scenarios passed.FoundryDotnetProjectDeploymentTests.cs:117threwMissingMethodExceptionforOpenAI.Responses.ResponsesClient(ClientPipeline, OpenAIClientOptions)fromAzure.AI.Extensions.OpenAI.ProjectResponsesClient. This is an SDK binary-compatibility failure after provisioning; the Foundry test and dependency manifests are unchanged by this PR. It has not been fixed or rerun here.AzureConnectorNamespaceDeploymentTestswas skipped by its existing environment gate: the deployment environment lacks required Connector Namespace preview enrollment. The job ran successfully but did not execute the deployment scenario.Checklist
<remarks />and<code />elements on your triple slash comments?