Pular para o conteúdo

Get started with the Azure App Service integration

Este conteúdo não está disponível em sua língua ainda.

Azure App Service logo 🧪 Preview

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 seamlessly publish your container, executable, and project resources as Azure App Service websites.

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.

To begin, install the Aspire Azure App Service Hosting integration in your Aspire AppHost project:

Aspire CLI — Adicionar pacote Aspire.Hosting.Azure.AppService
aspire add azure-appservice

A CLI Aspire é interativa; escolhe o resultado apropriado quando solicitado:

Aspire CLI — Exemplo de saída
Select an integration to add:
> azure-appservice (Aspire.Hosting.Azure.AppService)
> Other results listed as selectable options...

Next, add an App Service environment to your AppHost project. The environment represents the hosting infrastructure (App Service Plan) where your apps will run:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var appServiceEnv = builder.AddAzureAppServiceEnvironment("app-service-env");
builder.AddProject<Projects.WebApi>("api")
.PublishAsAzureAppServiceWebsite((infra, website) =>
{
// Optional: customize the Azure App Service website here
});
builder.Build().Run();

The preceding code:

  • Creates an Azure App Service environment named app-service-env.
  • Adds a project named api to the AppHost.
  • Configures the project to be published as an Azure App Service website.
  • Provides an optional callback to customize the website configuration.

During local development (when running with F5 F5 F5 ), the project runs locally. When you publish your app, the project is deployed as an Azure App Service website within the provisioned environment.