# AzureAppServiceEnvironmentExtensions Methods

- Package: [Aspire.Hosting.Azure.AppService](/reference/api/csharp/aspire.hosting.azure.appservice.md)
- Type: [AzureAppServiceEnvironmentExtensions](/reference/api/csharp/aspire.hosting.azure.appservice/azureappserviceenvironmentextensions.md)
- Kind: `Methods`
- Members: `9`

Extensions for adding Azure App Service Environment resources to a distributed application builder.

## AddAzureAppServiceEnvironment(IDistributedApplicationBuilder, string)

- Name: `AddAzureAppServiceEnvironment(IDistributedApplicationBuilder, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs#L82-L262)

Adds a azure app service environment resource to the distributed application builder.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> AddAzureAppServiceEnvironment(
        this IDistributedApplicationBuilder builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

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

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- `ApplicationModel.IResourceBuilder`1`

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>)

- Name: `WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs#L312-L314)

Configures whether Azure Application Insights should be enabled for the Azure App Service.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithAzureApplicationInsights(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The AzureAppServiceEnvironmentResource to configure.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- `ApplicationModel.IResourceBuilder`1`

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>, string)

- Name: `WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs)

Configures whether Azure Application Insights should be enabled for the Azure App Service.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithAzureApplicationInsights(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder,
        string applicationInsightsLocation)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The AzureAppServiceEnvironmentResource to configure.
- `applicationInsightsLocation` (`string`)
  The location for Application Insights.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- `ApplicationModel.IResourceBuilder`1`

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>, IResourceBuilder<ParameterResource>)

- Name: `WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs)

Configures whether Azure Application Insights should be enabled for the Azure App Service.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithAzureApplicationInsights(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder,
        IResourceBuilder<ParameterResource> applicationInsightsLocation)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The AzureAppServiceEnvironmentResource to configure.
- `applicationInsightsLocation` (`IResourceBuilder<ParameterResource>`)
  The location parameter for Application Insights.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- `ApplicationModel.IResourceBuilder`1`

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>, IResourceBuilder<AzureApplicationInsightsResource>)

- Name: `WithAzureApplicationInsights(IResourceBuilder<AzureAppServiceEnvironmentResource>, IResourceBuilder<AzureApplicationInsightsResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs#L373-L375)

Configures whether Azure Application Insights should be enabled for the Azure App Service.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithAzureApplicationInsights(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder,
        IResourceBuilder<AzureApplicationInsightsResource> applicationInsightsBuilder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The AzureAppServiceEnvironmentResource builder to configure.
- `applicationInsightsBuilder` (`IResourceBuilder<AzureApplicationInsightsResource>`)
  The Application Insights resource builder.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- `ApplicationModel.IResourceBuilder`1`

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithDashboard(IResourceBuilder<AzureAppServiceEnvironmentResource>, bool)

- Name: `WithDashboard(IResourceBuilder<AzureAppServiceEnvironmentResource>, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs#L300-L301)

Configures whether the Aspire dashboard should be included in the Azure App Service environment.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithDashboard(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder,
        bool enable = true)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The `ApplicationModel.IResourceBuilder`1` to configure.
- `enable` (`bool`) `optional`
  Whether to include the Aspire dashboard. Default is true.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1` for chaining additional configuration.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDeploymentSlot(IResourceBuilder<AzureAppServiceEnvironmentResource>, IResourceBuilder<ParameterResource>)

- Name: `WithDeploymentSlot(IResourceBuilder<AzureAppServiceEnvironmentResource>, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs)

Configures the slot to which the Azure App Services should be deployed.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithDeploymentSlot(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder,
        IResourceBuilder<ParameterResource> deploymentSlot)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The AzureAppServiceEnvironmentResource to configure.
- `deploymentSlot` (`IResourceBuilder<ParameterResource>`)
  The deployment slot parameter for all App Services in the App Service Environment.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- `ApplicationModel.IResourceBuilder`1`

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithDeploymentSlot(IResourceBuilder<AzureAppServiceEnvironmentResource>, string)

- Name: `WithDeploymentSlot(IResourceBuilder<AzureAppServiceEnvironmentResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs)

Configures the slot to which the Azure App Services should be deployed.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithDeploymentSlot(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder,
        string deploymentSlot)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The AzureAppServiceEnvironmentResource to configure.
- `deploymentSlot` (`string`)
  The deployment slot for all App Services in the App Service Environment.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- `ApplicationModel.IResourceBuilder`1`

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithHttpsUpgrade(IResourceBuilder<AzureAppServiceEnvironmentResource>, bool)

- Name: `WithHttpsUpgrade(IResourceBuilder<AzureAppServiceEnvironmentResource>, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppServiceEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs#L287-L288)

Configures whether HTTP endpoints should be automatically upgraded to HTTPS for the Azure App Service environment. By default, HTTP endpoints are upgraded to HTTPS for security and WebSocket compatibility.

```csharp
public static class AzureAppServiceEnvironmentExtensions
{
    public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithHttpsUpgrade(
        this IResourceBuilder<AzureAppServiceEnvironmentResource> builder,
        bool upgrade = true)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppServiceEnvironmentResource>`)
  The `ApplicationModel.IResourceBuilder`1` to configure.
- `upgrade` (`bool`) `optional`
  Whether to upgrade HTTP endpoints to HTTPS. Default is true.

## Returns

`IResourceBuilder<AzureAppServiceEnvironmentResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1` for chaining additional configuration.

## Remarks

When disabled ( `false`), HTTP endpoints will use HTTP scheme and port 80 in Azure App Service. Note that Azure App Service forces HTTP to HTTPS redirects at the platform level, so disabling upgrade primarily affects connection strings generated for dependent resources.

## Examples

Preserve HTTP endpoints instead of automatically upgrading them to HTTPS:

```csharp
var appService = builder.AddAzureAppServiceEnvironment("appservice")
    .WithHttpsUpgrade(false);
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
