Get started with the Azure Functions integration
Цей контент ще не доступний вашою мовою.
Azure Functions is a serverless compute service that lets you run event-triggered code without having to explicitly provision or manage infrastructure. The Aspire Azure Functions integration enables you to model Azure Functions projects as part of your distributed application.
In this introduction, you’ll see how to install and use the Aspire Azure Functions integration in a simple configuration. If you already have this knowledge, see Azure Functions Hosting integration for full reference details.
It’s expected that you’ve installed the required Azure tooling:
Supported scenarios
Section titled “Supported scenarios”The Aspire Azure Functions integration has several key supported scenarios.
Supported triggers
Section titled “Supported triggers”The following table lists the supported triggers for Azure Functions in the Aspire integration:
| Trigger | Attribute | Details |
|---|---|---|
| Azure Event Hubs trigger | EventHubTrigger | 📦 Aspire.Hosting.Azure.EventHubs |
| Azure Service Bus trigger | ServiceBusTrigger | 📦 Aspire.Hosting.Azure.ServiceBus |
| Azure Storage Blobs trigger | BlobTrigger | 📦 Aspire.Hosting.Azure.Storage |
| Azure Storage Queues trigger | QueueTrigger | 📦 Aspire.Hosting.Azure.Storage |
| Azure CosmosDB trigger | CosmosDbTrigger | 📦 Aspire.Hosting.Azure.CosmosDB |
| HTTP trigger | HttpTrigger | Supported without any additional resource dependencies. |
| Timer trigger | TimerTrigger | Supported without any additional resource dependencies—relies on implicit host storage. |
For more information about the Azure Functions integration with Aspire, see Azure Functions and Aspire integration.
Set up hosting integration
Section titled “Set up hosting integration”To begin, install the Aspire Azure Functions Hosting integration in your Aspire AppHost project:
aspire add azure-functionsAspire CLI інтерактивний; оберіть відповідний результат пошуку:
Select an integration to add:
> azure-functions (Aspire.Hosting.Azure.Functions)> Other results listed as selectable options...#:package Aspire.Hosting.Azure.Functions@*<PackageReference Include="Aspire.Hosting.Azure.Functions" Version="*" />Next, in the AppHost project, add an Azure Functions resource:
var builder = DistributedApplication.CreateBuilder(args);
var functions = builder.AddAzureFunctionsProject<Projects.ExampleFunctions>("functions") .WithExternalHttpEndpoints();
builder.AddProject<Projects.ExampleProject>() .WithReference(functions) .WaitFor(functions);
// After adding all resources, run the app...
builder.Build().Run();The preceding code adds an Azure Functions project resource named functions and makes it available to other projects in your distributed application.
Continue learning
Section titled “Continue learning”For more information on how the Azure Functions integration works, see: