# AzureFrontDoorExtensions Methods

- Package: [Aspire.Hosting.Azure.FrontDoor](/reference/api/csharp/aspire.hosting.azure.frontdoor.md)
- Type: [AzureFrontDoorExtensions](/reference/api/csharp/aspire.hosting.azure.frontdoor/azurefrontdoorextensions.md)
- Kind: `Methods`
- Members: `2`

Extension methods for adding Azure Front Door resources to an Aspire application.

## AddAzureFrontDoor(IDistributedApplicationBuilder, string)

- Name: `AddAzureFrontDoor(IDistributedApplicationBuilder, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureFrontDoorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Azure.FrontDoor/AzureFrontDoorExtensions.cs#L61-L159)

Adds an Azure Front Door resource to the application model.

```csharp
public static class AzureFrontDoorExtensions
{
    public static IResourceBuilder<AzureFrontDoorResource> AddAzureFrontDoor(
        this IDistributedApplicationBuilder builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The distributed application builder.
- `name` (`string`)
  The name of the resource.

## Returns

`IResourceBuilder<AzureFrontDoorResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1` for chaining.

## Remarks

Azure Front Door is a global, scalable entry point that uses the Microsoft global edge network to create fast, secure, and widely scalable web applications. Use [AzureFrontDoorExtensions.WithOrigin(IResourceBuilder<AzureFrontDoorResource>, IResourceBuilder<T>)](/reference/api/csharp/aspire.hosting.azure.frontdoor/azurefrontdoorextensions/methods.md#withorigin-iresourcebuilder-azurefrontdoorresource-iresourcebuilder-t) to add origins (backends) to the Front Door resource. Each origin gets its own Front Door endpoint, origin group, and route, so each backend app is independently routable via its own `*.azurefd.net` hostname.

For advanced scenarios (shared origin groups, path-based routing, custom routes), use `AzureProvisioningResourceExtensions.ConfigureInfrastructure` to customize the generated infrastructure directly.

Add an Azure Front Door resource with origins:

```csharp
var api = builder.AddProject<Projects.Api>("api")
    .WithExternalHttpEndpoints();
var web = builder.AddProject<Projects.Web>("web")
    .WithExternalHttpEndpoints();
var frontDoor = builder.AddAzureFrontDoor("frontdoor")
    .WithOrigin(api)
    .WithOrigin(web);
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithOrigin(IResourceBuilder<AzureFrontDoorResource>, IResourceBuilder<T>)

- Name: `WithOrigin(IResourceBuilder<AzureFrontDoorResource>, IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureFrontDoorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Azure.FrontDoor/AzureFrontDoorExtensions.cs#L187-L199)

Adds an origin (backend) to the Azure Front Door resource. Each origin gets its own Front Door endpoint with a distinct `*.azurefd.net` hostname, its own origin group, and a default route.

```csharp
public static class AzureFrontDoorExtensions
{
    public static IResourceBuilder<AzureFrontDoorResource> WithOrigin<T>(
        this IResourceBuilder<AzureFrontDoorResource> builder,
        IResourceBuilder<T> resource)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureFrontDoorResource>`)
  The Azure Front Door resource builder.
- `resource` (`IResourceBuilder<T>`)
  The resource to add as an origin (e.g., a project, container, or other compute resource with endpoints).

## Returns

`IResourceBuilder<AzureFrontDoorResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1` for chaining.

## Remarks

Add multiple origins (each gets its own Front Door endpoint):

```csharp
var frontDoor = builder.AddAzureFrontDoor("frontdoor")
    .WithOrigin(api)
    .WithOrigin(web);
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
