Skip to content
Docs Try Aspire
Docs Try

Get started with the Azure Functions integration

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 lets you model a Functions project as a first-class compute resource in your AppHost, wire it up to storage, messaging, and database resources, and configure bindings automatically through Aspire-injected environment variables.

Adding Azure Functions through Aspire — rather than configuring host JSON and connection strings by hand — gives you:

  • Zero-config local development. Aspire starts a local Azure Functions host, wires up Azurite for the required host storage, and injects connection strings for any Azure resource you reference from the AppHost.
  • Consistent resource references. Trigger and binding configuration for Service Bus, Storage, Cosmos DB, and Event Hubs is automatically injected into the Functions host at run time.
  • Dashboard observability. The Functions project shows up in the Aspire dashboard with logs, status, and telemetry alongside your other services.
  • KEDA-based deployment. When deployed to Azure Container Apps, the integration configures KEDA auto-scaling rules for your functions automatically.
  • Durable Task Scheduler support. Attach a local or existing Durable Task Scheduler with AddDurableTaskScheduler and a named task hub.

The Azure Functions integration has one side: a hosting integration that you use in your AppHost to model the Functions project as a compute resource. Azure Functions is not a backing service — it consumes other resources rather than providing connection information to them.

architecture-beta

  group apphost(server)[AppHost]
  group functions(server)[Functions project]

  service hosting(server)[Hosting integration] in apphost
  service storage(database)[Host storage] in apphost
  service trigger(server)[Trigger resource] in apphost

  service worker(server)[Functions runtime] in functions

  hosting:R --> L:storage
  hosting:R --> L:trigger
  trigger:R --> L:worker

The hosting integration lives in your AppHost project and models the Azure Functions project and its resource dependencies. At run time, the Functions project reads Aspire-injected environment variables to connect to triggers and bindings.

Getting there is a two-step process: model the Functions project in your AppHost, then configure your function bindings to read the injected connection information.

  1. Add the Azure Functions hosting integration to your AppHost, then declare a Functions project and reference the Azure resources it needs. The Azure Functions Hosting integration article walks through every capability — host storage, resource references, external HTTP endpoints, Durable Task Scheduler, and more — with side-by-side C# and TypeScript examples.

    Set up Azure Functions in the AppHost

  2. When your AppHost references other Azure resources from the Functions project, Aspire injects connection information as environment variables into the Functions host. See Azure Functions runtime configuration for how to read those values in .NET isolated worker, TypeScript/JavaScript, and Python functions, and for cross-links to binding-specific integration articles.

    Configure runtime bindings

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.