Repository navigation
Add Azure Container Apps Sandboxes deployment target - #19008
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19008Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19008" |
There was a problem hiding this comment.
Pull request overview
Adds an experimental Azure Container Apps Sandboxes deployment target, including provisioning, image inspection, ADC deployment lifecycle, endpoint state, and validation coverage.
Changes:
- Adds sandbox-group provisioning and container deployment APIs.
- Adds ADC lifecycle, retry, cleanup, identity, and ACR support.
- Adds C#, TypeScript, snapshot, and deployment E2E coverage.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/deployment-tests.yml |
Gates sandbox deployment tests. |
Aspire.slnx |
Adds the new project. |
src/Aspire.Hosting.Azure.Sandboxes/Aspire.Hosting.Azure.Sandboxes.csproj |
Defines the integration package. |
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxCleanupResource.cs |
Adds stale deployment cleanup. |
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs |
Implements deploy, state, endpoint, and destroy flows. |
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs |
Defines sandbox options and tiers. |
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerResource.cs |
Models sandbox deployment targets. |
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxEndpointPropertyValueProvider.cs |
Resolves deployed endpoint properties. |
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxGroupResource.cs |
Models the sandbox environment. |
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs |
Adds public builder APIs and provisioning. |
src/Aspire.Hosting.Azure.Sandboxes/Internal/Adc/AzureDevComputeClient.cs |
Implements the ADC preview client. |
src/Aspire.Hosting.Azure.Sandboxes/Provisioning/SandboxGroup.cs |
Defines sandbox-group Bicep resources. |
src/Aspire.Hosting.Azure.Sandboxes/Provisioning/SandboxesResourceVersions.cs |
Pins the preview API version. |
src/Aspire.Hosting.Azure.Sandboxes/README.md |
Documents usage and limitations. |
src/Aspire.Hosting.Azure.Sandboxes/api/Aspire.Hosting.Azure.Sandboxes.ats.txt |
Records the ATS surface. |
src/Aspire.Hosting.Azure.Sandboxes/api/Aspire.Hosting.Azure.Sandboxes.cs |
Records the .NET API surface. |
src/Aspire.Hosting.Azure/AcrLoginService.cs |
Exposes retryable ACR token retrieval. |
src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj |
Grants sandbox internals access. |
src/Aspire.Hosting.Azure/IAcrLoginService.cs |
Adds the refresh-token contract. |
src/Aspire.Hosting.Azure/Provisioning/BicepUtilities.cs |
Adds contextual value resolution. |
src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultUserPrincipalProvider.cs |
Detects service principals. |
src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs |
Binds deployment principal metadata. |
src/Aspire.Hosting.Azure/Provisioning/ProvisioningContext.cs |
Tracks principal type. |
src/Aspire.Hosting/Publishing/ContainerRuntimeBase.cs |
Adds image inspection and process injection. |
src/Aspire.Hosting/Publishing/DockerContainerRuntime.cs |
Injects the process runner. |
src/Aspire.Hosting/Publishing/IContainerImageInspector.cs |
Defines image-inspection APIs. |
src/Aspire.Hosting/Publishing/PodmanContainerRuntime.cs |
Adds Podman manifest inspection. |
src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs |
Uses the injectable process runner. |
tests/Aspire.Deployment.EndToEnd.Tests/AzureSandboxesDeploymentTests.cs |
Exercises deploy, redeploy, URLs, and destroy. |
tests/Aspire.Hosting.Azure.Tests/AcrLoginServiceTests.cs |
Tests refresh-token retries. |
tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj |
References the sandbox package. |
tests/Aspire.Hosting.Azure.Tests/AzureBicepProvisionerTests.cs |
Tests principal parameter binding. |
tests/Aspire.Hosting.Azure.Tests/AzureSandboxesTests.cs |
Covers sandbox provisioning and ADC behavior. |
tests/Aspire.Hosting.Azure.Tests/DefaultUserPrincipalProviderTests.cs |
Tests service-principal detection. |
tests/Aspire.Hosting.Azure.Tests/FakeAcrLoginService.cs |
Supports refresh-token tests. |
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxGroupAddsDeploymentPrincipalDataOwnerRoleAssignment.verified.bicep |
Captures role-assignment Bicep. |
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxGroupAddsDeploymentPrincipalDataOwnerRoleAssignment.verified.json |
Captures role-assignment manifest. |
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#00.verified.bicep |
Captures identity-enabled group Bicep. |
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#00.verified.json |
Captures identity-enabled manifest. |
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#01.verified.bicep |
Captures basic group Bicep. |
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureSandboxesTests.AddAzureSandboxResourcesGeneratesBicep#01.verified.json |
Captures basic group manifest. |
tests/Aspire.Hosting.TestUtilities/Publishing/FakeContainerRuntime.cs |
Fakes image inspection. |
tests/Aspire.Hosting.Tests/Publishing/ContainerRuntimeBaseTests.cs |
Tests output capture and argument escaping. |
tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/apphost.mts |
Exercises generated TypeScript APIs. |
tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/aspire.config.json |
Configures the polyglot integration. |
tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package.json |
Defines TypeScript validation tooling. |
tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/tsconfig.json |
Configures TypeScript compilation. |
Review details
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (1)
src/Aspire.Hosting.Azure.Sandboxes/README.md:21
- Hosting integration READMEs use the Aspire CLI installation flow, not
dotnet add package. Replace this section with the exactaspire add Aspire.Hosting.Azure.Sandboxescommand in abashblock so installation follows the supported AppHost workflow.
### Install the package
In your AppHost project, install the Aspire Azure Sandboxes Hosting library with [NuGet](https://www.nuget.org):
```dotnetcli
dotnet add package Aspire.Hosting.Azure.Sandboxes
</details>
- **Files reviewed:** 47/48 changed files
- **Comments generated:** 8
- **Review effort level:** Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
There was a problem hiding this comment.
Review details
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (8)
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs:82
AddAzureSandboxGroupalways adds anAzureProvisioningResource, so ordinary run mode schedules its Bicep provisioning even thoughPublishAsAzureSandboxis a no-op and no local workload can use the group. This can create a sandbox group duringaspire run. Keep the deployment environment out of the run model, asAddAzureContainerAppEnvironmentdoes inAzureContainerAppExtensions.cs:630-634, and register the cleanup/provisioning-only pieces only for publish/deploy.
return builder.AddResource(resource);
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:581
- A reference containing
@bypasses inspection entirely, so an ARM64 manifest digest or a multi-architecture index digest is accepted unchanged. The single-manifest path also does not verify platform metadata. This contradicts the integration's Linux/amd64 guarantee and can produce a disk image that cannot boot; inspect digest references too and reject or resolve anything not proven to be Linux/amd64.
if (imageReference.Contains('@', StringComparison.Ordinal))
{
return imageReference;
}
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:36
- This property accepts only three validated string literals, so the string type provides no forward-compatibility benefit and leaves both C# and generated TypeScript callers vulnerable to casing/typing mistakes. Model the closed set as an exported
AzureSandboxAutoSuspendModeenum, consistent withAzureSandboxTier.
/// <summary>
/// Gets or sets the sandbox suspend mode. Supported values are <c>Memory</c>, <c>Disk</c>, and <c>None</c>.
/// </summary>
public string? AutoSuspendMode { get; set; }
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:56
- This property accepts only two validated string literals, which makes the public C# and TypeScript contract unnecessarily typo-prone. Use an exported
AzureSandboxAutoDeleteTriggerenum instead of accepting arbitrary strings and rejecting them at runtime.
/// <summary>
/// Gets or sets the auto-delete trigger. Supported values are <c>AfterSuspend</c> and <c>AfterCreation</c>.
/// </summary>
public string? AutoDeleteTrigger { get; set; }
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:100
Nameis logically required—validation rejects null/empty values and the generated ATS surface already presents it as required—but the C# API allows callers to omit it and fail later duringPublishAsAzureSandbox. Make the property required and non-nullable so invalid endpoint options are rejected by the type system.
/// <summary>
/// Gets or sets the Aspire endpoint name.
/// </summary>
public string? Name { get; set; }
src/Aspire.Hosting.Azure.Sandboxes/README.md:25
- The integration exports a TypeScript API, but the only README usage example is C#. Add the corresponding TypeScript AppHost example so generated-SDK users can discover the supported
addAzureSandboxGroupandpublishAsAzureSandboxcall shape.
## Usage example
Then, in the _AppHost.cs_ file of `AppHost`, add an Azure sandbox group and publish a compute resource to it using the following methods:
src/Aspire.Hosting.Azure.Sandboxes/README.md:72
- Hosting integration READMEs must include the Aspire integration gallery in Additional documentation. Add the gallery link alongside the service documentation.
## Additional documentation
* https://learn.microsoft.com/azure/container-apps/sandboxes-overview
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:241
- This call is intended to make generation pruning best-effort, but
DeleteSandboxAsyncandDeleteDiskImageAsyncsuppress onlyInvalidOperationException. An exhausted network retry throwsHttpRequestException, escapes despitethrowOnError: false, and turns an otherwise successful deploy into failure cleanup that deletes the newly created generation. Suppress non-cancellation client failures whenthrowOnErroris false.
throwOnError: false).ConfigureAwait(false);
- Files reviewed: 47/48 changed files
- Comments generated: 2
- Review effort level: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
There was a problem hiding this comment.
Review details
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (4)
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs:82
- This always adds the sandbox group (and the default ACR created above) to the run-mode model, even though
PublishAsAzureSandboxintentionally does nothing in run mode. Consequently, simply using the documented AppHost API can provision unused Azure resources during local execution. Follow the other deployment environments' pattern: in run mode returnCreateResourceBuilder(resource)and avoid adding the cleanup/default-registry resources; add them only in publish mode.
var resource = new AzureSandboxGroupResource(name, ConfigureInfrastructure)
{
DefaultContainerRegistry = CreateDefaultAzureContainerRegistry(builder, $"{name}-acr")
};
return builder.AddResource(resource);
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:589
- Digest-pinned references bypass image inspection entirely, so an ARM64 manifest, a multi-platform index digest, or even a malformed
@...reference is accepted without enforcing the documented Linux/amd64 requirement. Inspect pinned references too and resolve an index to its Linux/amd64 child digest before creating the disk image.
private static async Task<string> ResolveContainerImageReferenceForDiskImageAsync(PipelineStepContext context, string imageReference)
{
if (imageReference.Contains('@', StringComparison.Ordinal))
{
return imageReference;
src/Aspire.Hosting.Azure.Sandboxes/README.md:29
- The integration exports TypeScript APIs, but the new hosting README documents only C#. Add the minimal TypeScript AppHost sample for
addAzureSandboxGroupandpublishAsAzureSandboxso TypeScript consumers can discover the supported usage pattern.
```csharp
var sandboxGroup = builder.AddAzureSandboxGroup("sandboxes");
src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultUserPrincipalProvider.cs:70
appidcannot distinguish applications from users: Microsoft documents that the client application can act as itself or on behalf of a user. A user token withidtyp: "user"but withoutupn/emailis therefore classified asServicePrincipal, causing the generated role assignment to use the wrong principal type. Preserve and honor the explicituseridentity type before falling back toappid.
else if (header == "idtyp")
{
reader.Read();
isAppPrincipal = string.Equals(reader.GetString(), "app", StringComparison.OrdinalIgnoreCase);
}
- Files reviewed: 47/48 changed files
- Comments generated: 0 new
- Review effort level: Balanced
There was a problem hiding this comment.
Review details
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (7)
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:122
- Same-group endpoint references are not ordered against the producer sandbox deployment. This only depends on the consumer's image push, so on a first deploy the consumer can resolve
AzureSandboxEndpointPropertyValueProviderbefore the producer has persisted a URL and fail with “does not have a deployed URL yet.” Add dependencies on referenced sandbox deploy steps (or reject these references) and cover an actual two-resource first deployment.
public static void ConfigureDeployOrdering(PipelineConfigurationContext context, AzureSandboxContainerResource resource)
{
var pushSteps = context.GetSteps(resource.TargetResource, WellKnownPipelineTags.PushContainerImage);
var deploySteps = context.GetSteps(resource, WellKnownPipelineTags.DeployCompute);
deploySteps.DependsOn(pushSteps);
}
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs:82
- This publish-only deployment environment is still added to the run-mode model. Unlike
PublishAsAzureSandbox, callingAddAzureSandboxGroupduring local run therefore leaves an active Azure provisioning resource that can provision a sandbox group even though no workload targets it. Return a non-added resource builder in run mode, as other deployment environments do.
return builder.AddResource(resource);
tests/Aspire.Deployment.EndToEnd.Tests/AzureSandboxesDeploymentTests.cs:221
- Cleanup is always reported as successful even when
CleanupResourceGroupAsyncfails to startaz, returns a nonzero exit code, or catches an exception. This hides orphaned Azure resources in deployment reports. Return/propagate the actual cleanup result and pass that status here.
output.WriteLine($"Triggering cleanup of resource group: {resourceGroupName}");
await CleanupResourceGroupAsync(resourceGroupName);
DeploymentReporter.ReportCleanupStatus(resourceGroupName, success: true, "Cleanup triggered");
tests/Aspire.Deployment.EndToEnd.Tests/AzureSandboxesDeploymentTests.cs:40
- The sandbox deployment is only opt-in in CI; local test runs ignore
ASPIRE_DEPLOYMENT_TEST_ENABLE_SANDBOXESand will create billable preview Azure resources whenever credentials are available. This contradicts the documented gated scenario. Require the flag on every environment and report the test as skipped when it is absent.
if (DeploymentE2ETestHelpers.IsRunningInCI &&
!string.Equals(Environment.GetEnvironmentVariable(EnableSandboxesEnvironmentVariable), "true", StringComparison.OrdinalIgnoreCase))
{
output.WriteLine($"Azure sandboxes deployment tests are disabled. Set {EnableSandboxesEnvironmentVariable}=true for the deployment-testing environment to enable them.");
return;
}
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:72
AzureSandboxTieris a new public type in this experimental deployment surface, but the enum itself is not marked experimental. Consumers can referenceAzureSandboxTier.Mediumdirectly without receiving the preview diagnostic. Apply the package's experimental attribute to the enum as well.
public enum AzureSandboxTier
src/Aspire.Hosting.Azure.Sandboxes/api/Aspire.Hosting.Azure.Sandboxes.cs:7
- This checked-in file is an auto-generated API compatibility baseline. Repository guidance reserves
*/api/*.csupdates for the release/API-baseline workflow; feature PRs should change the source API and let validation generate the current surface separately. Remove this generated baseline from the PR.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
src/Aspire.Hosting.Azure.Sandboxes/README.md:27
- The integration exports and validates a TypeScript API, but the hosting README documents only C#. Add the generated TypeScript AppHost usage so polyglot users can discover the supported
addAzureSandboxGroupandpublishAsAzureSandboxpath.
## Usage example
Then, in the _AppHost.cs_ file of `AppHost`, add an Azure sandbox group and publish a compute resource to it using the following methods:
```csharp
- Files reviewed: 47/48 changed files
- Comments generated: 0 new
- Review effort level: Balanced
There was a problem hiding this comment.
Review details
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (3)
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs:82
AddAzureSandboxGroupis a publish/deploy environment, but this unconditionally adds it to the application model in Run mode. UnlikePublishAsAzureSandbox, that leaves the sandbox group visible to local Azure provisioning even though no local sandbox deployment target is created. Match the established deployment-environment pattern inAzureContainerAppExtensions.cs:630-634and return an unattached resource builder in Run mode.
return builder.AddResource(resource);
src/Aspire.Hosting.Azure.Sandboxes/README.md:72
- The standard hosting integration README structure requires the Aspire integrations gallery in Additional documentation. Without it, this new integration omits the common discovery link included by the repository's hosting README guidance.
## Additional documentation
* https://learn.microsoft.com/azure/container-apps/sandboxes-overview
src/Aspire.Hosting.Azure.Sandboxes/README.md:27
- These APIs are exported to TypeScript and this PR includes TypeScript validation, but the hosting README only documents C#. Hosting integration READMEs must include both C# and TypeScript AppHost examples when the API is exported; add the equivalent TypeScript usage so that supported polyglot usage is discoverable.
```csharp
- Files reviewed: 47/48 changed files
- Comments generated: 1
- Review effort level: Balanced
There was a problem hiding this comment.
Review details
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (5)
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:590
- A digest proves immutability but not that it is a concrete Linux/amd64 manifest. This short-circuit lets a Windows manifest or a multi-platform index digest bypass platform selection; moreover,
CreateDigestImageReferencepreserves an existing@...value even if inspection later selects a child digest. Inspect digest references as well and replace an index digest with the selected Linux/amd64 child digest before creating the disk image.
if (imageReference.Contains('@', StringComparison.Ordinal))
{
return imageReference;
}
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:260
- If either collection PUT succeeds remotely but its response is lost,
CreateDiskImageAsync/CreateSandboxAsyncthrows before the returned ID is assigned, so this cleanup skips the newly created resource. The request already carries this deployment's ownership labels; on failure, perform a bounded label-based sweep for the currentdeployId(while retaining the previous generation) so an ambiguous network failure does not leave billable orphaned resources.
catch
{
if (!string.IsNullOrWhiteSpace(sandboxId))
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs:80
- This publish/deploy environment is added to the application model during Run mode, so the standard AppHost usage can trigger Azure provisioning for the sandbox group during
aspire runeven thoughPublishAsAzureSandboxdeliberately does nothing in Run mode. Deployment environments elsewhere use an unattached builder in Run mode (for example AzureContainerAppExtensions.cs:630-634 and AzureKubernetesEnvironmentExtensions.cs:83-86). Keep this resource out of the Run model as well.
return builder.AddResource(resource);
src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultUserPrincipalProvider.cs:81
- The fallback treats any token with
appidbut noupn/emailas app-only.appididentifies the client application in both app-only and delegated app+user tokens, so a delegated token that exposespreferred_usernameinstead can assignprincipalType: ServicePrincipalto the user'soid, causing RBAC deployment to fail. Microsoft recommendsidtyp(or thescp/rolestoken shape) to distinguish these cases; please do not useappidpresence as that discriminator.
var hasAppId = !string.IsNullOrEmpty(appId);
var principalType = isAppPrincipal || (string.IsNullOrEmpty(principalName) && hasAppId)
? RoleManagementPrincipalType.ServicePrincipal
: RoleManagementPrincipalType.User;
src/Aspire.Hosting.Azure.Sandboxes/README.md:29
- This integration exports its APIs to TypeScript, but the hosting README's only usage example is C# and it does not demonstrate the required resource-reference flow. Add the corresponding TypeScript AppHost example and show a compute resource consuming a sandbox endpoint/reference so users can see the supported end-to-end pattern.
Then, in the _AppHost.cs_ file of `AppHost`, add an Azure sandbox group and publish a compute resource to it using the following methods:
```csharp
var sandboxGroup = builder.AddAzureSandboxGroup("sandboxes");
- Files reviewed: 47/48 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Move ADC disk image creation to the V2 managed identity contract and keep sandbox-specific provisioning out of the shared Azure hosting infrastructure. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs — The PR description still says disk-image creation exchanges Azure credentials for short-lived ACR… |
|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs — These branches make the public identity APIs report a configuration that is never emitted:… |
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Allow enough reconciliation time for Windows timer granularity while retaining the one-millisecond poll interval. Co-authored-by: Copilot <[email protected]>
|
Mitch Denny (@mitchdenny) Addressed the V2/UAMI feedback in
I also restacked #19024 and removed its dependency on the Azure internals that were dropped here. Ready for another look when you have a chance—thanks for the direct Azure validation. |
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
Pre-existing issues (2)
| Severity | Finding |
|---|---|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs — These branches make the public identity APIs report a configuration that is never emitted:… View comment |
|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs — The PR description still says disk-image creation exchanges Azure credentials for short-lived ACR… View comment |
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:61
- Although
Endpointsis nullable and the deployment code treats it as optional, nullable reference types are not considered byIsOptionalDtoProperty; this is therefore emitted as required in the generated TypeScript DTO. Any TypeScript caller that supplies lifecycle options is forced to add an unrelatedendpoints: []. Please use an ATS-facing projection that makes this property optional.
public AzureSandboxEndpointOptions[]? Endpoints { get; set; }
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:21
Tierhas a C# default, but the ATS scanner only marks nullable value types or init-only properties optional. Because this uses a regular setter, the generated TypeScript DTO requirestierwhenever any options object is supplied, so callers cannot rely on the documentedMediumdefault while configuring an unrelated setting. Please project this through an ATS-facing options shape wheretieris optional (or otherwise make the generated contract preserve the default).
public AzureSandboxTier Tier { get; set; } = AzureSandboxTier.Medium;
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Co-authored-by: Copilot <[email protected]>
|
Mitch Denny (@mitchdenny) Follow-up is complete in |
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.RemoteHost/Ats/AtsMarshaller.cs — This converter changes every ATS DTO TimeSpan number to milliseconds, but existing TypeScript DTO… |
Issues resolved since last review (2)
| Severity | Finding |
|---|---|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxesExtensions.cs — These branches make the public identity APIs report a configuration that is never emitted:… View resolved comment |
|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs — The PR description still says disk-image creation exchanges Azure credentials for short-lived ACR… View resolved comment |
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:125
Nameis mandatory—the validator rejects null or whitespace—yet the nullable declaration makes it optional in the generated TypeScript DTO and defers the error until publish time. Model this as a required non-null property so C# and TypeScript callers get compile-time validation.
public string? Name { get; set; }
tests/Aspire.Deployment.EndToEnd.Tests/AzureSandboxesDeploymentTests.cs:36
- The sandbox opt-in is only enforced in CI. Locally, anyone with the normal deployment-test subscription and Azure CLI credentials who runs this suite will attempt to provision preview sandbox resources without setting the advertised enable flag. Make this guard unconditional so the preview deployment remains explicitly opt-in in every environment.
if (DeploymentE2ETestHelpers.IsRunningInCI &&
!string.Equals(Environment.GetEnvironmentVariable(EnableSandboxesEnvironmentVariable), "true", StringComparison.OrdinalIgnoreCase))
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Mitch Denny (mitchdenny)
left a comment
There was a problem hiding this comment.
Reviewed the final Azure Container Apps Sandboxes implementation, including the V2 managed-identity image-pull path.
Co-authored-by: Copilot App <[email protected]> Copilot-Session: ccb1419b-3f5f-4cb3-8933-b0bb1762ed48
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/AzureSandboxContainerOptionsAnnotation.cs — The ATS projection makes the defaulted Tier and nullable Endpoints properties required because… |
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs — This converter changes every ATS DTO TimeSpan number to milliseconds, but existing TypeScript DTO… View comment |
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Avoid sending the ACR pull identity for public registry images, reject pull/workload identity reuse, and require existing pull identities for existing sandbox groups. Co-authored-by: Copilot App <[email protected]> Copilot-Session: ccb1419b-3f5f-4cb3-8933-b0bb1762ed48
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 — WithAcrPullIdentity is marked for ATS export, but the new Aspire.Hosting.Azure.Sandboxes.ats.txt… |
Pre-existing issues (2)
| Severity | Finding |
|---|---|
src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs — This converter changes every ATS DTO TimeSpan number to milliseconds, but existing TypeScript DTO… View comment |
|
src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs — The ATS projection makes the defaulted Tier and nullable Endpoints properties required because… View comment |
Files not reviewed (1)
- tests/PolyglotAppHosts/Aspire.Hosting.Azure.Sandboxes/TypeScript/package-lock.json: Generated file
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
src/Aspire.Hosting/Publishing/ContainerImageInspectionResult.cs:51
- These read-only properties retain the caller's list instances, so a caller can mutate the apparent value object after construction. Snapshot both inputs, as
ContainerImageManifestInspectionResult.Successalready does for its manifest collection, to keep inspection metadata stable.
Entrypoint = entrypoint;
Command = command;
src/Aspire.Hosting.Azure.Sandboxes/README.md:92
- This describes retention as depending only on image and endpoint policy, but
HasSecurityRelevantEndpointChange(lines 1989–1997) forces immediate pruning whenever the current or previous deployment has any runtime environment or modeled command configuration, even when those values are unchanged. Document that condition so users do not expect previous-generation endpoint continuity for the common environment-variable/command case.
To keep endpoint references usable during an ordinary redeploy of the same immutable image and endpoint policy, Aspire can retain the immediately previous sandbox generation until the next successful deployment. If the image digest, endpoint exposure, protocol, or anonymous-access configuration changes, the previous generation is pruned immediately instead so an older workload or security posture does not remain reachable. Ordinary stale-generation pruning is best-effort after the new deployment state is safely persisted. A failure to prune after a security-relevant change fails the deployment visibly while preserving the new deployment and its state for recovery.
|
The CI build failed due to test failure(s) that appear unrelated to the PR changes. These may be flaky tests. Suspected flaky test(s):
Suggested actions:
You can re-run the failed jobs from the workflow run page. |



Description
Adds an experimental
Aspire.Hosting.Azure.Sandboxesdeployment target so Aspire applications can publish container-backed compute resources to Azure Container Apps Sandboxes.This ports and narrows the implementation from #17873 by David Fowler (@davidfowl) onto current
main. It preserves the core sandbox deployment path while removing Connector Gateway, MCP, trigger, OAuth, broad workload-role APIs, and unrelated playground scenarios from the initial review surface.Users can:
The internal Azure Dev Compute adapter is pinned to the preview API and includes pagination, transient retries,
Retry-Afterhandling, polling, and error-body redaction. Container images are resolved to immutable Linux/amd64 digests before disk-image creation.User-facing usage
C# AppHost:
TypeScript AppHost:
Security considerations
This integration creates sandbox proxy endpoints, invokes Docker or Podman to inspect images, sends resolved environment values to the sandbox data-plane API, and creates a scoped Container Apps SandboxGroup Data Owner assignment for the deployment principal.
Azure Dev Compute pulls private images through its V2 disk-image API using a dedicated user-assigned managed identity. For new sandbox groups, Aspire creates and attaches that identity and grants it only
AcrPullon the configured Azure Container Registry. Existing sandbox groups require an explicitly supplied identity that is already attached to the group and hasAcrPull.Security-sensitive defaults are intentionally restrictive:
A formal threat model and security review have not yet been completed.
Validation
Aspire.HostingandAspire.Hosting.Azure.Sandboxespackage/API compatibility checks.The ADC V2 managed-identity image-pull contract was validated directly against Azure in
westus3, as documented in Mitch Denny's review notes. The complete Aspire deployment E2E was not rerun for this port because no preview-enabled deployment-test subscription was configured locally. The original implementation in #17873 documents successful live sandbox deployments; this PR retains a gated current-main E2E for preview-subscription validation.Fixes # (issue)
Checklist
///comments?[Experimental]attributes?<remarks />and<code />elements on your triple slash comments?