Azure Front Door
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.
Hosting integration
Section titled “Hosting integration”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 add azure-frontdoorThe Aspire CLI is interactive, be sure to select the appropriate search result when prompted:
Select an integration to add:
> azure-frontdoor (Aspire.Hosting.Azure.FrontDoor)> Other results listed as selectable options...#:package Aspire.Hosting.Azure.FrontDoor@*<PackageReference Include="Aspire.Hosting.Azure.FrontDoor" Version="*" />Add an Azure Front Door resource
Section titled “Add an Azure Front Door resource”In your AppHost, call AddAzureFrontDooraddAzureFrontDoorAddAzureFrontDoor to add a Front Door profile, then call WithOriginwithOriginWithOrigin to attach a backend resource as an origin:
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();var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureAppServiceEnvironment("production");
var api = builder.AddDotnetProject("api", "../Api/Api.csproj") .WithExternalHttpEndpoints();
builder.AddAzureFrontDoor("frontdoor") .WithOrigin(api);
// After adding all resources, run the app...builder.Build().Run();package main
import ( "log"
"apphost/modules/aspire")
func main() { builder, err := aspire.CreateBuilder() if err != nil { log.Fatal(aspire.FormatError(err)) }
builder.AddAzureAppServiceEnvironment("production")
api := builder.AddDotnetProject("api", "../Api/Api.csproj"). WithExternalHttpEndpoints()
frontdoor := builder.AddAzureFrontDoor("frontdoor"). WithOrigin(api)
// After adding all resources, run the app... app, err := builder.Build() if err != nil { log.Fatal(aspire.FormatError(err)) } if err := app.Run(); err != nil { log.Fatal(aspire.FormatError(err)) }}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
apiproject and exposes it externally withWithExternalHttpEndpointswithExternalHttpEndpointsWithExternalHttpEndpoints. Front Door requires an origin to expose an external HTTP or HTTPS endpoint. - Adds a Front Door profile named
frontdoorand configures theapiproject 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.
Add multiple origins
Section titled “Add multiple origins”You can add multiple backends to the same Front Door profile. Each origin gets its own Front Door endpoint and route:
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();var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureAppServiceEnvironment("production");
var api = builder.AddDotnetProject("api", "../Api/Api.csproj") .WithExternalHttpEndpoints();
var web = builder.AddDotnetProject("web", "../Web/Web.csproj") .WithExternalHttpEndpoints();
builder.AddAzureFrontDoor("frontdoor") .WithOrigin(api) .WithOrigin(web);
builder.Build().Run();package main
import ( "log"
"apphost/modules/aspire")
func main() { builder, err := aspire.CreateBuilder() if err != nil { log.Fatal(aspire.FormatError(err)) }
builder.AddAzureAppServiceEnvironment("production")
api := builder.AddDotnetProject("api", "../Api/Api.csproj"). WithExternalHttpEndpoints()
web := builder.AddDotnetProject("web", "../Web/Web.csproj"). WithExternalHttpEndpoints()
frontdoor := builder.AddAzureFrontDoor("frontdoor"). WithOrigin(api). WithOrigin(web)
app, err := builder.Build() if err != nil { log.Fatal(aspire.FormatError(err)) } if err := app.Run(); err != nil { log.Fatal(aspire.FormatError(err)) }}Each origin must be added at most once per Front Door resource — adding the same resource twice throws InvalidOperationException.
Health probes
Section titled “Health probes”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.
Provisioning-generated Bicep
Section titled “Provisioning-generated Bicep”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:
@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.idAspire 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.
Reference endpoint outputs
Section titled “Reference endpoint outputs”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:
var frontdoor = builder.AddAzureFrontDoor("frontdoor") .WithOrigin(api);
var endpointUrl = frontdoor.Resource.GetEndpointUrl("api");var endpointId = frontdoor.Resource.GetEndpointId("api");Customize provisioning infrastructure
Section titled “Customize provisioning infrastructure”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:
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();using Azure.Provisioning.Cdn;
var frontDoor = builder.AddAzureFrontDoor("frontdoor") .WithOrigin(api) .ConfigureInfrastructure(infra => { var resources = infra.GetProvisionableResources();
// Upgrade to Premium SKU (required for WAF). var profile = resources.OfType<CdnProfile>().Single(); profile.SkuName = CdnSkuName.PremiumAzureFrontDoor;
// Enable caching on the route. var route = resources.OfType<FrontDoorRoute>().Single(); route.CacheConfiguration = new FrontDoorRouteCacheConfiguration { QueryStringCachingBehavior = FrontDoorQueryStringCachingBehavior.IgnoreQueryString }; });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.
Private Link origins
Section titled “Private Link origins”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.
Requirements
Section titled “Requirements”- The AppHost references 📦 Aspire.Hosting.Azure.FrontDoor and either 📦 Aspire.Hosting.Azure.AppContainers or 📦 Aspire.Hosting.Azure.AppService. The examples also use
AddDotnetProjectfrom 📦 Aspire.Hosting.Dotnet. - Front Door uses the Premium tier, which Aspire selects automatically. For pricing, see the Front Door tier comparison.
- The Container Apps environment is one that Aspire provisions, which is the default. Existing environments and Express environments aren’t supported.
- The App Service plan uses a tier that supports private endpoints, such as Basic, Standard, or Premium. The default plan,
P0V3, qualifies.
Azure Container Apps
Section titled “Azure Container Apps”The following AppHost makes both apps private origins:
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();#pragma warning disable ASPIREAZURE003 // WithAzureFrontDoorPrivateLink is experimental.
var builder = DistributedApplication.CreateBuilder(args);
var environment = builder.AddAzureContainerAppEnvironment("env");var frontDoor = builder.AddAzureFrontDoor("frontdoor");environment.WithAzureFrontDoorPrivateLink(frontDoor);
var api = builder.AddDotnetProject("api", "../Api/Api.csproj") .WithExternalHttpEndpoints();var web = builder.AddDotnetProject("web", "../Web/Web.csproj") .WithExternalHttpEndpoints() .WithReference(api);
frontDoor.WithOrigin(api).WithOrigin(web);
builder.Build().Run();package main
import ( "log"
"apphost/modules/aspire")
func main() { builder, err := aspire.CreateBuilder() if err != nil { log.Fatal(aspire.FormatError(err)) }
environment := builder.AddAzureContainerAppEnvironment("env") frontDoor := builder.AddAzureFrontDoor("frontdoor") environment.WithAzureFrontDoorPrivateLink(frontDoor)
api := builder.AddDotnetProject("api", "../Api/Api.csproj"). WithExternalHttpEndpoints() web := builder.AddDotnetProject("web", "../Web/Web.csproj"). WithExternalHttpEndpoints(). WithReference(api)
frontDoor.WithOrigin(api).WithOrigin(web)
app, err := builder.Build() if err != nil { log.Fatal(aspire.FormatError(err)) } if err := app.Run(); err != nil { log.Fatal(aspire.FormatError(err)) }}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.
Azure App Service
Section titled “Azure App Service”The following AppHost makes both websites private origins:
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();#pragma warning disable ASPIREAZURE003 // WithAzureFrontDoorPrivateLink is experimental.
var builder = DistributedApplication.CreateBuilder(args);
var environment = builder.AddAzureAppServiceEnvironment("env");var frontDoor = builder.AddAzureFrontDoor("frontdoor");environment.WithAzureFrontDoorPrivateLink(frontDoor);
var api = builder.AddDotnetProject("api", "../Api/Api.csproj") .WithExternalHttpEndpoints();var web = builder.AddDotnetProject("web", "../Web/Web.csproj") .WithExternalHttpEndpoints();
frontDoor.WithOrigin(api).WithOrigin(web);
builder.Build().Run();package main
import ( "log"
"apphost/modules/aspire")
func main() { builder, err := aspire.CreateBuilder() if err != nil { log.Fatal(aspire.FormatError(err)) }
environment := builder.AddAzureAppServiceEnvironment("env") frontDoor := builder.AddAzureFrontDoor("frontdoor") environment.WithAzureFrontDoorPrivateLink(frontDoor)
api := builder.AddDotnetProject("api", "../Api/Api.csproj"). WithExternalHttpEndpoints() web := builder.AddDotnetProject("web", "../Web/Web.csproj"). WithExternalHttpEndpoints()
frontDoor.WithOrigin(api).WithOrigin(web)
app, err := builder.Build() if err != nil { log.Fatal(aspire.FormatError(err)) } if err := app.Run(); err != nil { log.Fatal(aspire.FormatError(err)) }}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.
Deployment slots
Section titled “Deployment slots”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.
Calls between apps
Section titled “Calls between apps”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.
Approve the connection requests
Section titled “Approve the connection requests”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:
az containerapp env list --resource-group <resource-group> --query "[].name" --output tsvaz network private-endpoint-connection list --type Microsoft.App/managedEnvironments --name <environment-name> --resource-group <resource-group> --query "[?properties.privateLinkServiceConnectionState.status=='Pending'].id" --output tsvaz network private-endpoint-connection approve --id <connection-id>az webapp list --resource-group <resource-group> --query "[].name" --output tsvaz network private-endpoint-connection list --type Microsoft.Web/sites --name <website-name> --resource-group <resource-group> --query "[?properties.privateLinkServiceConnectionState.status=='Pending'].id" --output tsvaz network private-endpoint-connection approve --id <connection-id>Repeat the last two commands for each website.
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.
Private endpoint region
Section titled “Private endpoint region”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 add Aspire.Hosting.Azure.Provisioning.Cdnimport { 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();#pragma warning disable ASPIREAZURE003 // WithAzureFrontDoorPrivateLink is experimental.
using Azure.Provisioning.Cdn;
var builder = DistributedApplication.CreateBuilder(args);
var environment = builder.AddAzureContainerAppEnvironment("env");var frontDoor = builder.AddAzureFrontDoor("frontdoor") .ConfigureInfrastructure(infrastructure => { foreach (var origin in infrastructure.GetProvisionableResources().OfType<FrontDoorOrigin>()) { // Skip origins that don't use Private Link. if (!origin.SharedPrivateLinkResource.PrivateLinkId.IsEmpty) { origin.SharedPrivateLinkResource.PrivateLinkLocation = "westus2"; } } });environment.WithAzureFrontDoorPrivateLink(frontDoor);
var api = builder.AddDotnetProject("api", "../Api/Api.csproj") .WithExternalHttpEndpoints();
frontDoor.WithOrigin(api);
builder.Build().Run();Changing the region of an existing deployment creates a new connection request that you must approve.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Resolution |
|---|---|
| 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. |
See also
Section titled “See also”- Azure Front Door documentation
- Azure Front Door tier comparison
- Secure your origin with Private Link in Azure Front Door Premium
- Access a container app using Azure Front Door with Private Link
- Connect Azure Front Door to an App Service origin using Private Link
- Configure Azure Container Apps environments
- Azure App Service integration
- ASPIREAZURE003
- Azure integration overview