A sample project for the Aspire and Azure Functions integration
MIT License
This project demonstrates the Aspire and Azure Functions integration.
[!NOTE] This repository requires the following dependencies:
- A .NET 9 RC 2 SDK to support its functionality.
Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore
at v2.0.0-preview1Microsoft.Azure.Functions.Worker.Sdk
at v2.0.0-preview1- Azure Functions Core Tools at v4.0.6280
This project requires the .NET 8.0.401 SDK and the Aspire workload.
dotnet workload install aspire
To run this project, launch the AppHost project.
cd AzureFunctionsTest/AzureFunctionsTest.AppHost
dotnet run
To replicate this setup on existing Azure Functions projects, a few modifications need to be made in order to work around current limitations in the integration.
AzureWebJobsStorage
configuration generated by the Azure Functions template in local.settings.json
. The Aspire Azure Functions integration will configure the default host storage for Azure Functions using Aspire's Azure Storage integrations. These integrations handle launching the Azure Storage emulator and wiring up the endpoint references to the Azure Functions project, so no other explicit configuration is needed.{
"IsEncrypted": false,
"Values": {
- "AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
Currently, there's a requirement that all Azure Functions trigger bindings specify a connection name that aligns with the name of the Aspire resource.
For example, given the following resource configuration for an Azure Storage Queue resource named "queue" and an Azure Storage Blobs resource named "blob":
using Aspire.Hosting.Azure;
var builder = DistributedApplication.CreateBuilder(args);
var storage = builder.AddAzureStorage("storage").RunAsEmulator();
var queue = storage.AddQueues("queue");
var blob = storage.AddBlobs("blob");
builder.AddAzureFunctionsProject<Projects.AzureFunctionsEndToEnd_Functions>("funcapp")
.WithExternalHttpEndpoints()
.WithReference(queue)
.WithReference(blob)
The following trigger bindings must be used for Queue and Blob triggers respectively:
[BlobTrigger("blobs/{name}", Connection = "blob")]
// ...
[QueueTrigger("queue", Connection = "queue")]