Repository navigation
Fix Azure Sandbox deployment principal binding - #19801
Conversation
Co-authored-by: Copilot App <[email protected]>
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
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19801Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19801" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
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
DeploymentPrincipalIdwhile preservingUserPrincipalIdas 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. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: e6ccdb9b-cd9e-494d-b25f-f14fedca1440
This comment has been minimized.
This comment has been minimized.
|
🚀 Deployment tests starting on PR #19801... This will deploy to real Azure infrastructure. Results will be posted here when complete. |
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 2
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
src/Aspire.Hosting.Azure/AzurePublishingContext.cs — This promotes principalType for every resource with a null type, not only resources that request… |
|
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 |
|---|---|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs — principalType is populated only by the direct aspire deploy provisioner. In the `aspire… View comment |
|
🚀 Deployment tests starting on PR #19801... This will deploy to real Azure infrastructure. Results will be posted here when complete. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 2
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
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 |
|---|---|
src/Aspire.Hosting.Azure/AzurePublishingContext.cs — This promotes principalType for every resource with a null type, not only resources that request… View comment |
|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs — principalType is populated only by the direct aspire deploy provisioner. In the `aspire… View comment |
|
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
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: None
Issues resolved since last review (4)
| Severity | Finding |
|---|---|
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 |
|
src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs — When an explicit deployment-principal ID is supplied without principalType, this branch throws… View resolved comment |
|
src/Aspire.Hosting.Azure/AzurePublishingContext.cs — This promotes principalType for every resource with a null type, not only resources that request… View resolved comment |
|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs — principalType is populated only by the direct aspire deploy provisioner. In the `aspire… View resolved comment |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
🚀 Deployment tests starting on PR #19801... This will deploy to real Azure infrastructure. Results will be posted here when complete. |
Tests selector11 / 99 PR test projects · 2 PR jobs · 1 advisory-only target, from 15 changed files. Selected PR test projects (11 / 99)
Selected PR jobs (2)
Advisory workflow impact (1)
How these were chosen — grouped by what changed
🔧 🧪 🔧 🔧 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Aspire.Hosting.Azure/AzurePublishingContext.cs — The publish-artifact path still accepts an explicit UserPrincipalId with a null PrincipalType.… |
| 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; | ||
| } |
|
✅ No documentation update needed. Step 5 branch taken: Triggered signals (1): Why this is a false positive: The section under that heading states integration authors should continue using the existing parameter ( I confirmed there is no existing |


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
principalIdparameter. Directaspire deployintentionally 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 withAn Azure principal parameter was not supplied a value.This change restores the existing dedicated
UserPrincipalIdpath:aspire deploybinds those values from the authenticated Azure credential.main.bicepartifacts promote and forward both deployment-principal parameters.UserPrincipalIdvalues require a matching explicitPrincipalTypein run and publish modes.KnownParameters.UserPrincipalIdAPI 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:
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
main(54c1f929ae) into final headf3516bebc1.User, live endpoint verified, and Azure resources deleted.Aspire.Hosting.Azure.Testsrun before the merge: 1,790 passed, 5 skipped, 0 failed.Fixes # (issue)
Checklist