Aspire

Azure Front Door

Azure Front Door logo

Azure Front Door is a global, scalable entry point that uses Microsoft’s edge network to deliver fast, secure, and highly available web applications. The Aspire Azure Front Door hosting integration provisions a Front Door profile and routes traffic to your backends.

The Aspire Azure Front Door hosting integration models the resource as the following type:

  • AzureFrontDoorResource: Represents an Azure Front Door profile, including its endpoints, origin groups, origins, and routes.

To access this type and APIs, add the 📦 Aspire.Hosting.Azure.FrontDoor NuGet package to your AppHost project.

Aspire CLI — Add Aspire.Hosting.Azure.FrontDoor package
aspire add azure-frontdoor

The Aspire CLI is interactive, be sure to select the appropriate search result when prompted:

Aspire CLI — Example output prompt
Select an integration to add:
> azure-frontdoor (Aspire.Hosting.Azure.FrontDoor)
> Other results listed as selectable options...

In your AppHost, call AddAzureFrontDooraddAzureFrontDoorAddAzureFrontDoor to add a Front Door profile, then call WithOriginwithOriginWithOrigin to attach a backend resource as an origin:

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
await builder.addAzureAppServiceEnvironment("production");
const api = await builder.addDotnetProject("api", "../Api/Api.csproj");
await api.withExternalHttpEndpoints();
const frontdoor = await builder.addAzureFrontDoor("frontdoor");
await frontdoor.withOrigin(api);
// After adding all resources, run the app...
await builder.build().run();

The preceding code:

  • Adds an Azure App Service environment (a compute environment is required so Front Door can resolve the origin’s hostname).
  • Adds an api project and exposes it externally with WithExternalHttpEndpointswithExternalHttpEndpointsWithExternalHttpEndpoints. Front Door requires an origin to expose an external HTTP or HTTPS endpoint.
  • Adds a Front Door profile named frontdoor and configures the api project as an origin.

Each call to withOrigin creates a separate Front Door endpoint, origin group, origin, and route, so each backend is independently routable through its own *.azurefd.net hostname.

You can add multiple backends to the same Front Door profile. Each origin gets its own Front Door endpoint and route:

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
await builder.addAzureAppServiceEnvironment("production");
const api = await builder.addDotnetProject("api", "../Api/Api.csproj");
await api.withExternalHttpEndpoints();
const web = await builder.addDotnetProject("web", "../Web/Web.csproj");
await web.withExternalHttpEndpoints();
const frontdoor = await builder.addAzureFrontDoor("frontdoor");
await frontdoor.withOrigin(api);
await frontdoor.withOrigin(web);
await builder.build().run();

Each origin must be added at most once per Front Door resource — adding the same resource twice throws InvalidOperationException.

Front Door uses health probes to determine which origins are healthy. By default, the Aspire integration probes the origin’s external endpoint at path / over HTTPS. If you have configured an HTTP probe on the origin (for example with WithHttpProbewithHttpProbeWithHttpProbe), Front Door uses the path and protocol from the resource’s liveness probe instead.

When you publish your app, Aspire generates Bicep alongside the manifest. A Front Door resource with a single origin generates Bicep similar to the following:

Generated Bicep — frontdoor.bicep
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location
param my_api_host string
resource frontdoor 'Microsoft.Cdn/profiles@2025-06-01' = {
name: take('frontdoor-${uniqueString(resourceGroup().id)}', 260)
location: 'Global'
sku: {
name: 'Standard_AzureFrontDoor'
}
tags: {
'aspire-resource-name': 'frontdoor'
}
}
resource my_apiEndpoint 'Microsoft.Cdn/profiles/afdEndpoints@2025-06-01' = {
name: take('myapiEndpoint-${uniqueString(resourceGroup().id)}', 46)
location: 'Global'
parent: frontdoor
}
resource my_apiOriginGroup 'Microsoft.Cdn/profiles/originGroups@2025-06-01' = {
name: take('myapiOriginGroup-${uniqueString(resourceGroup().id)}', 90)
properties: {
healthProbeSettings: {
probePath: '/'
probeProtocol: 'Https'
}
loadBalancingSettings: {
sampleSize: 4
successfulSamplesRequired: 3
additionalLatencyInMilliseconds: 50
}
}
parent: frontdoor
}
resource my_apiOrigin 'Microsoft.Cdn/profiles/originGroups/origins@2025-06-01' = {
name: take('myapiOrigin-${uniqueString(resourceGroup().id, my_api_host)}', 90)
properties: {
hostName: my_api_host
originHostHeader: my_api_host
}
parent: my_apiOriginGroup
}
resource my_apiRoute 'Microsoft.Cdn/profiles/afdEndpoints/routes@2025-06-01' = {
name: take('myapiRoute-${uniqueString(resourceGroup().id)}', 90)
properties: {
forwardingProtocol: 'HttpsOnly'
httpsRedirect: 'Enabled'
linkToDefaultDomain: 'Enabled'
originGroup: {
id: my_apiOriginGroup.id
}
patternsToMatch: [
'/*'
]
}
parent: my_apiEndpoint
dependsOn: [
my_apiOrigin
]
}
output my_api_endpointUrl string = 'https://${my_apiEndpoint.properties.hostName}'
output my_api_endpointId string = my_apiEndpoint.id

Aspire passes the origin’s hostname (resolved from the compute environment, not the full URL) into the my_api_host parameter so the Front Door origin points at the deployed backend.

The generated Bicep is a starting point and is influenced by changes to the provisioning infrastructure in C#. Customizations to the Bicep file directly are overwritten, so make changes through the provisioning APIs to ensure they’re reflected in the generated files.

Each origin produces two outputs named after the origin resource (normalized to a Bicep identifier, such as my_api): {originName}_endpointUrl with the Front Door endpoint URL, and {originName}_endpointId with the endpoint’s Azure resource ID. In C#, get references to them by passing the origin’s resource name to GetEndpointUrl and GetEndpointId on the Front Door resource. Use the endpoint ID for resources that require it, such as Azure DNS alias records for an apex domain:

AppHost.cs
var frontdoor = builder.AddAzureFrontDoor("frontdoor")
.WithOrigin(api);
var endpointUrl = frontdoor.Resource.GetEndpointUrl("api");
var endpointId = frontdoor.Resource.GetEndpointId("api");

For advanced scenarios such as upgrading to the Premium SKU, attaching a Web Application Firewall (WAF) policy, configuring caching, or tuning routes, use ConfigureInfrastructure (configureInfrastructure in TypeScript) to modify the generated Bicep model directly:

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
await builder.addAzureAppServiceEnvironment("production");
const api = await builder.addDotnetProject("api", "../Api/Api.csproj");
await api.withExternalHttpEndpoints();
const frontdoor = await builder.addAzureFrontDoor("frontdoor");
await frontdoor.withOrigin(api);
await frontdoor.configureInfrastructure(async (infra) => {
// Use the AzureResourceInfrastructure API to customize Bicep
// parameters or resources directly.
await infra.addParameter("skuName", "Premium_AzureFrontDoor");
});
await builder.build().run();

Aspire selects the Premium SKU automatically when an origin uses Private Link.

For more information, see Customize Azure resources. For the full list of configurable properties, see the Azure.Provisioning.Cdn and Azure.Provisioning.FrontDoor API documentation.

By default, Front Door reaches each origin over the public internet. With Azure Private Link, Front Door connects to Azure Container Apps or Azure App Service origins through a private endpoint. Aspire also disables public network access on those apps, so they’re reachable only through Front Door.

Call WithAzureFrontDoorPrivateLink (withAzureFrontDoorPrivateLink in TypeScript) on the compute environment and pass the Front Door. Add apps with WithOrigin before or after this call. Only origins in the connected environment use Private Link, so one Front Door can serve both private and public origins. The call has no effect when you run the AppHost locally.

The following AppHost makes both apps private origins:

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const environment = await builder.addAzureContainerAppEnvironment("env");
const frontDoor = await builder.addAzureFrontDoor("frontdoor");
await environment.withAzureFrontDoorPrivateLink(frontDoor);
const api = await builder.addDotnetProject("api", "../Api/Api.csproj")
.withExternalHttpEndpoints();
const web = await builder.addDotnetProject("web", "../Web/Web.csproj")
.withExternalHttpEndpoints()
.withReference(api);
await frontDoor.withOrigin(api).withOrigin(web);
await builder.build().run();

Aspire disables public network access on the Container Apps environment. Apps in the environment still reach each other directly, because calls between apps in an environment stay inside the environment. Callers outside the environment must use the Front Door endpoint.

The following AppHost makes both websites private origins:

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const environment = await builder.addAzureAppServiceEnvironment("env");
const frontDoor = await builder.addAzureFrontDoor("frontdoor");
await environment.withAzureFrontDoorPrivateLink(frontDoor);
const api = await builder.addDotnetProject("api", "../Api/Api.csproj")
.withExternalHttpEndpoints();
const web = await builder.addDotnetProject("web", "../Web/Web.csproj")
.withExternalHttpEndpoints();
await frontDoor.withOrigin(api).withOrigin(web);
await builder.build().run();

For App Service:

  • Each website gets its own private endpoint connection.
  • Public network access is disabled on every app website in the environment, including websites that aren’t Front Door origins.
  • The Aspire dashboard is a separate website that stays public. If you don’t need it, turn it off with WithDashboard(false) (withDashboard({ enable: false }) in TypeScript).
  • Existing App Service plans are supported.

If you deploy the aspire publish output yourself, deploy the environment and website modules before the Front Door module, and pass each website’s resource ID and location to main.bicep.

Front Door Private Link can’t target a deployment slot, so with WithDeploymentSlot each origin targets the production site. The slot has public network access disabled and isn’t reachable through Front Door, so deploy to the slot and swap it into production.

With a deployment slot, Aspire doesn’t update a production site that already exists. If that site is public, disable its public network access yourself.

App Service has no internal route between apps. WithReference still resolves to each website’s host name, which isn’t publicly reachable. Callers must use the Front Door endpoint URLs or private networking and DNS that you set up. Don’t pass a Front Door output to one of its own origins, because that creates a deployment dependency cycle. Configure those URLs after deployment instead.

Front Door creates each connection request in the Pending state. No traffic reaches the apps until you approve the requests, and Aspire doesn’t approve them for you. Each request’s description is Azure Front Door <front-door> requests access to <environment>. Front Door can create more than one request, so approve each one.

Approve the requests in the Azure portal, under Networking for the Container Apps environment or for each App Service website, or with the Azure CLI:

Azure CLI
az containerapp env list --resource-group <resource-group> --query "[].name" --output tsv
az network private-endpoint-connection list --type Microsoft.App/managedEnvironments --name <environment-name> --resource-group <resource-group> --query "[?properties.privateLinkServiceConnectionState.status=='Pending'].id" --output tsv
az network private-endpoint-connection approve --id <connection-id>

Traffic starts flowing a few minutes after approval. Reach each app through its Front Door endpoint host name, which is listed on the Front Door profile’s Overview page in the Azure portal. Requests to the app’s own URL are denied.

Front Door Private Link is available only in some regions. Aspire creates the private endpoint in the region of the Container Apps environment or App Service website when that region is supported. Otherwise, it uses the supported region in the same Azure geography, such as westus2 for westus, which adds a network hop but keeps data in the same geography. If the geography has no supported region, such as Switzerland, deployment fails.

To choose the region yourself, set it on each Private Link origin with ConfigureInfrastructure (configureInfrastructure in TypeScript). The following example works for both Container Apps and App Service:

In a TypeScript AppHost, first add the experimental typed provisioning proxies for Front Door:

Aspire CLI
aspire add Aspire.Hosting.Azure.Provisioning.Cdn
apphost.mts
import { createBuilder, BicepValueKind } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const environment = await builder.addAzureContainerAppEnvironment("env");
const frontDoor = await builder.addAzureFrontDoor("frontdoor");
await frontDoor.configureInfrastructure(async (infrastructure) => {
for (const origin of await infrastructure.getFrontDoorOrigins()) {
const privateLink = await origin.sharedPrivateLinkResource.get();
const privateLinkId = await privateLink.privateLinkId.get();
// Skip origins that don't use Private Link.
if (await privateLinkId.kind() !== BicepValueKind.Unset) {
await privateLink.privateLinkLocation.set("westus2");
}
}
});
await environment.withAzureFrontDoorPrivateLink(frontDoor);
const api = await builder.addDotnetProject("api", "../Api/Api.csproj")
.withExternalHttpEndpoints();
await frontDoor.withOrigin(api);
await builder.build().run();

Changing the region of an existing deployment creates a new connection request that you must approve.

SymptomResolution
Publish fails for an existing or Express Container Apps environment.Use an environment that Aspire provisions.
Publish fails because none of the Front Door’s origins run in the connected environment.Add an app from that environment with WithOrigin, or remove the WithAzureFrontDoorPrivateLink call.
Publish fails because an origin runs in an environment that’s connected to a different Front Door.Also call WithAzureFrontDoorPrivateLink on that environment with this Front Door.
Requests through Front Door fail after deployment.Approve every pending connection request, then wait a few minutes.
With a deployment slot, an existing production site is still publicly reachable.Disable public network access on the site yourself.