Skip to content

Get started with the Azure Functions integration

Choose a development environment
Azure Functions logo

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:

The Aspire Azure Functions integration has several key supported scenarios.

The following table lists the supported triggers for Azure Functions in the Aspire integration:

TriggerAttributeDetails
Azure Event Hubs triggerEventHubTrigger📦 Aspire.Hosting.Azure.EventHubs
Azure Service Bus triggerServiceBusTrigger📦 Aspire.Hosting.Azure.ServiceBus
Azure Storage Blobs triggerBlobTrigger📦 Aspire.Hosting.Azure.Storage
Azure Storage Queues triggerQueueTrigger📦 Aspire.Hosting.Azure.Storage
Azure CosmosDB triggerCosmosDbTrigger📦 Aspire.Hosting.Azure.CosmosDB
HTTP triggerHttpTriggerSupported without any additional resource dependencies.
Timer triggerTimerTriggerSupported 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.

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

Aspire CLI — Add Aspire.Hosting.Azure.Functions package
aspire add azure-functions

The Aspire CLI is interactive, be sure to select the appropriate search result when prompted:

Aspire CLI — Example output prompt
Select an integration to add:
> azure-functions (Aspire.Hosting.Azure.Functions)
> Other results listed as selectable options...

Next, in the AppHost project, add an Azure Functions resource:

C# — AppHost.cs
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.

For more information on how the Azure Functions integration works, see: