Skip to content

Commit 220c3e9

Browse files
Splitting Functions and Aspire to new article
1 parent 6a50247 commit 220c3e9

8 files changed

+220
-130
lines changed

articles/azure-functions/TOC.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,16 @@
415415
- name: Isolated worker model
416416
displayName: .NET isolated
417417
href: dotnet-isolated-process-guide.md
418-
- name: In-process model
419-
href: functions-dotnet-class-library.md
420-
- name: Script (.csx)
421-
href: functions-reference-csharp.md
422-
- name: Execution mode comparison
423-
href: dotnet-isolated-in-process-differences.md
418+
- name: .NET Aspire integration (Preview)
419+
href: dotnet-aspire-integration.md
420+
- name: Legacy models
421+
items:
422+
- name: Execution mode comparison
423+
href: dotnet-isolated-in-process-differences.md
424+
- name: In-process model
425+
href: functions-dotnet-class-library.md
426+
- name: Script (.csx)
427+
href: functions-reference-csharp.md
424428
- name: JavaScript
425429
href: functions-reference-node.md?tabs=javascript
426430
- name: TypeScript

articles/azure-functions/dotnet-aspire-integration.md

Lines changed: 201 additions & 0 deletions
Large diffs are not rendered by default.

articles/azure-functions/dotnet-isolated-in-process-differences.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Use the following table to compare feature and functional differences between th
4343
| Cold start times<sup>2</sup> | [Configurable optimizations](./dotnet-isolated-process-guide.md#performance-optimizations) | Optimized |
4444
| ReadyToRun | [Supported](dotnet-isolated-process-guide.md#readytorun) | [Supported](functions-dotnet-class-library.md#readytorun) |
4545
| [Flex Consumption] | [Supported](./flex-consumption-plan.md#supported-language-stack-versions) | Not supported |
46-
| .NET Aspire | [Preview](dotnet-isolated-process-guide.md#net-aspire-preview) | Not supported |
46+
| .NET Aspire | [Preview](./dotnet-aspire-integration.md) | Not supported |
4747

4848
<sup>1</sup> When you need to interact with a service using parameters determined at runtime, using the corresponding service SDKs directly is recommended over using imperative bindings. The SDKs are less verbose, cover more scenarios, and have advantages for error handling and debugging purposes. This recommendation applies to both models.
4949

articles/azure-functions/dotnet-isolated-process-guide.md

Lines changed: 4 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,125 +1219,7 @@ When you create your function app in Azure using the methods in the previous sec
12191219

12201220
## .NET Aspire (Preview)
12211221

1222-
[.NET Aspire](/dotnet/aspire/get-started/aspire-overview) is an opinionated stack that simplifies development of distributed applications in the cloud. You can enlist .NET 8 and .NET 9 isolated worker model projects in Aspire 9.0 orchestrations using preview support. The section outlines the core requirements for enlistment.
1223-
1224-
This integration requires specific setup:
1225-
1226-
- Use [Aspire 9.0 or later](/dotnet/aspire/fundamentals/setup-tooling) and the [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0). Aspire 9.0 supports the .NET 8 and .NET 9 frameworks.
1227-
- If you use Visual Studio, update to version 17.12 or later. You must also have the latest version of the Functions tools for Visual Studio. To check for updates, navigate to **Tools** > **Options**, choose **Azure Functions** under **Projects and Solutions**. Select **Check for updates** and install updates as prompted.
1228-
- In the [Aspire app host project](/dotnet/aspire/fundamentals/app-host-overview):
1229-
- You must reference [Aspire.Hosting.Azure.Functions].
1230-
- You must have a project reference to your Functions project.
1231-
- In the app host's `Program.cs`, you must also include the project by calling `AddAzureFunctionsProject<TProject>()` on your `IDistributedApplicationBuilder`. This method is used instead of the `AddProject<TProject>()` that you use for other project types. If you just use `AddProject<TProject>()`, the Functions project will not start properly.
1232-
- In the Functions project:
1233-
- You must reference the [2.x versions](#version-2x) of [Microsoft.Azure.Functions.Worker] and [Microsoft.Azure.Functions.Worker.Sdk]. You must also update any references you have to `Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore` to the 2.x version as well.
1234-
- Your `Program.cs` should use the `IHostApplicationBuilder` version of [host instance startup](#start-up-and-configuration).
1235-
- If you want to use your Aspire service defaults, you should include a project reference to the service defaults project. Before building your `IHostApplicationBuilder` in `Program.cs`, you should also include a call to `builder.AddServiceDefaults()`.
1236-
- You shouldn't keep configuration in `local.settings.json`, aside from the `FUNCTIONS_WORKER_RUNTIME` setting, which should remain "dotnet-isolated". Other configuration should be set through the app host project.
1237-
- You should remove any direct Application Insights integrations. Monitoring in Aspire is instead handled through its OpenTelemetry support.
1238-
1239-
The following example shows a minimal `Program.cs` for an App Host project:
1240-
1241-
```csharp
1242-
var builder = DistributedApplication.CreateBuilder(args);
1243-
1244-
builder.AddAzureFunctionsProject<Projects.MyFunctionsProject>("MyFunctionsProject");
1245-
1246-
builder.Build().Run();
1247-
```
1248-
1249-
The following example shows a minimal `Program.cs` for a Functions project used in Aspire:
1250-
1251-
```csharp
1252-
using Microsoft.Azure.Functions.Worker;
1253-
using Microsoft.Azure.Functions.Worker.Builder;
1254-
using Microsoft.Extensions.DependencyInjection;
1255-
using Microsoft.Extensions.Hosting;
1256-
1257-
var builder = FunctionsApplication.CreateBuilder(args);
1258-
1259-
builder.AddServiceDefaults();
1260-
1261-
builder.ConfigureFunctionsWebApplication();
1262-
1263-
builder.Build().Run();
1264-
```
1265-
1266-
This does not include the default Application Insights configuration that you see in many of the other `Program.cs` examples in this article. Instead, Aspire's OpenTelemetry integration is configured through the `builder.AddServiceDefaults()` call.
1267-
1268-
### Considerations and best practices for .NET Aspire integration
1269-
1270-
Consider the following points when evaluating .NET Aspire with Azure Functions:
1271-
1272-
- Support for Azure Functions with .NET Aspire is currently in preview. During the preview period, when you publish the Aspire solution to Azure, Functions projects are deployed as Azure Container Apps resources without event-driven scaling. Azure Functions support is not available for apps deployed in this mode.
1273-
- Trigger and binding configuration through Aspire is currently limited to specific integrations. See [Connection configuration with Aspire](#connection-configuration-with-aspire) for details.
1274-
- Your `Program.cs` should use the `IHostApplicationBuilder` version of [host instance startup](#start-up-and-configuration). This allows you to call `builder.AddServiceDefaults()` to add [.NET Aspire service defaults](/dotnet/aspire/fundamentals/service-defaults) to your Functions project.
1275-
- Aspire uses OpenTelemetry for monitoring. You can configure Aspire to export telemetry to Azure Monitor through the service defaults project. In many other Azure Functions contexts, you might include direct integration with Application Insights by registering the telemetry worker service. This is not recommended in Aspire and can lead to runtime errors with version 2.22.0 of `Microsoft.ApplicationInsights.WorkerService`. You should remove any direct Application Insights integrations from your Functions project when using Aspire.
1276-
- For Functions projects enlisted into an Aspire orchestration, most of the application configuration should come from the Aspire app host project. You should typically avoid setting things in `local.settings.json`, other than the `FUNCTIONS_WORKER_RUNTIME` setting. If the same environment variable is set by `local.settings.json` and Aspire, the system uses the Aspire version.
1277-
- Do not configure the Storage emulator for any connections in `local.settings.json`. Many Functions starter templates include the emulator as a default for `AzureWebJobsStorage`. However, emulator configuration can prompt some IDEs to start a version of the emulator that can conflict with the version that Aspire uses.
1278-
1279-
### Connection configuration with Aspire
1280-
1281-
Azure Functions requires a [host storage connection (`AzureWebJobsStorage`)](./functions-reference.md#connecting-to-host-storage-with-an-identity) for several of its core behaviors. When you call `AddAzureFunctionsProject<TProject>()` in your app host project, a default `AzureWebJobsStorage` connection is created and provided to the Functions project. This default connection uses the Storage emulator for local development runs and automatically provisions a storage account when deployed. For additional control, you can replace this connection by calling `.WithHostStorage()` on the Functions project resource.
1282-
1283-
The following example shows a minimal `Program.cs` for an app host project that replaces the host storage:
1284-
1285-
```csharp
1286-
var builder = DistributedApplication.CreateBuilder(args);
1287-
1288-
var myHostStorage = builder.AddAzureStorage("myHostStorage");
1289-
1290-
builder.AddAzureFunctionsProject<Projects.MyFunctionsProject>("MyFunctionsProject")
1291-
.WithHostStorage(myHostStorage);
1292-
1293-
builder.Build().Run();
1294-
```
1295-
1296-
> [!NOTE]
1297-
> When Aspire provisions the host storage in publish mode, it defaults to creating role assignments for the [Storage Account Contributor], [Storage Blob Data Contributor], [Storage Queue Data Contributor], and [Storage Table Data Contributor] roles.
1298-
1299-
Your triggers and bindings reference connections by name. Some Aspire integrations are enabled to provide these through a call to `WithReference()` on the project resource:
1300-
1301-
| Aspire integration | Notes |
1302-
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1303-
| [Azure Blobs](/dotnet/aspire/storage/azure-storage-blobs-integration) | When Aspire provisions the resource, it defaults to creating role assignments for the [Storage Blob Data Contributor], [Storage Queue Data Contributor], and [Storage Table Data Contributor] roles. |
1304-
| [Azure Queues](/dotnet/aspire/storage/azure-storage-queues-integration) | When Aspire provisions the resource, it defaults to creating role assignments for the [Storage Blob Data Contributor], [Storage Queue Data Contributor], and [Storage Table Data Contributor] roles. |
1305-
| [Azure Event Hubs](/dotnet/aspire/messaging/azure-event-hubs-integration) | When Aspire provisions the resource, it defaults to creating a role assignment using the [Azure Event Hubs Data Owner] role. |
1306-
| [Azure Service Bus](/dotnet/aspire/messaging/azure-service-bus-integration) | When Aspire provisions the resource, it defaults to creating a role assignment using the [Azure Service Bus Data Owner] role. |
1307-
1308-
The following example shows a minimal `Program.cs` for an app host project that configures a queue trigger. In this example, the corresponding queue trigger has its `Connection` property set to "MyQueueTriggerConnection".
1309-
1310-
```csharp
1311-
var builder = DistributedApplication.CreateBuilder(args);
1312-
1313-
var myAppStorage = builder.AddAzureStorage("myAppStorage").RunAsEmulator();
1314-
var queues = myAppStorage.AddQueues("queues");
1315-
1316-
builder.AddAzureFunctionsProject<Projects.MyFunctionsProject>("MyFunctionsProject")
1317-
.WithReference(queues, "MyQueueTriggerConnection");
1318-
1319-
builder.Build().Run();
1320-
```
1321-
1322-
For other integrations, calls to `WithReference` set the configuration in a different way, making it available to [Aspire client integrations](/dotnet/aspire/fundamentals/integrations-overview#client-integrations), but not to triggers and bindings. For these integrations, you should call `WithEnvironment()` to pass the connection information for the trigger or binding to resolve. The following example shows how to set the environment variable "MyBindingConnection" for a resource that exposes a connection string expression:
1323-
1324-
```csharp
1325-
builder.AddAzureFunctionsProject<Projects.MyFunctionsProject>("MyFunctionsProject")
1326-
.WithEnvironment("MyBindingConnection", otherIntegration.Resource.ConnectionStringExpression);
1327-
```
1328-
1329-
You can configure both `WithReference()` and `WithEnvironment()` if you want a connection to be used both by Aspire client integrations and the triggers and bindings system.
1330-
1331-
For some resources, the structure of a connection might be different between when you run it locally and when you publish it to Azure. In the previous example, `otherIntegration` could be a resource that runs as an emulator, so `ConnectionStringExpression` would return an emulator connection string. However, when the resource is published, Aspire might set up an identity-based connection, and `ConnectionStringExpression` would return the service's URI. In this case, to set up [identity based connections for Azure Functions](./functions-reference.md#configure-an-identity-based-connection), you might need to provide a different environment variable name. The following example uses `builder.ExecutionContext.IsPublishMode` to conditionally add the necessary suffix:
1332-
1333-
```csharp
1334-
builder.AddAzureFunctionsProject<Projects.MyFunctionsProject>("MyFunctionsProject")
1335-
.WithEnvironment("MyBindingConnection" + (builder.ExecutionContext.IsPublishMode ? "__serviceUri" : ""), otherIntegration.Resource.ConnectionStringExpression);
1336-
```
1337-
1338-
Depending on your scenario, you may also need to adjust the permissions that will be assigned for an identity-based connection. You can use the [`ConfigureConstruct<T>()` method](/dotnet/api/aspire.hosting.azureconstructresourceextensions.configureconstruct) to customize how Aspire configures infrastructure when it publishes your project.
1339-
1340-
Consult each binding's [reference pages](./functions-triggers-bindings.md#supported-bindings) for details on the connection formats it supports and the permissions those formats require.
1222+
[.NET Aspire](/dotnet/aspire/get-started/aspire-overview) is an opinionated stack that simplifies development of distributed applications in the cloud. You can enlist .NET 8 and .NET 9 isolated worker model projects in Aspire 9.0 orchestrations using preview support. See [Azure Functions with .NET Aspire (Preview)](./dotnet-aspire-integration.md) for more information.
13411223

13421224
## Debugging
13431225

@@ -1489,6 +1371,9 @@ Keep these considerations in mind when using Functions with preview versions of
14891371
> [!div class="nextstepaction"]
14901372
> [Migrate .NET apps to the isolated worker model][migrate]
14911373

1374+
> [!div class="nextstepaction"]
1375+
> [Integrate with .NET Aspire](./dotnet-aspire-integration.md)
1376+
14921377
[migrate]: ./migrate-dotnet-to-isolated-model.md
14931378

14941379
[supported-versions]: #supported-versions

articles/azure-functions/functions-bindings-service-bus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Functions 1.x apps automatically have a reference the [Microsoft.Azure.WebJobs](
6767

6868
This version allows you to bind to types from [Azure.Messaging.ServiceBus](/dotnet/api/azure.messaging.servicebus).
6969

70-
This version supports configuration of triggers and bindings through [.NET Aspire integration](./dotnet-isolated-process-guide.md#connection-configuration-with-aspire).
70+
This version supports configuration of triggers and bindings through [.NET Aspire integration](./dotnet-aspire-integration.md#connection-configuration-with-aspire).
7171

7272
Add the extension to your project by installing the [NuGet package](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus), version 5.x.
7373

articles/azure-functions/functions-bindings-storage-blob.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Functions 1.x apps automatically have a reference the [Microsoft.Azure.WebJobs](
7878

7979
This version allows you to bind to types from [Azure.Storage.Blobs](/dotnet/api/azure.storage.blobs). Learn more about how these new types are different from `WindowsAzure.Storage` and `Microsoft.Azure.Storage` and how to migrate to them from the [Azure.Storage.Blobs Migration Guide](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/AzureStorageNetMigrationV12.md).
8080

81-
This version supports configuration of triggers and bindings through [.NET Aspire integration](./dotnet-isolated-process-guide.md#connection-configuration-with-aspire).
81+
This version supports configuration of triggers and bindings through [.NET Aspire integration](./dotnet-aspire-integration.md#connection-configuration-with-aspire).
8282

8383
Add the extension to your project by installing the [Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs NuGet package], version 5.x or later.
8484

articles/azure-functions/functions-bindings-storage-queue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Functions 1.x apps automatically have a reference the [Microsoft.Azure.WebJobs](
8080

8181
This version allows you to bind to types from [Azure.Storage.Queues](/dotnet/api/azure.storage.queues).
8282

83-
This version supports configuration of triggers and bindings through [.NET Aspire integration](./dotnet-isolated-process-guide.md#connection-configuration-with-aspire).
83+
This version supports configuration of triggers and bindings through [.NET Aspire integration](./dotnet-aspire-integration.md#connection-configuration-with-aspire).
8484

8585
Add the extension to your project by installing the [NuGet package](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues), version 5.x.
8686

includes/functions-bindings-event-hubs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Version 1.x of the Functions runtime doesn't require an extension.
5555

5656
[!INCLUDE [functions-bindings-supports-identity-connections-note](functions-bindings-supports-identity-connections-note.md)]
5757

58-
This version supports configuration of triggers and bindings through [.NET Aspire integration](../articles/azure-functions/dotnet-isolated-process-guide.md#connection-configuration-with-aspire).
58+
This version supports configuration of triggers and bindings through [.NET Aspire integration](../articles/azure-functions/dotnet-aspire-integration.md#connection-configuration-with-aspire).
5959

6060
Add the extension to your project by installing the [NuGet package](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.EventHubs), version 5.x.
6161

0 commit comments

Comments
 (0)