You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/dotnet-aspire-integration.md
+68-15Lines changed: 68 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,28 +3,25 @@ title: Guide for Using Azure Functions with Aspire
3
3
description: Learn how to use Azure Functions with Aspire, which simplifies authoring of distributed applications in the cloud.
4
4
ms.service: azure-functions
5
5
ms.topic: conceptual
6
-
ms.date: 04/21/2025
6
+
ms.date: 10/31/2025
7
7
---
8
8
9
-
# Azure Functions with Aspire (preview)
9
+
# Azure Functions with Aspire
10
10
11
11
[Aspire](/dotnet/aspire/get-started/aspire-overview) is an opinionated stack that simplifies development of distributed applications in the cloud. The integration of Aspire with Azure Functions enables you to develop, debug, and orchestrate an Azure Functions .NET project as part of the Aspire app host.
12
12
13
-
> [!IMPORTANT]
14
-
> The integration of Aspire with Azure Functions is currently in preview and is subject to change.
15
-
16
13
## Prerequisites
17
14
18
15
Set up your development environment for using Azure Functions with Aspire:
19
16
20
-
- Install the [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0) and [Aspire 9.0 or later](/dotnet/aspire/fundamentals/setup-tooling). Although the .NET 9 SDK is required, Aspire 9.0 supports the .NET 8 and .NET 9 frameworks.
21
-
- If you use Visual Studio, update to version 17.12 or later. You must also have the latest version of the Azure Functions tools for Visual Studio. To check for updates:
17
+
-[Install the Aspire Prerequisites](/dotnet/aspire/fundamentals/setup-tooling#install-aspire-prerequisites).
18
+
- Full support for the Azure Functions integration requires Aspire 13.1 or later. Aspire 13.0 also includes a preview version of `Aspire.Hosting.Azure.Functions` which acts as a release candidate with go-live support.
19
+
- Install the [Azure Functions Core Tools](./functions-run-local.md).
20
+
21
+
If you use Visual Studio, update to version 17.12 or later. You must also have the latest version of the Azure Functions tools for Visual Studio. To check for updates:
22
22
1. Go to **Tools** > **Options**.
23
23
1. Under **Projects and Solutions**, select **Azure Functions**.
24
24
1. Select **Check for updates** and install updates as prompted.
25
-
26
-
> [!NOTE]
27
-
> The Azure Functions integration with Aspire doesn't yet support .NET 10 Preview.
28
25
29
26
## Solution structure
30
27
@@ -176,11 +173,18 @@ For details on the connection formats that each binding supports, and the permis
176
173
177
174
## Hosting the application
178
175
179
-
By default, when you publish an Azure Functions project to Azure, it's deployed to Azure Container Apps.
176
+
Aspire supports two different ways to host your Functions project in Azure:
177
+
178
+
-[Publish as a container app (default)](#publish-as-a-container-app)
179
+
-[Publish as a function app](#publish-as-a-function-app) using preview App Service integration
180
180
181
-
During the preview period, the container app resources don't support event-driven scaling. Azure Functions support is not available for apps deployed in this mode. If you need to open a support ticket, select the Azure Container Apps resource type.
181
+
In both cases, your project is deployed as a container. Aspire takes care of building the container image for you and pushing it to Azure Container Registry.
182
182
183
-
### Access keys
183
+
### Publish as a container app
184
+
185
+
By default, when you publish an Aspire project to Azure, it's deployed to Azure Container Apps. The system sets up scaling rules for your Functions project using [KEDA](https://keda.sh/). When using Azure Container Apps, additional setup is needed for function keys. See [Access keys on Azure Container Apps](#access-keys-on-azure-container-apps) for more information.
186
+
187
+
#### Access keys on Azure Container Apps
184
188
185
189
Several Azure Functions scenarios use access keys to provide a basic mitigation against unwanted access. For example, HTTP trigger functions by default require an access key to be invoked, though this requirement can be disabled using the [`AuthLevel` property](./functions-bindings-http-webhook-trigger.md#attributes). See [Work with access keys in Azure Functions](./function-keys-how-to.md) for scenarios which may require a key.
186
190
@@ -329,12 +333,60 @@ This example uses a default key vault created by the extension method. It result
329
333
330
334
To use these keys from clients, you need to retrieve them from the key vault.
331
335
336
+
### Publish as a function app
337
+
338
+
> [!NOTE]
339
+
> Publishing as a function app requires the Aspire Azure App Service integration, which is currently in preview.
340
+
341
+
You can configure Aspire to deploy to a function app using the [Aspire Azure App Service integration](/dotnet/aspire/azure/azure-app-service-integration). Because Aspire publishes the Functions project as a container, the hosting plan for your function app must support deploying containerized applications.
342
+
343
+
To publish your Aspire Functions project as a function app, follow these steps:
344
+
345
+
1. Add a reference to the [Aspire.Hosting.Azure.AppService] NuGet package in your app host project.
346
+
1. In the `AppHost.cs` file, call `AddAzureAppServiceEnvironment()` on your `IDistributedApplicationBuilder` instance to create an App Service plan. Note that despite the name, this does not provision an App Service Environment resource.
347
+
1. On the Functions project resource, call `.WithExternalHttpEndpoints()`. This is required for deploying with the Aspire Azure App Service integration.
348
+
1. On the Functions project resource, call `.PublishAsAzureAppServiceWebsite((infra, app) => app.Kind = "functionapp,linux")` to publish that project to the plan.
349
+
350
+
> [!IMPORTANT]
351
+
> Make sure that you set the `app.Kind` property to `"functionapp,linux"`. This setting ensures the resource is created as a function app, which affects experiences for working with your application.
352
+
353
+
The following example shows a minimal `AppHost.cs` file for an app host project that publishes a Functions project as a function app:
By default, this configuration creates a Premium V3 plan. When using a dedicated App Service plan SKU, scaling isn't event-based. Instead, scaling is managed through the App Service plan settings. If you want to change the SKU, you can do so through the `ConfigureInfrastructure` method on the environment resource. The following example shows how you can set up an Elastic Premium plan:
When you configure the plan to use an Elastic Premium SKU, you can only publish Functions projects to that plan. If your app host project includes other web apps, you should use a dedicated App Service plan SKU.
385
+
332
386
## Considerations and best practices
333
387
334
388
Consider the following points when you're evaluating the integration of Azure Functions with Aspire:
335
389
336
-
- Support for the integration is currently in preview.
337
-
338
390
- Trigger and binding configuration through Aspire is currently limited to specific integrations. For details, see [Connection configuration with Aspire](#connection-configuration-with-aspire) in this article.
339
391
340
392
- Your function project's `Program.cs` file should use the `IHostApplicationBuilder` version of [host instance startup](./dotnet-isolated-process-guide.md#start-up-and-configuration). `IHostApplicationBuilder` allows you to call `builder.AddServiceDefaults()` to add [Aspire service defaults](/dotnet/aspire/fundamentals/service-defaults) to your Functions project.
@@ -354,6 +406,7 @@ Consider the following points when you're evaluating the integration of Azure Fu
ApplicationInsightsintegrationisnotenabledbydefaultinallsetupexperiences. SometemplateswillcreateFunctionsprojectswiththenecessarypackagesandstartupcodecommentedout. IfyouwanttouseApplicationInsightsintegration, youcanuncommenttheselinesin `Program.cs` andtheproject's `.csproj` file. The instructions in the rest of this section also describe how to enable the integration.
3. Youcan't run .NET 10 apps on Linux in the Consumption plan. To run on Linux, you should instead use the [Flex Consumption plan](./flex-consumption-plan.md).
1331
1331
1332
1332
See [Supportedversions][supported-versions] foralistofgenerallyavailablereleasesthatyoucanuse.
0 commit comments