Get started with the Azure App Service integration
此内容尚不支持你的语言。
Azure App Service is a fully managed platform for building, deploying, and scaling web apps. Aspire apps often run locally during development but require scalable, production-ready hosting environments for staging and production. The Aspire integration allows you to provision or reference an existing Azure App Service environment (App Service Plan) and automatically deploy supported web-facing project resources and Dockerfile-backed web containers as Azure App Service websites. Backing services such as databases, caches, and brokers should use managed Azure services instead of App Service websites. Use PublishAsAzureAppServiceWebsite when you need to customize the generated website.
In this introduction, you’ll see how to install and use the Aspire Azure App Service integration in a simple configuration. If you already have this knowledge, see Azure App Service Hosting integration for full reference details.
Set up hosting integration
Section titled “Set up hosting integration”To begin, install the Aspire Azure App Service Hosting integration in your Aspire AppHost project:
aspire add azure-appserviceAspire CLI 是交互式的;按提示选择合适的搜索结果:
Select an integration to add:
> azure-appservice (Aspire.Hosting.Azure.AppService)> Other results listed as selectable options...#:package Aspire.Hosting.Azure.AppService@*<PackageReference Include="Aspire.Hosting.Azure.AppService" Version="*" />Next, add an App Service environment to your AppHost project. The environment represents the hosting infrastructure (App Service Plan) where your apps will run:
var builder = DistributedApplication.CreateBuilder(args);
var appServiceEnv = builder.AddAzureAppServiceEnvironment("app-service-env");
builder.AddProject<Projects.WebApi>("api");
builder.Build().Run();The preceding code:
- Creates an Azure App Service environment named
app-service-env. - Adds a project named
apito the AppHost. - Targets the
apiproject to the App Service environment automatically.
During local development (when running with
You don’t need PublishAsAzureAppServiceWebsite for standard deployment. Use it only when you want to customize the generated website or deployment slot.