Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions src/Aspire.Hosting.Azure.AppService/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Aspire.Hosting.Azure.AppService library

Provides extension methods and resource definitions for a .NET Aspire AppHost to configure Azure App Service.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the compute resources (like project).


## Getting started

### Prerequisites

- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default SKU we use for AppService (P0v3) is not supported on free subscription. Remove the "create one for free" line.

Copy link
Contributor

@ShilpiRach ShilpiRach Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add that user needs to be the owner of the subscription.


### Install the package

In your AppHost project, install the .NET Aspire Azure App Service Hosting library with [NuGet](https://www.nuget.org):

```dotnetcli
dotnet add package Aspire.Hosting.Azure.AppService
```

## Usage example

In the _AppHost.cs_ file of `AppHost`, add an Azure App Service Environment and publish your project as an Azure App Service website:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var appServiceEnvironment = builder.AddAzureAppServiceEnvironment("env");

builder.AddProject<Projects.MyWebApp>("webapp")
.WithExternalHttpEndpoints()
.PublishAsAzureAppServiceWebsite((infrastructure, site) =>
{
// Configure the App Service website
site.SiteConfig.IsWebSocketsEnabled = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to appsettings

});
```

## Azure App Service constraints

When deploying to Azure App Service, the following constraints apply:

- **External endpoints only**: App Service only supports external endpoints. All endpoints must be configured using `WithExternalHttpEndpoints()`.
- **HTTP/HTTPS only**: Only HTTP and HTTPS endpoints are supported. Other protocols are not supported.
- **Single endpoint**: App Service supports only a single target port. Resources with multiple external endpoints with different target ports are not supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is 8000. TargetPort can be overriden with WithHttpEndpoint extension method.


### Publishing compute resources to Azure App Service

The `PublishAsAzureAppServiceWebsite` extension method is used to configure a compute resource (such as a project) to be published as an Azure App Service website when deploying to Azure. This method allows you to customize the App Service website configuration using the Azure Provisioning SDK.

```csharp
builder.AddProject<Projects.MyApi>("api")
.WithHttpEndpoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the following extension methods:

  • WithHealthProbe to enable health checks
  • WithArgs to add command line parameter

.WithExternalHttpEndpoints()
.PublishAsAzureAppServiceWebsite((infrastructure, site) =>
{
// Customize the App Service website settings
site.SiteConfig.IsWebSocketsEnabled = true;
site.SiteConfig.MinTlsVersion = SupportedTlsVersions.Tls1_2;
});
```

### Adding an Azure App Service Environment

The Azure App Service Environment resource creates the underlying infrastructure needed to host your applications, including:

- An Azure App Service Plan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default SKU is P0v3. This can be changed with:

var appServiceEnvironment = builder.AddAzureAppServiceEnvironment("env")
    .ConfigureInfrastructure((infra) =>
    {
        var plan = infra.GetProvisionableResources().OfType<AppServicePlan>().Single();
        plan.Sku = new AppServiceSkuDescription
        {
            Name = "P2V3",
            Tier = "Premium"
        };
    });

- An Azure Container Registry for storing container images
- A managed identity for accessing the container registry
- Optionally, the Aspire Dashboard as an Azure App Service website

```csharp
var appServiceEnvironment = builder.AddAzureAppServiceEnvironment("env");
```

By default, the Aspire Dashboard is included in the App Service Environment. To disable the dashboard, use the `WithDashboard` extension method:

```csharp
var appServiceEnvironment = builder.AddAzureAppServiceEnvironment("env")
.WithDashboard(enable: false);
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add information about Application Insights that can be enabled with WithAzureApplicationInsights extension method.

  • A different location can be specified for Application Insights using the option parameter for location.
var appServiceEnvironment = builder.AddAzureAppServiceEnvironment("env")
   .WithAzureApplicationInsights();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Address this feedback

## Additional documentation

* https://learn.microsoft.com/azure/app-service/
* https://github.com/dotnet/aspire/tree/main/src/Components/README.md

## Feedback & contributing

https://github.com/dotnet/aspire
Loading