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
Support existing Azure Kubernetes environments - #20921
Allow Aspire applications to deploy to a pre-provisioned AKS cluster using the shared Azure AsExisting APIs, following the Azure Container Apps and App Service approach.
Existing clusters are referenced without reconfiguring their node pools, networking, or add-ons. Aspire does not create or implicitly select a workload node pool for them. Supporting infrastructure remains in the application's resource group, while deployment credentials and workload cleanup target the cluster's actual identity. OIDC is only required when workloads use workload identity.
The implementation reuses existing API signatures and introduces no dependencies. The README documents prerequisites and warns that the cluster must be outside the application's resource group to survive aspire destroy.
dotnet build tests/Aspire.Deployment.EndToEnd.Tests/Aspire.Deployment.EndToEnd.Tests.csproj --no-restore - passed, no warnings or errors.
gh workflow run deployment-tests.yml --repo microsoft/aspire --ref mitchdenny-existing-aks-environments -f test_filter=AksExistingClusterDeploymentTests - passed, including the full CI build and live deployment test on commit 225b03c23ca9e170b7a749a2ff1c04cdd5605e19 (1 passed, 0 skipped).
The new E2E test creates an AKS cluster with Azure CLI and passes its complete resource ID as a deployment parameter. It verifies the deployed API response, unchanged cluster configuration, and absence of a second cluster in the application's resource group. It then runs aspire destroy, verifies that workloads are removed and the existing cluster survives, and requests cleanup of both test-owned resource groups.
The bootstrap explicitly verifies that OIDC and workload identity are disabled. It uses Kubernetes 1.33 with AKS Long-Term Support because newly created 1.34+ clusters enable OIDC by default and cannot disable it afterward. Regression coverage also verifies subscription inheritance for resource-group-only existing references, preview API selection for existing clusters with ALB, and preservation of annotation-based module scope for Sandbox groups and Foundry projects.
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?
The reason will be displayed to describe this comment to others. Learn more.
Found 2 correctness issues: partial existing-cluster scope resolution can target the wrong subscription, and existing clusters with an ALB retain a stable API version that cannot expose the required controller identity. Both were reproduced with focused regression probes. Validation: 92 AKS tests and 31 BicepUtilities tests passed; three unchanged snapshot tests failed due to local CRLF line endings. Confirmed the PR live deployment run passed on the reviewed commit, but it does not cover these edge cases.
The fixed local port makes this deployment test fail whenever port 18080 is already occupied, which is a known flaky-test pattern in this repository. Allocate an available port and pass it to both kubectl port-forward and curl; AksPersistentVolumeDeploymentTests.GetAvailablePort() demonstrates the existing approach.
This new usage section documents an API that is exported to TypeScript, but only provides the C# form. Add the equivalent TypeScript example so polyglot AppHost users can discover the existing-cluster path, consistent with the two-language usage example above.
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
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
Allow Aspire applications to deploy to a pre-provisioned AKS cluster using the shared Azure
AsExistingAPIs, following the Azure Container Apps and App Service approach.Existing clusters are referenced without reconfiguring their node pools, networking, or add-ons. Aspire does not create or implicitly select a
workloadnode pool for them. Supporting infrastructure remains in the application's resource group, while deployment credentials and workload cleanup target the cluster's actual identity. OIDC is only required when workloads use workload identity.The implementation reuses existing API signatures and introduces no dependencies. The README documents prerequisites and warns that the cluster must be outside the application's resource group to survive
aspire destroy.Fixes #17711
User-facing usage
AsExisting
Use an existing cluster in the current subscription scope. Pass a resource-group parameter, or
nullto use the application's resource group.AsExistingInResourceGroup
Use an existing cluster with an explicit resource group and subscription.
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'- passed, 126 tests.dotnet test --project tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-class '*.BicepUtilitiesTests' --filter-class '*.AzureBicepProvisionerTests' --filter-class '*.AzureBicepResourceTests' --filter-class '*.AzureProvisioningResourceTests' --filter-class '*.AzureBicepResourceScopeTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'- passed, 175 tests.dotnet build tests/Aspire.Deployment.EndToEnd.Tests/Aspire.Deployment.EndToEnd.Tests.csproj --no-restore- passed, no warnings or errors.gh workflow run deployment-tests.yml --repo microsoft/aspire --ref mitchdenny-existing-aks-environments -f test_filter=AksExistingClusterDeploymentTests- passed, including the full CI build and live deployment test on commit225b03c23ca9e170b7a749a2ff1c04cdd5605e19(1 passed, 0 skipped).The new E2E test creates an AKS cluster with Azure CLI and passes its complete resource ID as a deployment parameter. It verifies the deployed API response, unchanged cluster configuration, and absence of a second cluster in the application's resource group. It then runs
aspire destroy, verifies that workloads are removed and the existing cluster survives, and requests cleanup of both test-owned resource groups.The bootstrap explicitly verifies that OIDC and workload identity are disabled. It uses Kubernetes 1.33 with AKS Long-Term Support because newly created 1.34+ clusters enable OIDC by default and cannot disable it afterward. Regression coverage also verifies subscription inheritance for resource-group-only existing references, preview API selection for existing clusters with ALB, and preservation of annotation-based module scope for Sandbox groups and Foundry projects.
Checklist
<remarks />and<code />elements on your triple slash comments?