Skip to content

Add Azure Container Apps Sandboxes deployment target - #19008

Merged
Mitch Denny (mitchdenny) merged 81 commits into
microsoft:mainfrom
spboyer:spboyer/aca-sandboxes
Aug 29, 2026
Merged

Mitch Denny (mitchdenny) merged 81 commits into
microsoft:mainfrom
spboyer:spboyer/aca-sandboxes

Conversation

@spboyer

@spboyer Shayne Boyer (spboyer) commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Description

Adds an experimental Aspire.Hosting.Azure.Sandboxes deployment 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:

  • Provision an Azure sandbox group and its Azure Container Registry dependency.
  • Publish project, container, and Dockerfile resources as sandbox containers.
  • Select documented sandbox resource tiers and lifecycle settings.
  • Explicitly expose anonymous HTTP endpoints.
  • Resolve deployed sandbox endpoint values from persisted deployment state.
  • Deploy, redeploy, prune stale generations, and destroy sandbox and disk-image resources.

The internal Azure Dev Compute adapter is pinned to the preview API and includes pagination, transient retries, Retry-After handling, polling, and error-body redaction. Container images are resolved to immutable Linux/amd64 digests before disk-image creation.

User-facing usage

C# AppHost:

var sandboxGroup = builder.AddAzureSandboxGroup("sandboxes");

builder.AddProject<Projects.ApiService>("api")
    .WithHttpEndpoint(name: "http", targetPort: 8080)
    .WithExternalHttpEndpoints()
    .PublishAsAzureSandbox(sandboxGroup, new AzureSandboxOptions
    {
        Tier = AzureSandboxTier.Medium,
        AutoSuspendEnabled = true,
        AutoSuspendInterval = TimeSpan.FromMinutes(15),
        AutoSuspendMode = AzureSandboxAutoSuspendMode.Disk,
        Endpoints =
        [
            new AzureSandboxEndpointOptions
            {
                Name = "http",
                Anonymous = true
            }
        ]
    });

TypeScript AppHost:

import { AzureSandboxTier, createBuilder } from './.aspire/modules/aspire.mjs';

const builder = await createBuilder();
const sandboxGroup = await builder.addAzureSandboxGroup('sandboxes');

await builder.addDockerfile('site', './site')
    .withHttpEndpoint({ name: 'http', targetPort: 80 })
    .withExternalHttpEndpoints()
    .publishAsAzureSandbox(sandboxGroup, {
        tier: AzureSandboxTier.Medium,
        endpoints: [
            {
                name: 'http',
                anonymous: true
            }
        ]
    });

await builder.build().run();

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 AcrPull on the configured Azure Container Registry. Existing sandbox groups require an explicitly supplied identity that is already attached to the group and has AcrPull.

Security-sensitive defaults are intentionally restrictive:

  • External endpoints do not allow anonymous access unless explicitly enabled.
  • Egress uses full traffic inspection with deny-by-default behavior.
  • Registry credentials and access tokens are never sent to Azure Dev Compute or persisted in deployment state.
  • The image-pull identity is separate from identities exposed to sandbox workloads.
  • Images must resolve to immutable Linux/amd64 digests.
  • Generic volume mounts and unsupported endpoint transports fail explicitly.
  • Failure cleanup uses independent bounded tokens so cancellation does not silently orphan newly created resources.

A formal threat model and security review have not yet been completed.

Validation

  • 81 sandbox unit and Azure Dev Compute contract tests, including V2 request shape, image-pull identity provisioning, existing-group requirements, and cross-resource-group ACR behavior.
  • Generated Bicep coverage for workload and infrastructure identity combinations.
  • 3 container-runtime image inspection tests.
  • TypeScript SDK restore and type-check using locally packed Aspire packages.
  • Deployment E2E project compilation with a gated deploy/redeploy/destroy scenario.
  • Aspire.Hosting and Aspire.Hosting.Azure.Sandboxes package/API compatibility checks.
  • Full Debug package build completed successfully.

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

  • 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 /// comments?
        • Yes
        • No
      • Did you add [Experimental] attributes?
        • 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

Copilot AI balanced review requested due to automatic review settings August 5, 2026 00:43
@github-actions

github-actions Bot commented Aug 5, 2026

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

Or

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

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

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 exact aspire add Aspire.Hosting.Azure.Sandboxes command in a bash block 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


@github-actions

github-actions Bot commented Aug 5, 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.

@github-actions

github-actions Bot commented Aug 5, 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.

@github-actions

github-actions Bot commented Aug 5, 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 review requested due to automatic review settings August 5, 2026 01:35

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.

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

  • AddAzureSandboxGroup always adds an AzureProvisioningResource, so ordinary run mode schedules its Bicep provisioning even though PublishAsAzureSandbox is a no-op and no local workload can use the group. This can create a sandbox group during aspire run. Keep the deployment environment out of the run model, as AddAzureContainerAppEnvironment does in AzureContainerAppExtensions.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 AzureSandboxAutoSuspendMode enum, consistent with AzureSandboxTier.
    /// <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 AzureSandboxAutoDeleteTrigger enum 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

  • Name is 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 during PublishAsAzureSandbox. 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 addAzureSandboxGroup and publishAsAzureSandbox call 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 DeleteSandboxAsync and DeleteDiskImageAsync suppress only InvalidOperationException. An exhausted network retry throws HttpRequestException, escapes despite throwOnError: false, and turns an otherwise successful deploy into failure cleanup that deletes the newly created generation. Suppress non-cancellation client failures when throwOnError is false.
                throwOnError: false).ConfigureAwait(false);
  • Files reviewed: 47/48 changed files
  • Comments generated: 2
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 5, 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.

@github-actions

github-actions Bot commented Aug 5, 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.

@github-actions

github-actions Bot commented Aug 5, 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 review requested due to automatic review settings August 5, 2026 02:26

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.

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 PublishAsAzureSandbox intentionally 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 return CreateResourceBuilder(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 addAzureSandboxGroup and publishAsAzureSandbox so TypeScript consumers can discover the supported usage pattern.
```csharp
var sandboxGroup = builder.AddAzureSandboxGroup("sandboxes");

src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultUserPrincipalProvider.cs:70

  • appid cannot distinguish applications from users: Microsoft documents that the client application can act as itself or on behalf of a user. A user token with idtyp: "user" but without upn/email is therefore classified as ServicePrincipal, causing the generated role assignment to use the wrong principal type. Preserve and honor the explicit user identity type before falling back to appid.
                    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

Copilot AI review requested due to automatic review settings August 5, 2026 03:00

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.

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 AzureSandboxEndpointPropertyValueProvider before 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, calling AddAzureSandboxGroup during 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 CleanupResourceGroupAsync fails to start az, 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_SANDBOXES and 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

  • AzureSandboxTier is a new public type in this experimental deployment surface, but the enum itself is not marked experimental. Consumers can reference AzureSandboxTier.Medium directly 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/*.cs updates 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 addAzureSandboxGroup and publishAsAzureSandbox path.
## 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

Copilot AI review requested due to automatic review settings August 5, 2026 03:33

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.

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

  • AddAzureSandboxGroup is a publish/deploy environment, but this unconditionally adds it to the application model in Run mode. Unlike PublishAsAzureSandbox, 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 in AzureContainerAppExtensions.cs:630-634 and 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

Copilot AI review requested due to automatic review settings August 5, 2026 04:25

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.

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, CreateDigestImageReference preserves 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/CreateSandboxAsync throws 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 current deployId (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 run even though PublishAsAzureSandbox deliberately 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 appid but no upn/email as app-only. appid identifies the client application in both app-only and delegated app+user tokens, so a delegated token that exposes preferred_username instead can assign principalType: ServicePrincipal to the user's oid, causing RBAC deployment to fail. Microsoft recommends idtyp (or the scp/roles token shape) to distinguish these cases; please do not use appid presence 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]>

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 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Low severity src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxContainerDeployment.cs — The PR description still says disk-image creation exchanges Azure credentials for short-lived ACR…
Medium severity 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]>
@spboyer

Copy link
Copy Markdown
Member Author

Mitch Denny (@mitchdenny) Addressed the V2/UAMI feedback in b4e57f5a0:

  • Disk-image creation now uses PUT /diskimages/v2 with source.kind, source.imageUrl, and source.managedIdentityClientId.
  • New sandbox groups get a dedicated attached UAMI with ACR-scoped AcrPull; existing groups require an explicitly supplied, preconfigured UAMI.
  • Removed the ACR refresh-token/credential path and restored all src/Aspire.Hosting.Azure/ files to the PR merge-base behavior.
  • The SandboxGroup Data Owner assignment now uses the existing principalId path and omits optional principalType; the principal-detection, ValueProviderContext, and Sandboxes friend-assembly changes are gone.
  • Added coverage for V2 request shape, supplied/existing identities, cross-resource-group ACR identity promotion, and generated Bicep. The focused sandbox suite passes 78/78.

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.

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 Medium severity · 1 Low severity

Pre-existing issues (2)
Severity Finding
Medium severity src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxesExtensions.cs — These branches make the public identity APIs report a configuration that is never emitted:… View comment
Low severity 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 Endpoints is nullable and the deployment code treats it as optional, nullable reference types are not considered by IsOptionalDtoProperty; this is therefore emitted as required in the generated TypeScript DTO. Any TypeScript caller that supplies lifecycle options is forced to add an unrelated endpoints: []. Please use an ATS-facing projection that makes this property optional.
    public AzureSandboxEndpointOptions[]? Endpoints { get; set; }

src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerOptionsAnnotation.cs:21

  • Tier has 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 requires tier whenever any options object is supplied, so callers cannot rely on the documented Medium default while configuring an unrelated setting. Please project this through an ATS-facing options shape where tier is optional (or otherwise make the generated contract preserve the default).
    public AzureSandboxTier Tier { get; set; } = AzureSandboxTier.Medium;

@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.

@spboyer

Copy link
Copy Markdown
Member Author

Mitch Denny (@mitchdenny) Follow-up is complete in df3aac432. The PR description now documents the V2/UAMI security model and validation, and the public identity APIs explicitly distinguish workload identities from the dedicated ADC image-pull identity. Generated Bicep snapshots cover the emitted identity combinations, and the focused sandbox suite passes 81/81. Both new review threads are resolved; ready for another look when convenient.

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.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
Medium severity src/​Aspire.Hosting.Azure.Sandboxes/​AzureSandboxesExtensions.cs — These branches make the public identity APIs report a configuration that is never emitted:… View resolved comment
Low severity 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

  • Name is 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))

@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.

@mitchdenny Mitch Denny (mitchdenny) left a comment

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.

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

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 · 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity 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
High severity 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

@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.

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

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 · 2 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity 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
High severity src/​Aspire.Hosting.RemoteHost/​Ats/​AtsMarshaller.cs — This converter changes every ATS DTO TimeSpan number to milliseconds, but existing TypeScript DTO… View comment
Medium severity 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.Success already 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.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ CI Failure Analysis: Possible Flaky Test(s)

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):

  • Aspire.Dashboard.Components.Tests.Pages.MetricsTests.ChangeResource_MeterAndInstrumentNotOnNewResources_InstrumentCleared in job Tests / Dashboard.Components / Dashboard.Components (windows-latest)

Suggested actions:

  • Re-run the failed CI jobs to confirm if the failure is intermittent
  • If the test continues to fail, consider quarantining it using /quarantine-test <test name> <issue URL>
  • Search existing issues to see if this test is already known to be flaky

You can re-run the failed jobs from the workflow run page.

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.

9 participants