Skip to content

Add Azure sandbox deployment target - #17873

Closed
David Fowler (davidfowl) wants to merge 1 commit into
mainfrom
davidfowl/sandbox-deployment-target
Closed

David Fowler (davidfowl) wants to merge 1 commit into
mainfrom
davidfowl/sandbox-deployment-target

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds a new experimental Aspire hosting package for Azure Container Apps Sandboxes so we can investigate this deployment target end to end. The deployment path is container-image based: Aspire builds and pushes compute resources, converts the pushed OCI image into a sandbox disk image, creates a sandbox from that disk image, applies lifecycle settings, exposes endpoint-derived ports, persists endpoint state, and cleans up sandbox/disk state during destroy.

Sandbox ARM resources are modeled with Azure.Provisioning/Bicep. Sandbox runtime operations use an internal ADC HTTP client for the regional Azure Dev Compute management endpoint (https://management.{region}.azuredevcompute.io) with api-version=2026-02-01-preview.

This includes:

  • Aspire.Hosting.Azure.Sandboxes package and sandbox group deployment environment resource.
  • Container and project-resource deployment to ACA Sandboxes.
  • C# and TypeScript AppHost coverage for publishing resources as ACA Sandboxes.
  • Sandbox runtime options for CPU, memory, disk, lifecycle, egress inspection, and endpoint access.
  • Endpoint state persistence so other resources can reference deployed sandbox URLs.
  • Azure Storage + managed identity/RBAC validation for sandbox-hosted apps.
  • Mixed Azure App Service + sandbox deployment validation.
  • Connector gateway ARM model support for connections, connection access policies, MCP server configs, and late-bound trigger configs.
  • Sandbox group RBAC modeled in Bicep for both the deployment principal and connector gateway system-assigned identity.

User-facing usage

C# AppHost:

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

builder.AddProject<Projects.ApiService>("api", launchProfileName: null)
    .WithHttpEndpoint(targetPort: 8080)
    .WithExternalHttpEndpoints()
    .PublishAsSandbox(sandboxGroup, new AzureSandboxOptions
    {
        Cpu = "1000m",
        Memory = "2048Mi",
        Disk = "20480Mi"
    });

TypeScript AppHost:

import { 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()
    .publishAsSandbox(sandboxGroup, {
        cpu: '1000m',
        memory: '2048Mi',
        disk: '20480Mi'
    });

await builder.build().run();

Connector trigger callback into a sandbox-hosted app:

var gateway = builder.AddAzureConnectorGateway("gateway");
gateway.WithRoleAssignments(sandboxGroup, AzureSandboxGroupBuiltInRole.SandboxGroupDataOwner);

var sharePoint = gateway.AddConnection("sharepoint", "sharepointonline");

sharePoint.AddTriggerConfig(
    "newfile",
    "GetOnNewFileItems",
    node.GetEndpoint("http"),
    callbackPath: "/webhook",
    parameters:
    [
        new("dataset", "https://contoso.sharepoint.com/sites/demo"),
        new("table", "Documents")
    ]);

Running aspire deploy builds and pushes images, provisions Azure resources, creates sandbox disk images and sandboxes through ADC APIs, exposes modeled HTTP endpoints through the sandbox proxy, and then provisions late trigger configs once sandbox callback URLs exist.

Validation

  • dotnet test --project tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-class "*.AzureSandboxesTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" (20 tests)
  • dotnet build playground/AzureSandboxes/SandboxAllFeatures.AppHost/SandboxAllFeatures.AppHost.csproj /p:SkipNativeBuild=true
  • aspire deploy --list-steps --apphost playground/AzureSandboxes/SandboxAllFeatures.AppHost/SandboxAllFeatures.AppHost.csproj --non-interactive
  • dotnet build tests/Aspire.Deployment.EndToEnd.Tests/Aspire.Deployment.EndToEnd.Tests.csproj /p:SkipNativeBuild=true --nologo
  • GITHUB_ACTIONS=true ASPIRE_DEPLOYMENT_TEST_ENABLE_SANDBOXES=false dotnet test --project tests/Aspire.Deployment.EndToEnd.Tests/Aspire.Deployment.EndToEnd.Tests.csproj --no-build --no-launch-profile -- --filter-class "*.AzureSandboxesDeploymentTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Live Azure E2E validation completed against subscription 39a289cd-f0fc-4d59-a745-17cf49d6aafd, region westus3:

  • Project-resource sandbox deploy: completed 21/21 steps; verified HTTP endpoint and /environment; destroyed and verified resource group deletion.
  • Node + Azure Storage sandbox deploy: completed 24/24 steps; verified UI, /storage, and blob create/list/read with managed identity; destroyed and verified resource group deletion.
  • Mixed App Service + sandbox deploy: completed 31/31 steps; verified App Service backend and sandbox-hosted nginx frontend proxying /api/message; destroyed and verified resource group deletion.
  • All-up deploy: completed 39/39 steps against rg-aspire-sbx-all-0604-2249; verified App Service backend, sandbox frontend, sandbox Node + Storage APIs, sandbox /webhook, connector gateway connections, MCP server config, trigger config, gateway connection access policy, sandbox group RBAC for deployment principal and gateway service principal, and Storage data-plane RBAC for the Node managed identity. Destroy completed 13/13 steps and az group exists returned false.

The guarded deployment E2E test now uses a TypeScript AppHost and is opt-in for live sandbox deployment through ASPIRE_DEPLOYMENT_TEST_ENABLE_SANDBOXES.

The SharePoint connector resources provision successfully, but the live SharePoint connections remain unauthenticated until interactive OAuth consent is completed. Actual SharePoint event firing was not exercised in the automated E2E validation.

Security considerations

This change creates public sandbox proxy endpoints for external endpoints, obtains ACR refresh tokens for private image disk conversion, invokes the local container runtime for image build/push/inspect, sends resolved environment values to the sandbox data-plane API, and grants Azure RBAC roles for sandbox deployment/runtime operations. No threat model or security review has been completed yet; this PR is draft.

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

@github-actions

github-actions Bot commented Jun 3, 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 -- 17873

Or

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

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

❓ CLI E2E Tests unknown — 110 passed, 0 failed, 3 unknown (commit 1c44bdf)

View all recordings
- Test Detail
✅ AddPackageInteractiveWhileAppHostRunningDetached Recording · Job · CLI logs
✅ AddPackageWhileAppHostRunningDetached Recording · Job · CLI logs
✅ AgentCommands_AllHelpOutputs_AreCorrect Recording · Job · CLI logs
✅ AgentInitCommand_DefaultSelection_InstallsDefaultSkills Recording · Job · CLI logs
✅ AgentInitCommand_MigratesDeprecatedConfig Recording · Job · CLI logs
✅ AgentInit_NonInteractive_BundleOnlySkillsNotInCatalog Recording · Job · CLI logs
✅ AgentMcpListStructuredLogsReturnsLogsFromStarterApp Recording · Job · CLI logs
✅ AgentMcpListStructuredLogsReturnsLogsFromStarterApp_DevLocalhost Recording · Job · CLI logs
✅ AgentMcpListStructuredLogsReturnsLogsFromStarterApp_Isolated Recording · Job · CLI logs
✅ AllPublishMethodsBuildDockerImages Recording · Job · CLI logs
✅ AspireAddAndStartWorkAgainstLegacyAppHostTs Recording · Job · CLI logs
✅ AspireAddPackageVersionToDirectoryPackagesProps Recording · Job · CLI logs
✅ AspireInitSingleFileAppHostRunsViaDotnetRunAppHost Recording · Job · CLI logs
✅ AspireInit_ExistingAppHostDir_RecreatesNuGetConfigKeepsFiles Recording · Job · CLI logs
❔ AspireInit_SolutionFile_BuildsAgainstChannelHive Recording · Job · CLI logs
✅ AspireStartUpdatesStaleTypeScriptAppHostPath Recording · Job · CLI logs
✅ AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps Recording · Job · CLI logs
✅ AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent Recording · Job · CLI logs
✅ Banner_DisplayedOnFirstRun Recording · Job · CLI logs
✅ Banner_DisplayedWithExplicitFlag Recording · Job · CLI logs
✅ Banner_NotDisplayedWithNoLogoFlag Recording · Job · CLI logs
✅ CertificatesClean_RemovesCertificates Recording · Job · CLI logs
✅ CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate Recording · Job · CLI logs
✅ CertificatesTrust_WithUntrustedCert_TrustsCertificate Recording · Job · CLI logs
✅ ConfigSetGet_CreatesNestedJsonFormat Recording · Job · CLI logs
✅ CreateAndRunAspireStarterProject Recording · Job · CLI logs
✅ CreateAndRunAspireStarterProjectWithBundle Recording · Job · CLI logs
✅ CreateAndRunEmptyAppHostProject Recording · Job · CLI logs
✅ CreateAndRunJavaEmptyAppHostProject Recording · Job · CLI logs
✅ CreateAndRunJsReactProject Recording · Job · CLI logs
✅ CreateAndRunPolyglotAppHostWithDevLocalhostUrls Recording · Job · CLI logs
✅ CreateAndRunPythonReactProject Recording · Job · CLI logs
✅ CreateAndRunTypeScriptEmptyAppHostProject Recording · Job · CLI logs
✅ CreateAndRunTypeScriptStarterProject Recording · Job · CLI logs
✅ CreateJavaAppHostWithViteApp Recording · Job · CLI logs
✅ CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain Recording · Job · CLI logs
✅ DashboardRunWithAgentMcpListTracesReturnsNoTraces Recording · Job · CLI logs
✅ DashboardRunWithAgentMcpListTracesReturnsNoTraces_DevLocalhost Recording · Job · CLI logs
✅ DashboardRunWithOtelTracesReturnsNoTraces Recording · Job · CLI logs
✅ DashboardRunWithOtelTracesReturnsNoTraces_DevLocalhost Recording · Job · CLI logs
✅ DeployK8sBasicApiService Recording · Job · CLI logs
✅ DeployK8sWithExternalHelmChart Recording · Job · CLI logs
✅ DeployK8sWithGarnet Recording · Job · CLI logs
✅ DeployK8sWithMongoDB Recording · Job · CLI logs
✅ DeployK8sWithMySql Recording · Job · CLI logs
✅ DeployK8sWithPostgres Recording · Job · CLI logs
✅ DeployK8sWithRabbitMQ Recording · Job · CLI logs
✅ DeployK8sWithRedis Recording · Job · CLI logs
✅ DeployK8sWithSqlServer Recording · Job · CLI logs
✅ DeployK8sWithValkey Recording · Job · CLI logs
✅ DeployTypeScriptAppToKubernetes Recording · Job · CLI logs
✅ DescribeCommandResolvesReplicaNames Recording · Job · CLI logs
✅ DescribeCommandShowsRunningResources Recording · Job · CLI logs
✅ DetachFormatJsonProducesValidJson Recording · Job · CLI logs
✅ DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance Recording · Job · CLI logs
✅ DoPublishAndDeployListStepsWork Recording · Job · CLI logs
✅ DocsCommand_RendersInteractiveMarkdownFromLocalSource Recording · Job · CLI logs
✅ DoctorCommand_DetectsDeprecatedAgentConfig Recording · Job · CLI logs
✅ DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain Recording · Job · CLI logs
✅ DoctorCommand_WithSslCertDir_ShowsTrusted Recording · Job · CLI logs
✅ DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted Recording · Job · CLI logs
✅ DotNetRunFileBasedAppHostUsesAspireCliBundle Recording · Job · CLI logs
✅ DotNetRunProjectAppHostUsesAspireCliBundle Recording · Job · CLI logs
✅ GatewayWithoutExternalEndpoint_FailsPublishWithGuidance Recording · Job · CLI logs
✅ GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain Recording · Job · CLI logs
✅ GlobalMigration_HandlesCommentsAndTrailingCommas Recording · Job · CLI logs
✅ GlobalMigration_HandlesMalformedLegacyJson Recording · Job · CLI logs
✅ GlobalMigration_PreservesAllValueTypes Recording · Job · CLI logs
✅ GlobalMigration_SkipsWhenNewConfigExists Recording · Job · CLI logs
✅ GlobalSettings_MigratedFromLegacyFormat Recording · Job · CLI logs
✅ IngressWithoutExternalEndpoint_FailsPublishWithGuidance Recording · Job · CLI logs
✅ InitTypeScriptAppHost_AugmentsExistingViteRepoInWorkspaceSubdirectory Recording · Job · CLI logs
✅ InteractiveCSharpInitCreatesExpectedFiles Recording · Job · CLI logs
✅ InvalidAppHostPathWithComments_IsHealedOnRun Recording · Job · CLI logs
✅ JavaScriptHostingApisRunFromTypeScriptAppHost Recording · Job · CLI logs
✅ LatestCliCanStartStableChannelAppHost Recording · Job · CLI logs
✅ LatestCliCanStartStableChannelTypeScriptAppHost Recording · Job · CLI logs
✅ LegacySettingsMigration_AdjustsRelativeAppHostPath Recording · Job · CLI logs
✅ LogsCommandShowsResourceLogs Recording · Job · CLI logs
✅ OtelLogsReturnsStructuredLogsFromStarterApp Recording · Job · CLI logs
✅ OtelLogsReturnsStructuredLogsFromStarterAppIsolated Recording · Job · CLI logs
✅ PersistentContainersPreserveDataAcrossAppHostRuns Recording · Job · CLI logs
✅ PsCommandListsRunningAppHost Recording · Job · CLI logs
✅ PsFormatJsonOutputsOnlyJsonToStdout Recording · Job · CLI logs
✅ PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts Recording · Job · CLI logs
✅ PublishWithConfigureEnvFileUpdatesEnvOutput Recording · Job · CLI logs
✅ PublishWithDockerComposeServiceCallbackSucceeds Recording · Job · CLI logs
✅ PublishWithoutOutputPathUsesAppHostDirectoryDefault Recording · Job · CLI logs
✅ ResourceCommand_FailedExec_ShowsLogPathAndLogHasEntries Recording · Job · CLI logs
✅ ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput Recording · Job · CLI logs
✅ RestoreGeneratesSdkFiles Recording · Job · CLI logs
✅ RestoreGeneratesSdkFiles_WithConfiguredToolchain Recording · Job · CLI logs
✅ RestoreRefreshesGeneratedSdkAfterAddingIntegration Recording · Job · CLI logs
✅ RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes Recording · Job · CLI logs
✅ RunFromParentDirectory_UsesExistingConfigNearAppHost Recording · Job · CLI logs
✅ RunReportsSyntaxErrorsForDotNetAppHost Recording · Job · CLI logs
✅ RunReportsSyntaxErrorsForTypeScriptAppHost Recording · Job · CLI logs
✅ SecretCrudOnDotNetAppHost Recording · Job · CLI logs
✅ SecretCrudOnTypeScriptAppHost Recording · Job · CLI logs
✅ StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels Recording · Job · CLI logs
✅ StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets Recording · Job · CLI logs
✅ StartReportsSyntaxErrorsForDotNetAppHost Recording · Job · CLI logs
✅ StartReportsSyntaxErrorsForTypeScriptAppHost Recording · Job · CLI logs
✅ StopAllAppHostsFromAppHostDirectory Recording · Job · CLI logs
✅ StopJavaPolyglotAppHostUsingApphostDirectory Recording · Job · CLI logs
✅ StopNonInteractiveSingleAppHost Recording · Job · CLI logs
✅ StopTypeScriptPolyglotAppHostUsingApphostDirectory Recording · Job · CLI logs
✅ StopWithNoRunningAppHostExitsSuccessfully Recording · Job · CLI logs
✅ TypeScriptAppHostRunDoesNotDeadlockWhenLazyOptionsInvokeAsyncCallback Recording · Job · CLI logs
✅ TypeScriptAppHostWithVite_AllowsDifferentGuestPkgManager Recording · Job · CLI logs
✅ UnAwaitedChainsCompileWithAutoResolvePromises Recording · Job · CLI logs
❔ UpdateToStable_CSharpEmptyAppHost_KeepsConfigChannel Recording · Job · CLI logs
❔ UpdateToStable_TypeScript_PreviewsStablePkgsAndKeepsChannel Recording · Job · CLI logs

📹 Recordings uploaded automatically from CI run #26998344395

@davidfowl
David Fowler (davidfowl) force-pushed the davidfowl/sandbox-deployment-target branch from f6a4720 to 9f7b6cf Compare June 17, 2026 06:42
Copilot AI review requested due to automatic review settings June 17, 2026 06:42

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

This PR introduces a new experimental Aspire.Hosting.Azure.Sandboxes hosting package that enables deploying Aspire compute resources (projects, containers, Dockerfiles) to Azure Container Apps Sandboxes. The deployment flow builds and pushes container images, converts them into sandbox disk images via the Azure Dev Compute (ADC) management API, provisions sandbox ARM resources with Bicep, exposes HTTP endpoints through the sandbox proxy, and persists endpoint state. The PR also models Azure Connector Gateway resources (connections, access policies, MCP server configs, trigger configs) for SharePoint-style webhook integration.

Changes:

  • Adds ~34 new C# files in src/Aspire.Hosting.Azure.Sandboxes/ covering resource types, deployment logic, provisioning models, ADC HTTP client, extension methods, and TypeScript API surface.
  • Extends core hosting infrastructure: ContainerRuntimeBase gains IProcessRunner injection and new InspectImageConfigAsync/InspectImageManifestAsync methods; DefaultUserPrincipalProvider adds app-token (service principal) detection; BicepProvisioner propagates UserPrincipalId and PrincipalType parameters; AcrLoginService exposes registry refresh tokens for disk image creation.
  • Adds comprehensive unit tests (20 in AzureSandboxesTests) and a guarded E2E deployment test using Hex1b terminal automation against a TypeScript AppHost.
Show a summary per file
File Description
src/Aspire.Hosting.Azure.Sandboxes/ (34 files) New package: resource types, deployment steps, ADC client, Bicep provisioning models, extension methods, options, and value providers
src/Aspire.Hosting/Publishing/ContainerRuntimeBase.cs Injects IProcessRunner, adds ExecuteContainerCommandForOutputAsync, InspectImageConfigAsync, InspectImageManifestAsync
src/Aspire.Hosting/Publishing/IContainerRuntime.cs Adds InspectImageConfigAsync and InspectImageManifestAsync to the interface
src/Aspire.Hosting/Publishing/DockerContainerRuntime.cs Updated constructor to accept IProcessRunner
src/Aspire.Hosting/Publishing/PodmanContainerRuntime.cs Updated constructor to accept IProcessRunner
src/Aspire.Hosting.Azure/Provisioning/ProvisioningContext.cs UserPrincipal extended with RoleManagementPrincipalType
src/Aspire.Hosting.Azure/Provisioning/Internal/DefaultUserPrincipalProvider.cs Detects app-only tokens via idtyp/appid JWT claims
src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs Populates UserPrincipalId and PrincipalType well-known parameters
src/Aspire.Hosting.Azure/Provisioning/BicepUtilities.cs Threads ValueProviderContext to IValueProvider.GetValueAsync
src/Aspire.Hosting.Azure/AcrLoginService.cs Extracts retry logic, adds GetRefreshTokenAsync
src/Aspire.Hosting.Azure/IAcrLoginService.cs Adds GetRefreshTokenAsync and AcrRefreshToken record
src/Aspire.Hosting.Azure.Sandboxes/README.md New hosting README (has guideline violations)
tests/Aspire.Hosting.Azure.Tests/AzureSandboxesTests.cs 20 unit tests for sandbox resources, ADC client, provisioning
tests/Aspire.Hosting.Tests/Publishing/FakeContainerRuntime.cs Implements new InspectImage* methods
tests/Aspire.Hosting.Tests/Publishing/ContainerRuntimeBaseTests.cs Tests ExecuteContainerCommandForOutputAsync
tests/Aspire.Deployment.EndToEnd.Tests/AzureSandboxesDeploymentTests.cs Guarded E2E deployment test using TypeScript AppHost
tests/Aspire.Hosting.Azure.Tests/Snapshots/ (10+ files) Verified Bicep and JSON snapshot files
playground/AzureSandboxes/ Playground apps for manual validation
.github/workflows/deployment-tests.yml CI config for sandbox deployment tests

Copilot's findings

Files not reviewed (4)
  • playground/AzureSandboxes/NodeStorageApp/package-lock.json: Generated file
  • playground/AzureSandboxes/SandboxAppServiceMixed.Frontend/package-lock.json: Generated file
  • playground/TypeScriptApps/SandboxStaticSite/package-lock.json: Generated file
  • playground/TypeScriptApps/SandboxStaticSite/site/package-lock.json: Generated file
  • Files reviewed: 112/117 changed files
  • Comments generated: 2

Comment on lines +1 to +49
# Aspire.Hosting.Azure.Sandboxes library

Provides extension methods and resource definitions for an Aspire AppHost to configure Azure Container Apps sandboxes and connector gateway resources.

## Getting started

### Prerequisites

* An Azure subscription with access to the Azure Container Apps sandbox and connector gateway preview features.
* Azure permissions to create resource groups, sandbox groups, connector gateways, role assignments, and any referenced Azure resources.

### 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
```

## 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
var sandboxGroup = builder.AddAzureSandboxGroup("sandboxes");

builder.AddProject<Projects.ApiService>("api")
.WithExternalHttpEndpoints()
.PublishAsSandbox(sandboxGroup);
```

## Connector trigger limitations

Connector gateway, connection, MCP server config, access policy, and trigger config resources can be modeled and provisioned by the AppHost. The current implementation does not run an interactive OAuth consent flow for connector connections. For connectors that require user consent, such as SharePoint, complete the connection authorization outside Aspire before relying on authenticated connector trigger delivery.

## Configure Azure Provisioning for local development

Adding Azure resources to the Aspire application model will automatically enable development-time provisioning for Azure resources so that you don't need to configure them manually. Provisioning requires a number of settings to be available via .NET configuration. The Aspire dashboard will prompt you to set these values if they are not already configured. See [Local Azure Provisioning](https://aspire.dev/integrations/cloud/azure/local-provisioning/) for more details.

> NOTE: Developers must have Owner access to the target subscription so that role assignments can be configured for the provisioned resources.

## Additional documentation

* https://learn.microsoft.com/azure/container-apps/sessions-code-interpreter
* https://learn.microsoft.com/azure/connectors/connectors-create-api-sharepointonline

## Feedback & contributing

https://github.com/microsoft/aspire
Comment on lines +98 to +118
public virtual Task<string> InspectImageConfigAsync(string imageName, CancellationToken cancellationToken)
{
ArgumentException.ThrowIfNullOrWhiteSpace(imageName);

return ExecuteContainerCommandForOutputAsync(
$"image inspect \"{imageName}\" --format \"{{{{json .Config}}}}\"",
"inspect image config",
imageName,
cancellationToken);
}

public virtual Task<string> InspectImageManifestAsync(string imageName, CancellationToken cancellationToken)
{
ArgumentException.ThrowIfNullOrWhiteSpace(imageName);

return ExecuteContainerCommandForOutputAsync(
$"manifest inspect \"{imageName}\"",
"inspect image manifest",
imageName,
cancellationToken);
}
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@davidfowl

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #19008, which ports the Azure Container Apps Sandboxes deployment target onto current main with a narrower review surface. The replacement preserves the core sandbox deployment path while removing Connector Gateway, MCP, triggers, OAuth, broad workload-role APIs, and unrelated playground scenarios from the initial scope.

@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.6 milestone Aug 23, 2026
Eric Erhardt (eerhardt) added a commit that referenced this pull request Sep 3, 2026
## Description

Adds the `Aspire.Hosting.Azure.ConnectorNamespace` integration for Azure Connector Namespace resources (ARM resource type `Microsoft.Web/connectorGateways`).

This is a hardened port of the Connector Namespace portion of #17873, adapted to the current Azure provisioning pipeline, existing-resource APIs, workload references, and ATS exports.

### Included

- `Microsoft.Web/connectorGateways@2026-05-01-preview` provisioning
- connector connections and Microsoft Entra connection access policies
- user-assigned identity access policies without hard-coded principal IDs
- workload `WithReference` configuration for the Azure Connector SDK
- managed MCP server configurations, connector routes, explicit operation allow-lists, and caller access policies
- existing Connector Namespace, connection, and MCP configuration references
- TypeScript validation, README guidance, Bicep snapshots, and an opt-in live Azure deployment test

Generated C# and ATS compatibility baselines are intentionally not updated in this feature PR; those release baselines are generated separately by the repository's release process.

### Deferred

Connector triggers and event subscriptions are intentionally deferred. Incremental ARM deployments do not remove omitted or renamed `triggerConfigs` children, so safe support requires explicit lifecycle reconciliation and persistent deployed-trigger state rather than best-effort child deployments. #19809 tracks that follow-up.

### C# example

```csharp
var connectorNamespace = builder.AddAzureConnectorNamespace("connectors");
var outlook = connectorNamespace.AddConnection(
    "outlook",
    "office365",
    new AzureConnectorNamespaceConnectionOptions
    {
        ConnectionName = "office365-outlook",
        DisplayName = "Office 365 Outlook"
    });

builder.AddProject<Projects.Worker>("worker")
    .WithReference(outlook);

connectorNamespace.AddMcpServerConfig("outlook-mcp")
    .WithConnector(
        "office365",
        outlook,
        new AzureConnectorNamespaceMcpConnectorOptions
        {
            Operations =
            [
                new AzureConnectorNamespaceMcpOperationOptions { Name = "GetEmailsV3" }
            ]
        })
    .WithAccessPolicy(
        "developer-access",
        new AzureConnectorNamespaceMcpAccessPolicyOptions
        {
            ObjectId = "11111111-1111-1111-1111-111111111111",
            TenantId = "22222222-2222-2222-2222-222222222222",
            PrincipalType = AzureConnectorNamespaceMcpAccessPolicyPrincipalType.User
        });
```

### TypeScript example

```typescript
const connectorNamespace = await builder.addAzureConnectorNamespace("connectors");
const outlook = await connectorNamespace.addConnection("outlook", "office365", {
    connectionName: "office365-outlook",
    displayName: "Office 365 Outlook"
});

const worker = await builder.addContainer(
    "worker",
    "mcr.microsoft.com/dotnet/runtime-deps:10.0"
);
await worker.withReference(outlook);

const outlookMcp = await connectorNamespace.addMcpServerConfig("outlook-mcp");
await outlookMcp.withConnector("office365", outlook, {
    operations: [{ name: "GetEmailsV3" }]
});
await outlookMcp.withAccessPolicy("developer-access", {
    objectId: "11111111-1111-1111-1111-111111111111",
    tenantId: "22222222-2222-2222-2222-222222222222",
    principalType: AzureConnectorNamespaceMcpAccessPolicyPrincipalType.User
});
```

### Security considerations

- Aspire provisions connection resources but does not automate or store OAuth consent. Interactive authorization remains a user action in `connectors.azure.com`.
- MCP routes require an explicit operation allow-list; broad connector tool exposure is rejected.
- Connection and MCP access policies authorize only explicitly configured Microsoft Entra principals.
- Secret-valued connection parameter sets are intentionally unsupported; use an existing externally authorized connection instead.

### Validation

- 33 `AzureConnectorNamespaceTests` pass with quarantined and outerloop tests excluded
- `Aspire.Deployment.EndToEnd.Tests` builds with the guarded Connector Namespace deployment scenario
- Connector Namespace package creation succeeds
- TypeScript SDK generation and `tsc --noEmit` are covered by the polyglot validation fixture
- generated Bicep compiles and matches the verified snapshot
- `git diff --check` passes

Related: #19008, #19809
Original implementation source and credit: #17873 by @davidfowl

* feat: add Azure Container Apps Sandboxes target

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* fix: address Azure Sandboxes review feedback

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* fix: scope Azure sandbox cleanup ownership

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* test: make container output assertion portable

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* test: avoid cmd echo trailing whitespace

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* fix: configure sandbox build options on target creation

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Address Azure Sandboxes review feedback

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Harden Azure Sandboxes APIs and retries

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Secure sandbox diagnostics and image inspection

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Strengthen image argument boundary tests

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Address Azure Sandboxes deployment review

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Address sandbox scope and cleanup review

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Fix sandbox group resource naming

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* fix(ats): support TimeSpan values in DTOs

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* docs(sandboxes): cite data owner role

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Fix polyglot sandbox ownership isolation

Use source AppHost file identity for deployment-state isolation while migrating legacy state paths, and derive sandbox ownership from the canonical AppHost identity. Keep publish-only sandbox resources out of run mode and document the TypeScript API.

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Emit required sandbox group properties

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Fix deployment state migration path resolution

Co-authored-by: Copilot <[email protected]>
Copilot-Session: a759f61f-23ce-4579-935b-c0e48290edae

* Address Azure sandbox review feedback

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

Copilot-Session: a759f61f-23ce-4579-935b-c0e48290edae

* Add Azure Connector Gateway integration

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Address Connector Gateway review feedback

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* chore: record stacked prerequisite update

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

Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542

* Update Connector Gateway tests for rebased sandbox APIs

Co-authored-by: Copilot <[email protected]>
Copilot-Session: a759f61f-23ce-4579-935b-c0e48290edae

* Fix sandbox state and principal migration

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

* Address Azure sandbox follow-up review

Make publish helpers inert during run mode, prune previous generations when immutable images change, and reconcile create response-loss by deployment labels.\n\nCo-authored-by: Copilot <[email protected]>

* Isolate source AppHost deployment state

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

* Harden Azure sandbox deployment lifecycle

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

* Add typed container image inspection results

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

* Harden deployment state loading and replacement

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

* Clarify deployment state clearing messages

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

* Handle ADC role assignment propagation

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

* Preserve scalar state migration semantics

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

* Fix claimed parent migration authority

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

* Reject reserved connector policy collisions

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

* Preserve authoritative migrated section state

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

* Harden sandbox security replacement cleanup

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

* Classify role-less app-only Azure tokens

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

* Fix deployment state migration edge cases

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

* Preserve deployment state manager compatibility

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

* Address sandbox runtime review feedback

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

* Handle optional Azure user name claims

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

* Address Connector Gateway review feedback

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

* Prune retained sandboxes with runtime configuration

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

* Update Connector Gateway fingerprint tests

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

* Isolate deployment state identity from AppHost path

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

* Use deployment identity for sandbox ownership

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

* Canonicalize deployment paths by filesystem semantics

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

* Merge concurrent nested state additions

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

* Allow composite connection endpoints through sandbox egress

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

* Harden deployment state locking and clearing

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

* Prune retained sandboxes for modeled commands

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

* Use existing sandbox scope for cleanup

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

* Harden deployment state fallback merging

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

* Clarify existing sandbox identity support

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

* Harden deployment state load against edge cases from review

LoadDeploymentState now computes state paths inside the try/catch so an
environment name containing characters outside [a-zA-Z0-9_-] degrades to
skipping the best-effort load instead of throwing ArgumentException from
builder construction in publish mode.

FileDeploymentStateManager only locks and reads legacy state when the
legacy file exists. This avoids manufacturing a phantom legacy directory
and lock file for identities that never had legacy state (e.g. brand-new
source AppHosts on a clean machine) and avoids re-coupling sibling
AppHosts that share the legacy identity on that shared lock.

Adds regression tests that fail without each fix.

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

* Disable SelfUpdateChannelPersistenceTests pending fix

The test fails in PR CI and is tracked by #19708, which has a separate
fix in progress. Mark it [ActiveIssue] so it does not block unrelated PRs.

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

* Harden authoritative state recovery

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

* Revert SelfUpdateChannelPersistenceTests disable in favor of #19733

PR #19733 quarantines this test with [QuarantinedTest] linked to #19708,
which preserves quarantine-workflow coverage until the root cause is fixed
in #19731. Our earlier [ActiveIssue] change skipped the test everywhere
(including the quarantine workflow) and touched the same method, causing a
merge conflict. Remove it so #19733 owns disabling this test and this
branch leaves the file unchanged from base.

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

* Fix response-loss cleanup cancellation assertion

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

* Address sandbox analyzer and endpoint feedback

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

* Address sandbox deployment review feedback

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

* Harden sandbox create reconciliation and egress

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

* Address sandbox cleanup and digest feedback

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

* Use managed identity for sandbox image pulls

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

* Decouple connector triggers from Azure internals

Reuse the standard Bicep provisioning pipeline after sandbox deployment instead of depending on internal Azure hosting APIs.

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

* Stabilize response-loss visibility test

Allow enough reconciliation time for Windows timer granularity while retaining the one-millisecond poll interval.

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

* Clarify sandbox workload identities

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

* Address Connector Gateway review feedback

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

* Avoid Connector Gateway grants in run mode

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

* Exclude Connector Gateway children from manifests

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

* Require secured Connector Gateway trigger construction

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

* Validate Connector Gateway policy identifiers

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

* Exercise Sandbox ACR pull identity export

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

* Refine Connector Namespace API scope

Rename the public integration surface to Connector Namespace and defer trigger provisioning until lifecycle reconciliation can safely remove stale child resources.

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

* Reject unsupported connector namespace configurations

Prevent Bicep identifier collisions across Connector Namespace child resources and reject multiple connectors on a preview MCP server configuration.

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

Copilot-Session: 3accecbc-b198-435e-8e5d-16f3c09d7d5f

* Fix Connector Namespace Bicep identifier collisions

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

* Address Connector Namespace review feedback

Handle existing namespace identity and location semantics, remove unnecessary experimental diagnostics, and use readable collision-resistant policy identifiers.

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

Copilot-Session: 3accecbc-b198-435e-8e5d-16f3c09d7d5f

* Split Connector Namespace into dedicated package

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

Copilot-Session: 3accecbc-b198-435e-8e5d-16f3c09d7d5f

* Avoid enabling targeted role assignments

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

Copilot-Session: 3accecbc-b198-435e-8e5d-16f3c09d7d5f

* Remove duplicate Azure provisioning registration

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

Copilot-Session: 3accecbc-b198-435e-8e5d-16f3c09d7d5f

* Avoid Connector Namespace Bicep symbol collisions

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

Copilot-Session: 3accecbc-b198-435e-8e5d-16f3c09d7d5f

* Fix Connector Namespace resource name collisions

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

* Address Connector Namespace API feedback

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

* Add managed MCP access policies

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

* Validate Connector Namespace principal IDs

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

* Mark Connector Namespace APIs experimental

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

* Add Connector Namespace deployment coverage

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

* Add Connector Namespace workload references

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

* Enable Aspire Integration Analyzers in project file

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Clarify Connector Namespace workload authorization

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

* Minor PR feedback

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Mitch Denny <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Eric Erhardt <[email protected]>
Copilot-Session: 2fbe254b-3480-468c-99fa-428b6d207542
Copilot-Session: a759f61f-23ce-4579-935b-c0e48290edae
Copilot-Session: ccb1419b-3f5f-4cb3-8933-b0bb1762ed48
Copilot-Session: 3accecbc-b198-435e-8e5d-16f3c09d7d5f
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants