Skip to content

Fix Azure Sandbox deployment principal binding - #19801

Merged
Mitch Denny (mitchdenny) merged 7 commits into
mainfrom
mitchdenny-azure-sandbox-e2e
Aug 31, 2026
Merged

Mitch Denny (mitchdenny) merged 7 commits into
mainfrom
mitchdenny-azure-sandbox-e2e

Conversation

@mitchdenny

@mitchdenny Mitch Denny (mitchdenny) commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

Description

Azure Sandbox deployments provision the sandbox group through ARM, then use the Azure Dev Compute data-plane API to create disk images, sandboxes, lifecycle settings, and public ports. Those post-provisioning calls run as the authenticated deployment principal, which therefore needs the scoped Container Apps SandboxGroup Data Owner role.

The recently merged Sandbox integration modeled this role assignment with the generic principalId parameter. Direct aspire deploy intentionally refuses to infer that parameter in publish mode because it normally represents an application managed identity. As a result, the real Sandbox deployment E2E test failed before provisioning with An Azure principal parameter was not supplied a value.

This change restores the existing dedicated UserPrincipalId path:

  • The Sandbox role assignment uses the deployment principal's object ID and detected principal type.
  • Direct aspire deploy binds those values from the authenticated Azure credential.
  • Published main.bicep artifacts promote and forward both deployment-principal parameters.
  • Explicit UserPrincipalId values require a matching explicit PrincipalType in run and publish modes.
  • Generic application-principal publishing behavior remains unchanged.
  • The existing public KnownParameters.UserPrincipalId API and "userPrincipalId" Bicep wire value remain unchanged.

User-facing usage

Integration authors should continue using the existing parameter when defining infrastructure that grants access to the identity performing deployment:

var userPrincipalId = new ProvisioningParameter(
    AzureBicepResource.KnownParameters.UserPrincipalId,
    typeof(Guid));

Breaking changes

None. The existing public API and generated Bicep parameter name are unchanged.

Security considerations

The Sandbox integration grants the authenticated deployment identity the built-in Container Apps SandboxGroup Data Owner role scoped to the provisioned sandbox group. This is required for the Azure Dev Compute data-plane operations performed after ARM provisioning. The change does not broaden the role or its scope, expose credentials, or alter token acquisition.

Validation

  • Merged latest main (54c1f929ae) into final head f3516bebc1.
  • Full deployment E2E matrix on the merged head: 45/45 deployment jobs and 50/50 tests passed on the first attempt in run 33356816901.
  • Azure Sandbox deploy/redeploy passed, including verification that both the previous and current public URLs remained reachable.
  • Local Azure CLI user-principal deploy: role assignment type User, live endpoint verified, and Azure resources deleted.
  • Final Aspire.Hosting.Azure.Tests run before the merge: 1,790 passed, 5 skipped, 0 failed.

Fixes # (issue)

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
    • 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

Use the dedicated deployment-principal parameter for sandbox data-plane role assignments so direct aspire deploy can bind the authenticated principal in publish mode.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: e6ccdb9b-cd9e-494d-b25f-f14fedca1440
Add DeploymentPrincipalId as the canonical API while preserving the existing userPrincipalId Bicep wire name. Obsolete UserPrincipalId as a compatibility alias and migrate first-party consumers.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: e6ccdb9b-cd9e-494d-b25f-f14fedca1440
Copilot AI balanced review requested due to automatic review settings August 29, 2026 06:10
@mitchdenny Mitch Denny (mitchdenny) added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Aug 29, 2026
@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 -- 19801

Or

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

@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Aug 29, 2026
@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.

Copilot review overview

Review tier: Balanced
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxesExtensions.cs — principalType is populated only by the direct aspire deploy provisioner. In the `aspire…
What changed in this PR

Fixes Azure Sandbox RBAC binding by distinguishing the deployment principal from application managed identities.

Changes:

  • Adds DeploymentPrincipalId while preserving UserPrincipalId as an obsolete compatibility alias.
  • Binds Sandbox role assignments to the deployment principal ID and type.
  • Updates consumers, tests, and generated snapshots.
File Description
tests/​Aspire.Hosting.Azure.Tests/​Snapshots/​AzureSandboxesTests.WithNoManagedIdentityClearsGroupIdentityButPreservesComputeWorkloadIdentity.verified.bicep Updates Sandbox RBAC snapshot.
tests/​Aspire.Hosting.Azure.Tests/​Snapshots/​AzureSandboxesTests.SandboxGroupWithSystemAssignedWorkloadIdentityAlsoEmitsImagePullIdentity.verified.bicep Updates system-identity snapshot.
tests/​Aspire.Hosting.Azure.Tests/​Snapshots/​AzureSandboxesTests.SandboxGroupWithoutWorkloadIdentityEmitsImagePullIdentity.verified.bicep Updates no-workload-identity snapshot.
tests/​Aspire.Hosting.Azure.Tests/​Snapshots/​AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#01.verified.json Adds deployment-principal manifest parameters.
tests/​Aspire.Hosting.Azure.Tests/​Snapshots/​AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#01.verified.bicep Updates worker-group RBAC output.
tests/​Aspire.Hosting.Azure.Tests/​Snapshots/​AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#00.verified.json Adds host-group manifest parameters.
tests/​Aspire.Hosting.Azure.Tests/​Snapshots/​AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#00.verified.bicep Updates host-group RBAC output.
tests/​Aspire.Hosting.Azure.Tests/​AzureBicepResourceTests.cs Verifies API and wire-name compatibility.
tests/​Aspire.Hosting.Azure.Tests/​AzureBicepProvisionerTests.cs Tests direct deployment-principal binding.
src/​Aspire.Hosting.Foundry/​Project/​ProjectBuilderExtension.cs Uses the canonical parameter name.
src/​Aspire.Hosting.Azure/​Provisioning/​Provisioners/​BicepProvisioner.cs Populates deployment principal details.
src/​Aspire.Hosting.Azure/​Provisioning/​BicepUtilities.cs Recognizes the canonical known parameter.
src/​Aspire.Hosting.Azure/​AzurePublishingContext.cs Maps the renamed deployment-principal ID.
src/​Aspire.Hosting.Azure/​AzureBicepResource.cs Adds the API and compatibility alias.
src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxesExtensions.cs Assigns scoped Sandbox data-owner RBAC.
src/​Aspire.Hosting.Azure.AppService/​AzureAppServiceEnvironmentExtensions.cs Migrates App Service usage.
src/​Aspire.Hosting.Azure.AppContainers/​AzureContainerAppExtensions.cs Migrates Container Apps usage.

@davidfowl David Fowler (davidfowl) added breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. and removed breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. labels Aug 29, 2026
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: e6ccdb9b-cd9e-494d-b25f-f14fedca1440
Copilot AI review requested due to automatic review settings August 29, 2026 08:22
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #19801...

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

View workflow run

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.

Copilot review overview

Review tier: Balanced
Findings: 2 High severity · 1 Medium severity

New issues introduced by this change (2)
Severity Finding
High severity src/​Aspire.Hosting.Azure/​AzurePublishingContext.cs — This promotes principalType for every resource with a null type, not only resources that request…
Medium severity src/​Aspire.Hosting.Azure/​Provisioning/​Provisioners/​BicepProvisioner.cs — When an explicit deployment-principal ID is supplied without principalType, this branch throws…
Pre-existing issues (1)
Severity Finding
High severity src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxesExtensions.cs — principalType is populated only by the direct aspire deploy provisioner. In the `aspire… View comment

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #19801...

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.

Copilot review overview

Review tier: Balanced
Findings: 2 High severity · 2 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​Aspire.Hosting.Azure/​Provisioning/​Provisioners/​BicepProvisioner.cs — This only rejects an explicit UserPrincipalId without a matching type in publish mode. In run…
Pre-existing issues (3)
Severity Finding
High severity src/​Aspire.Hosting.Azure/​AzurePublishingContext.cs — This promotes principalType for every resource with a null type, not only resources that request… View comment
High severity src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxesExtensions.cs — principalType is populated only by the direct aspire deploy provisioner. In the `aspire… View comment
Medium severity src/​Aspire.Hosting.Azure/​Provisioning/​Provisioners/​BicepProvisioner.cs — When an explicit deployment-principal ID is supplied without principalType, this branch throws… View comment

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: e6ccdb9b-cd9e-494d-b25f-f14fedca1440
@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.

Copilot review overview

Review tier: Balanced
Findings: None

Issues resolved since last review (4)
Severity Finding
Medium severity src/​Aspire.Hosting.Azure/​Provisioning/​Provisioners/​BicepProvisioner.cs — This only rejects an explicit UserPrincipalId without a matching type in publish mode. In run… View resolved comment
Medium severity src/​Aspire.Hosting.Azure/​Provisioning/​Provisioners/​BicepProvisioner.cs — When an explicit deployment-principal ID is supplied without principalType, this branch throws… View resolved comment
High severity src/​Aspire.Hosting.Azure/​AzurePublishingContext.cs — This promotes principalType for every resource with a null type, not only resources that request… View resolved comment
High severity src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxesExtensions.cs — principalType is populated only by the direct aspire deploy provisioner. In the `aspire… View resolved comment

@github-actions

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.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #19801...

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

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

11 / 99 PR test projects · 2 PR jobs · 1 advisory-only target, from 15 changed files.

Selected PR test projects (11 / 99)

Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Tests, Aspire.Playground.Tests

Selected PR jobs (2)

extension-e2e, typescript-api-compat

Advisory workflow impact (1)

  • deployment-e2e (schedule/dispatch-only)

How these were chosen — grouped by what changed

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

🔧 src/Aspire.Hosting.Azure/AzurePublishingContext.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests
→ 9 via the project graph: Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Blazor.Tests (3 hops), Aspire.Hosting.CodeGeneration.TypeScript.Tests (2 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)

🧪 tests/Aspire.Hosting.Azure.Tests/AzureBicepProvisionerTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests
→ 1 via the project graph: Aspire.Hosting.Azure.Kubernetes.Tests

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

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

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

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

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

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

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#00.verified.json (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

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

🧪 tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#01.verified.json (changed test)
→ 1 directly: Aspire.Hosting.Azure.Tests

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

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

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

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

Job reasons

Job Triggered by
deployment-e2e affected project Aspire.Hosting.Azure.Sandboxes
extension-e2e • src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs, src/Aspire.Hosting.Azure/AzurePublishingContext.cs, src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs
• affected project Aspire.Hosting.Azure.Sandboxes
typescript-api-compat affected project Aspire.Hosting.Azure.Sandboxes

Selection computed for commit f3516be.

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.

Copilot review overview

Review tier: Balanced
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​Aspire.Hosting.Azure/​AzurePublishingContext.cs — The publish-artifact path still accepts an explicit UserPrincipalId with a null PrincipalType.…

Comment on lines +344 to +351
if (parameter.Key == AzureBicepResource.KnownParameters.PrincipalType &&
parameter.Value is null &&
resource.Parameters.TryGetValue(AzureBicepResource.KnownParameters.UserPrincipalId, out var userPrincipalId) &&
userPrincipalId is null)
{
module.Parameters.Add(parameter.Key, deploymentPrincipalType!);
continue;
}
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

Step 5 branch taken: docs_required → false positive (no concrete change to document).

Triggered signals (1): pr_body_has_user_facing_section — the PR body contains a "### User-facing usage" heading, which mechanically satisfies the signal.

Why this is a false positive: The section under that heading states integration authors should continue using the existing parameter (AzureBicepResource.KnownParameters.UserPrincipalId) exactly as before: new ProvisioningParameter(AzureBicepResource.KnownParameters.UserPrincipalId, typeof(Guid)). The PR itself confirms "Breaking changes: None. The existing public API and generated Bicep parameter name are unchanged." This is an internal bug fix restoring the deployment principal binding for the newly-added, still-experimental (ASPIREAZURE001) Azure Sandboxes integration’s post-provisioning role assignment — it corrects a regression in generated Bicep parameter wiring (principalId vs the dedicated UserPrincipalId/PrincipalType path) with no change to any public API, CLI flag, generated output shape, or integration-author-facing behavior.

I confirmed there is no existing microsoft/aspire.dev documentation page for the Azure Sandboxes integration at all (searched src/frontend/src/content/docs/ for sandbox, Sandbox, AzureSandbox, and UserPrincipalId — no matches outside of auto-generated package-API JSON data files). Since the integration is preview/experimental and undocumented on the site, and this PR does not change any user-visible surface, contract, or generated-Bicep parameter name, there is no concrete documentation edit this change requires.

This branch was previously deployed

1 inactive deployment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants