Skip to content

Support existing Azure Kubernetes environments - #20921

Merged
Mitch Denny (mitchdenny) merged 26 commits into
mainfrom
mitchdenny-existing-aks-environments
Nov 3, 2026
Merged

Mitch Denny (mitchdenny) merged 26 commits into
mainfrom
mitchdenny-existing-aks-environments

Conversation

@mitchdenny

@mitchdenny Mitch Denny (mitchdenny) commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Description

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.

Fixes #17711

User-facing usage

AsExisting

Use an existing cluster in the current subscription scope. Pass a resource-group parameter, or null to use the application's resource group.

var clusterName = builder.AddParameter("cluster-name");
var resourceGroup = builder.AddParameter("cluster-resource-group");

var aks = builder.AddAzureKubernetesEnvironment("aks")
    .AsExisting(clusterName, resourceGroup);

builder.AddProject<Projects.MyService>("myservice")
    .WithComputeEnvironment(aks);

AsExistingInResourceGroup

Use an existing cluster with an explicit resource group and subscription.

var clusterName = builder.AddParameter("cluster-name");
var resourceGroup = builder.AddParameter("cluster-resource-group");
var subscription = builder.AddParameter("cluster-subscription");

var aks = builder.AddAzureKubernetesEnvironment("aks")
    .AsExistingInResourceGroup(clusterName, resourceGroup, subscription);

builder.AddProject<Projects.MyService>("myservice")
    .WithComputeEnvironment(aks);

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 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?
        • Yes
        • No
    • No

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
@github-actions

Copy link
Copy Markdown
Contributor

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20921

Or

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

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot October 12, 2026 10:27
@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Oct 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Existing clusters without OIDC can fail because the generated Bicep still reads the optional OIDC issuer output.

1 open finding
What changed in this PR

Adds deployment support for pre-provisioned AKS clusters while preserving cluster-owned configuration and cleanup boundaries.

Changes:

  • References existing AKS clusters through shared Azure existing-resource APIs.
  • Corrects provisioning scope, credential acquisition, and destroy behavior.
  • Adds unit, snapshot, and live deployment coverage plus documentation.
File Description
tests/​Aspire.Hosting.Azure.Tests/​BicepUtilitiesTests.cs Tests compute-environment module scope behavior.
tests/​Aspire.Hosting.Azure.Kubernetes.Tests/​Snapshots/​AzureKubernetesInfrastructureTests.ExistingCluster_PreservesWorkloadIdentity.verified.bicep Captures existing-cluster workload identity infrastructure.
tests/​Aspire.Hosting.Azure.Kubernetes.Tests/​Snapshots/​AzureKubernetesEnvironmentExtensionsTests.AsExisting_GeneratesExistingCluster_crossResourceGroup=True.verified.bicep Captures cross-resource-group AKS references.
tests/​Aspire.Hosting.Azure.Kubernetes.Tests/​Snapshots/​AzureKubernetesEnvironmentExtensionsTests.AsExisting_GeneratesExistingCluster_crossResourceGroup=False.verified.bicep Captures same-scope AKS references.
tests/​Aspire.Hosting.Azure.Kubernetes.Tests/​Snapshots/​AzureKubernetesEnvironmentExtensionsTests.AddAsExistingResource_ReusesReference_existing=True.verified.bicep Verifies existing reference reuse.
tests/​Aspire.Hosting.Azure.Kubernetes.Tests/​Snapshots/​AzureKubernetesEnvironmentExtensionsTests.AddAsExistingResource_ReusesReference_existing=False.verified.bicep Verifies provisioned-cluster reference reuse.
tests/​Aspire.Hosting.Azure.Kubernetes.Tests/​AzureKubernetesInfrastructureTests.cs Tests node pools, identity, credentials, and destroy behavior.
tests/​Aspire.Hosting.Azure.Kubernetes.Tests/​AzureKubernetesEnvironmentExtensionsTests.cs Tests existing-resource APIs and generated Bicep.
tests/​Aspire.Deployment.EndToEnd.Tests/​AksExistingClusterDeploymentTests.cs Exercises deployment and cleanup against a live existing cluster.
src/​Aspire.Hosting.Azure/​Provisioning/​BicepUtilities.cs Keeps supporting infrastructure in the module scope.
src/​Aspire.Hosting.Azure.Kubernetes/​README.md Documents existing-cluster usage and prerequisites.
src/​Aspire.Hosting.Azure.Kubernetes/​AzureKubernetesEnvironmentResource.cs Adds reusable existing AKS references.
src/​Aspire.Hosting.Azure.Kubernetes/​AzureKubernetesEnvironmentResource.AksPipeline.cs Adjusts node-pool, credential, and destroy handling.
src/​Aspire.Hosting.Azure.Kubernetes/​AzureKubernetesEnvironmentExtensions.cs Emits existing rather than newly provisioned AKS resources.

🧠 Review effort: Balanced

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The ownership, scoping, credential, and cleanup paths are consistently implemented and covered by focused and live deployment tests.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

…sion

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The broad scope bypass breaks some existing cross-resource-group compute environments, and the new E2E test uses a collision-prone fixed port.

1 open finding
Previously missed (1)

In code that hasn't changed since last review

Medium severity Use an available port instead of fixed port 18080 in deployment test

tests/​Aspire.Deployment.EndToEnd.Tests/​AksExistingClusterDeploymentTests.cs:124

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.

🧠 Review effort: Balanced

…-scoped references

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #20921...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

For existing Sandbox groups, conflicting scope precedence can direct role assignments and resource references to a different group than the primary deployment, causing deployment failures or incorrect permission grants.

4 open issues
1 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
@mitchdenny

Copy link
Copy Markdown
Member Author

/deployment-test

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #20921...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Annotation-first scope resolution overrides explicit module scope for sandbox resources, causing cross-module references and role assignments to target the wrong resource or fail deployment.

4 open issues

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Record module-scoped existing declarations in shared provisioning and materialize their source before resolving cross-template references. Cover conflicting Sandbox scopes without changing AKS independent-reference semantics.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
@mitchdenny

Copy link
Copy Markdown
Member Author

/deployment-test

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #20921...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A group-only existing-cluster reference can remain pinned to the initial subscription after a callback override, leaving it inconsistent with cluster-role modules; scope resolution needs correction and regression coverage.

1 open issue
4 resolved since last review

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Keep the source declaration scoped to its annotation without capturing the module's initial subscription. Cross-template references inherit the finalized subscription after source configuration. Extend publish and consumer regressions with initial scopes overridden by callbacks.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 14f4e734-0b32-464c-8c0c-37babdc5349c
@mitchdenny

Copy link
Copy Markdown
Member Author

/deployment-test

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #20921...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Tests selector

16 / 100 PR test projects · 3 PR jobs, from 65 changed files.

Selected PR test projects (16 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Tests, Aspire.Playground.Tests

Selected PR jobs (3)

extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 11 of the 16 selected test projects come from a single change — src/Aspire.Hosting.Azure/AzureProvisioningResource.cs.

🔧 src/Aspire.Hosting.Azure/AzureProvisioningResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests
→ 10 via the project graph: Aspire.Hosting.Azure.EntraId.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (2 hops), Aspire.Hosting.Blazor.Tests (3 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.Dotnet.Tests (3 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Radius.Tests (3 hops), Aspire.Hosting.Tests (2 hops), Aspire.Playground.Tests (2 hops)

🔧 src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentExtensions.cs (changed source)
→ 2 directly: Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Tests
→ 3 via the project graph: Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.RemoteHost.Tests

🔧 src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentResource.AksPipeline.cs (changed source)
→ 2 directly: Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentResource.cs (changed source)
→ 2 directly: Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Tests

📦 affected project Aspire.Hosting.Azure.Storage
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Hosting.Azure/AzureRoleAssignmentResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure/Provisioning/BicepUtilities.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/AzureKubernetesEnvironmentExtensionsTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/AzureKubernetesInfrastructureTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AddAsExistingResource_InheritsModuleSubscriptionAcrossTemplates.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AddAsExistingResource_ReusesReference_existing=False.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AddAsExistingResource_ReusesReference_existing=True.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AddLoadBalancer_BicepEnablesIngressProfileAndUsesPreviewApi.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AddLoadBalancer_BicepEnablesIngressProfileAndUsesPreviewApi_existing=False.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AddLoadBalancer_BicepEnablesIngressProfileAndUsesPreviewApi_existing=True.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AsExisting_GeneratesExistingCluster_crossResourceGroup=False.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AsExisting_GeneratesExistingCluster_crossResourceGroup=True.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_DoesNotProvisionReplacementIdentities.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=callback#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=callback#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=callback#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=callback#03.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=existing#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=existing#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=existing#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=existing#03.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=group#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=group#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=group#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=group#03.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new#03.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new-scoped#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new-scoped#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new-scoped#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=new-scoped#03.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=subscription#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=subscription#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=subscription#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RegistryRoleUsesRegistryScope_registryScenario=subscription#03.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=False_callbackScope=False#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=False_callbackScope=False#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=False_callbackScope=False#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=False_callbackScope=True#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=False_callbackScope=True#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=False_callbackScope=True#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=True_callbackScope=False#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=True_callbackScope=False#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=True_callbackScope=False#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=True_callbackScope=True#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=True_callbackScope=True#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.ExistingCluster_RoleTargetsClusterScopeInsteadOfSupportingScope_inheritedSubscription=True_callbackScope=True#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesInfrastructureTests.ExistingCluster_PreservesWorkloadIdentity.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesInfrastructureTests.GetCredentialsStepUsesClusterReferenceScope_crossResourceGroup=False_crossSubscription=False.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesInfrastructureTests.GetCredentialsStepUsesClusterReferenceScope_crossResourceGroup=True_crossSubscription=False.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesInfrastructureTests.GetCredentialsStepUsesClusterReferenceScope_crossResourceGroup=True_crossSubscription=True.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Kubernetes.Tests

🧪 tests/Aspire.Hosting.Azure.Tests/BicepUtilitiesTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/BicepUtilitiesTests.SetScopeAsync_ExistingComputeEnvironmentDoesNotChangeModuleScope_appService=False.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/BicepUtilitiesTests.SetScopeAsync_ExistingComputeEnvironmentDoesNotChangeModuleScope_appService=True.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/BicepUtilitiesTests.SetScopeAsync_ExistingComputeRoleTargetDoesNotReenterTemplateGeneration.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/BicepUtilitiesTests.SetScopeAsync_ModuleScopedComputeReferencesPreserveExplicitScope#00.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/BicepUtilitiesTests.SetScopeAsync_ModuleScopedComputeReferencesPreserveExplicitScope#01.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/BicepUtilitiesTests.SetScopeAsync_ModuleScopedComputeReferencesPreserveExplicitScope#02.verified.bicep (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

Job reasons

Job Triggered by
extension-e2e affected project Aspire.Hosting.Azure.Functions
polyglot • affected project Aspire.Hosting.Azure.Kubernetes
• affected project Aspire.Hosting.Azure.Provisioning.ContainerService
typescript-api-compat affected project Aspire.Hosting.Azure.Kubernetes

Selection computed for commit 52736e6.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because existing-cluster configurations with an ALB subnet in another resource group can generate role assignments that Bicep rejects.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #20921...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@mitchdenny

Copy link
Copy Markdown
Member Author

PR #20921 full deployment test report

Result

The full, unfiltered deployment matrix completed. No failure attributable to this PR was found. The workflow is red because one Sandbox test reproduces an independent failure on main; this is not a completely green run.

Coverage

Measurement Result
All workflow jobs 63: 61 succeeded, 1 failed, 1 skipped
Deployment matrix jobs 58: 57 succeeded, 1 failed
Actual test results across all 58 deployment jobs 71 total: 69 passed, 1 failed, 1 skipped
AKS coverage All 14 AKS jobs / 15 tests passed, with no skips
Existing-AKS resource-ID scenario Passed
Cross-resource-group AKS registry scenarios Both tests passed
Other deployment coverage ACA, App Service, Foundry, Front Door, Entra, resource scopes, run-mode role assignments, and other enabled scenarios passed

Every deployment job has a test summary; no deployment matrix entry was omitted or cancelled. The one skipped workflow job is the conditional issue-creation job, not a deployment job.

The Connector Namespace matrix job succeeded, but its single test was dynamically skipped because ASPIRE_DEPLOYMENT_TEST_ENABLE_CONNECTOR_NAMESPACE=false. The logged reason requires preview enrollment before opt-in. Connector Namespace deployment behavior is therefore unvalidated, not passed. No environment flag was changed to bypass that prerequisite.

Sole failure: Sandbox protected frontend port registration

Test: AzureSandboxesDeploymentTests.DeployDotNetProjectsWithEndpointsAndAzureStorageToAzureSandbox.

Failed PR job.

The deployment reached the Sandbox data-plane operation POST .../sandboxes/<id>/ports/add, which returned HTTP 400 Bad Request during deploy-frontend-sandbox-container. This is a service response, not an assertion failure, build failure, Bicep compilation failure, provisioning timeout, or AKS failure.

The pipeline completed 25 of 27 steps. The anonymous Sandbox deployment and its storage role provisioning succeeded; the protected frontend port registration failed. The second test in the same job, RedeployProjectToAzureSandboxRetainsPreviousPublicUrl, passed.

Relationship to this PR: pre-existing, high confidence

  1. The same test independently failed at the same ports/add operation with HTTP 400 in the same-day main job, at main commit cec61ac9b795bbfd9913f0c7196689b0d7a215d7, without this PR.
  2. The previous main job, at commit 1d3c45f9a299c30d46fc3166148902d466043df2, also failed identically.
  3. This scenario creates a new Sandbox group with AddAzureSandboxGroup("env"); it does not use an existing compute annotation or adopt an AKS cluster. The PR's scope/reference changes specifically affect existing-resource handling. The Sandbox port-registration/authentication code is not changed by the PR.
  4. The directly relevant AKS deployments, including existing-cluster adoption, resource-ID handling, role grants, and cross-group registry access, all passed.

The strongest supported classification is a repeatable pre-existing Sandbox issue, not a regression introduced by this PR. It should not be dismissed as a random flake: independent runs repeatedly fail at the same operation.

What remains uncertain

The service error body is redacted in both the job output and the detailed CLI logs. The exact backend validation rule is consequently unknown. The failing frontend uses the default Entra-protected external endpoint, whereas the explicitly anonymous endpoint succeeds. This narrows the likely area to protected-port configuration or the preview service's handling of it, but does not prove a specific authentication, tenant, request-contract, or service defect.

No claim is made that this is definitely infrastructure-only rather than an existing Sandbox product/API-contract bug. Resolving that distinction requires the service-side rejection reason or a separately scoped Sandbox investigation.

Other previously seen failures

Foundry's previous “Project not found” failure, the custom-registry DNS failure, Entra authorization failure, and Front Door timeout did not occur in this run. They are not current failures and are not counted as such.

Evidence retained

Files are in this session's files/validation/ directory:

  • nov3-full-deployment-status.json: complete job metadata.
  • nov3-full-deployment.log: complete workflow logs, including all 58 test summaries.
  • nov3-sandbox-failed-job.log: isolated failed job log.
  • nov3-sandbox-results/: TRX, detailed Aspire CLI logs, and collected recordings.
  • nov3-sandbox-recordings/: both Sandbox terminal recordings.
  • nov3-same-day-main-sandbox.log: independent same-day main failure.
  • nov3-main-baseline-sandbox.log: prior main failure.

Downloaded evidence is retained for inspection outside the repository. No test report was manually posted to the PR or issue.

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2042

Generated by PR Documentation Check · copilot · auto · 28.8 AIC · ⌖ 1.17 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2042 targeting release/17.0.

Added a "Use an existing AKS cluster" section to the AKS integration page (integrations/cloud/azure/aks/index.mdx). Triggered signals: integration_readme_changed (Aspire.Hosting.Azure.Kubernetes/README.md), pr_body_has_user_facing_section (AsExisting / AsExistingInResourceGroup usage), pr_body_has_cli_flag_mention.

Note

This draft PR needs human review before merging.

This branch was previously deployed

1 inactive deployment
deployment-testing — 52736e6a Deployed Nov 3, 2026 by mitchdenny via Deploy (Deployment.EndToEnd-AppServiceReactDeploymentTests) #938
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AsExisting(...) support for AddAzureKubernetesEnviroment (ACR parity)

6 participants