-
Couldn't load subscription status.
- Fork 712
Add README to Aspire.Hosting.Azure.AppService #12105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
004c505
9163770
051db48
9f3fda1
760ba2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. | ||
|
|
||
| ## Getting started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Azure subscription - [create one for free](https://azure.microsoft.com/free/) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default is 8000. TargetPort can be overriden with |
||
|
|
||
| ### 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() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the following extension methods:
|
||
| .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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| ``` | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add information about Application Insights that can be enabled with
var appServiceEnvironment = builder.AddAzureAppServiceEnvironment("env")
.WithAzureApplicationInsights();There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment.
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).