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-isolated-process-guide.md
+63-7Lines changed: 63 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Guide for running C# Azure Functions in an isolated worker process
3
3
description: Learn how to use the .NET isolated worker model to run your C# functions in Azure, which lets you run your functions on currently supported versions of .NET and .NET Framework.
4
4
ms.service: azure-functions
5
5
ms.topic: conceptual
6
-
ms.date: 12/13/2023
6
+
ms.date: 09/05/2024
7
7
ms.custom:
8
8
- template-concept
9
9
- devx-track-dotnet
@@ -63,6 +63,12 @@ The following packages are required to run your .NET functions in an isolated wo
63
63
+[Microsoft.Azure.Functions.Worker]
64
64
+[Microsoft.Azure.Functions.Worker.Sdk]
65
65
66
+
#### Version 2.x (Preview)
67
+
68
+
The 2.x versions of the core packages change the supported framework assets and bring in support for new .NET APIs from these later versions. When using .NET 9 (Preview) or later, your app needs to reference version 2.0.0-preview1 or later of both packages.
69
+
70
+
The 2.0.0-preview1 versions are compatible with code written against version 1.x. However, during the preview period, newer versions may introduce behavior changes that could influence the code you write.
71
+
66
72
### Extension packages
67
73
68
74
Because .NET isolated worker process functions use different binding types, they require a unique set of binding extension packages.
@@ -123,7 +129,7 @@ Dependency injection is simplified when compared to .NET in-process functions, w
123
129
For a .NET isolated process app, you use the .NET standard way of call [ConfigureServices] on the host builder and use the extension methods on [IServiceCollection] to inject specific services.
124
130
125
131
The following example injects a singleton service dependency:
126
-
132
+
127
133
```csharp
128
134
.ConfigureServices(services=>
129
135
{
@@ -138,7 +144,9 @@ This code requires `using Microsoft.Extensions.DependencyInjection;`. To learn m
138
144
Dependency injection can be used to interact with other Azure services. You can inject clients from the [Azure SDK for .NET](/dotnet/azure/sdk/azure-sdk-for-dotnet) using the [Microsoft.Extensions.Azure](https://www.nuget.org/packages/Microsoft.Extensions.Azure) package. After installing the package, [register the clients](/dotnet/azure/sdk/dependency-injection#register-clients) by calling `AddAzureClients()` on the service collection in `Program.cs`. The following example configures a [named client](/dotnet/azure/sdk/dependency-injection#configure-multiple-service-clients-with-different-names) for Azure Blobs:
139
145
140
146
```csharp
147
+
usingMicrosoft.Azure.Functions.Worker;
141
148
usingMicrosoft.Extensions.Azure;
149
+
usingMicrosoft.Extensions.DependencyInjection;
142
150
usingMicrosoft.Extensions.Hosting;
143
151
144
152
varhost=newHostBuilder()
@@ -194,7 +202,7 @@ The [`ILogger<T>`][ILogger<T>] in this example was also obtained through d
194
202
195
203
### Middleware
196
204
197
-
.NET isolated also supports middleware registration, again by using a model similar to what exists in ASP.NET. This model gives you the ability to inject logic into the invocation pipeline, and before and after functions execute.
205
+
The isolated worker model also supports middleware registration, again by using a model similar to what exists in ASP.NET. This model gives you the ability to inject logic into the invocation pipeline, and before and after functions execute.
198
206
199
207
The [ConfigureFunctionsWorkerDefaults] extension method has an overload that lets you register your own middleware, as you can see in the following example.
200
208
@@ -225,6 +233,10 @@ The isolated worker model uses `System.Text.Json` by default. You can customize
225
233
The following example shows this using `ConfigureFunctionsWebApplication`, but it will also work for `ConfigureFunctionsWorkerDefaults`:
@@ -239,11 +251,17 @@ var host = new HostBuilder()
239
251
});
240
252
})
241
253
.Build();
254
+
255
+
host.Run();
242
256
```
243
257
244
258
You might wish to instead use JSON.NET (`Newtonsoft.Json`) for serialization. To do this, you would install the [`Microsoft.Azure.Core.NewtonsoftJson`](https://www.nuget.org/packages/Microsoft.Azure.Core.NewtonsoftJson) package. Then, in your service registration, you would reassign the `Serializer` property on the `WorkerOptions` configuration. The following example shows this using `ConfigureFunctionsWebApplication`, but it will also work for `ConfigureFunctionsWorkerDefaults`:
@@ -440,6 +460,10 @@ To enable ASP.NET Core integration for HTTP:
440
460
ASP.NETCorehasitsownserializationlayer, anditisnotaffectedby [customizinggeneralserializationconfiguration](#customizing-json-serialization). Tocustomizetheserializationbehaviorusedfor your HTTP triggers, you need to include an `.AddMvc()` callaspartofserviceregistration. Thereturned `IMvcBuilder` canbeusedtomodifyASP.NETCore's JSON serialization settings. The following example shows how to configure JSON.NET (`Newtonsoft.Json`) for serialization using this approach:
441
461
442
462
```csharp
463
+
usingMicrosoft.Azure.Functions.Worker;
464
+
usingMicrosoft.Extensions.DependencyInjection;
465
+
usingMicrosoft.Extensions.Hosting;
466
+
443
467
varhost=newHostBuilder()
444
468
.ConfigureFunctionsWebApplication()
445
469
.ConfigureServices(services=>
@@ -486,7 +510,7 @@ public class MyFunction {
486
510
487
511
The logger can also be obtained from a [FunctionContext] object passed to your function. Call the [GetLogger<T>] or [GetLogger] method, passing a string value that is the name for the category in which the logs are written. The category is usually the name of the specific function from which the logs are written. To learn more about categories, see the [monitoring article](functions-monitoring.md#log-levels-and-categories).
488
512
489
-
Use the methods of [`ILogger<T>`][ILogger<T>] and [`ILogger`][ILogger] to write various log levels, such as `LogWarning` or `LogError`. To learn more about log levels, see the [monitoring article](functions-monitoring.md#log-levels-and-categories). You can customize the log levels for components added to your code by registering filters as part of the `HostBuilder` configuration:
513
+
Use the methods of [`ILogger<T>`][ILogger<T>] and [`ILogger`][ILogger] to write various log levels, such as `LogWarning` or `LogError`. To learn more about log levels, see the [monitoring article](functions-monitoring.md#log-levels-and-categories). You can customize the log levels for components added to your code by registering filters:
490
514
491
515
```csharp
492
516
usingMicrosoft.Azure.Functions.Worker;
@@ -514,12 +538,17 @@ var host = new HostBuilder()
514
538
As part of configuring your app in `Program.cs`, you can also define the behavior for how errors are surfaced to your logs. By default, exceptions thrown by your code can end up wrapped in an `RpcException`. To remove this extra layer, set the `EnableUserCodeException` property to "true" as part of configuring the builder:
@@ -570,6 +599,11 @@ The call to `ConfigureFunctionsApplicationInsights()` adds an `ITelemetryModule`
570
599
The rest of your application continues to work with `ILogger` and `ILogger<T>`. However, by default, the Application Insights SDK adds a logging filter that instructs the logger to capture only warnings and more severe logs. If you want to disable this behavior, remove the filter rule as part of service configuration:
571
600
572
601
```csharp
602
+
usingMicrosoft.Azure.Functions.Worker;
603
+
usingMicrosoft.Extensions.DependencyInjection;
604
+
usingMicrosoft.Extensions.Hosting;
605
+
usingMicrosoft.Extensions.Logging;
606
+
573
607
varhost=newHostBuilder()
574
608
.ConfigureFunctionsWorkerDefaults()
575
609
.ConfigureServices(services=> {
@@ -633,7 +667,7 @@ Placeholders are a platform capability that improves cold start for apps targeti
633
667
az functionapp config set -g <groupName> -n <appName> --net-framework-version <framework>
634
668
```
635
669
636
-
In this example, also replace `<framework>` with the appropriate version string, such as `v8.0`, `v7.0`, or `v6.0`, according to your target .NET version.
670
+
In this example, also replace `<framework>` with the appropriate version string, such as `v8.0`, according to your target .NET version.
637
671
638
672
1. Make sure that your function app is configured to use a 64-bit process, which you can do by using this [az functionapp config set](/cli/azure/functionapp/config#az-functionapp-config-set) command:
639
673
@@ -822,7 +856,15 @@ Before a generally available release, a .NET version might be released in a _Pre
822
856
823
857
While it might be possible to target a given release from a local Functions project, function apps hosted in Azure might not have that release available. Azure Functions can only be used with Preview or Go-live releases noted in this section.
824
858
825
-
Azure Functions doesn't currently work with any "Preview" or "Go-live" .NET releases. See [Supported versions][supported-versions] for a list of generally available releases that you can use.
859
+
Azure Functions currently can be used with the following "Preview" or "Go-live" .NET releases:
860
+
861
+
| Operating system | .NET preview version |
862
+
| - | - |
863
+
| Linux | .NET 9 Preview 7<sup>1</sup> |
864
+
865
+
<sup>1</sup> To successfully target .NET 9, your project needs to reference the [2.x versions of the core packages](#version-2x-preview). If using Visual Studio, .NET 9 requires version 17.12 or later.
866
+
867
+
See [Supported versions][supported-versions] for a list of generally available releases that you can use.
826
868
827
869
### Using a preview .NET SDK
828
870
@@ -831,12 +873,26 @@ To use Azure Functions with a preview version of .NET, you need to update your p
831
873
1. Installing the relevant .NET SDK version in your development
832
874
1. Changing the `TargetFramework` setting in your `.csproj` file
833
875
834
-
When deploying to a function app in Azure, you also need to ensure that the framework is made available to the app. To do so on Windows, you can use the following CLI command. Replace `<groupName>` with the name of the resource group, and replace `<appName>` with the name of your function app. Replace `<framework>` with the appropriate version string, such as `v8.0`.
876
+
When you deploy to your function app in Azure, you also need to ensure that the framework is made available to the app. During the preview period, some tools and experiences may not surface the new preview version as an option. If you do not see the preview version included in the Azure Portal, for example, you can use the REST API, Bicep templates, or the Azure CLI to configure the version manually.
877
+
878
+
### [Windows](#tab/windows)
879
+
880
+
For apps hosted on Windows, use the following Azure CLI command. Replace `<groupName>` with the name of the resource group, and replace `<appName>` with the name of your function app. Replace `<framework>` with the appropriate version string, such as `v8.0`.
835
881
836
882
```azurecli
837
883
az functionapp config set -g <groupName> -n <appName> --net-framework-version <framework>
838
884
```
839
885
886
+
### [Linux](#tab/linux)
887
+
888
+
For apps hosted on Linux, use the following Azure CLI command. Replace `<groupName>` with the name of the resource group, and replace `<appName>` with the name of your function app. Replace `<version>` with the appropriate version string, such as `8.0`.
889
+
890
+
```azurecli
891
+
az functionapp config set -g <groupName> -n <appName> --linux-fx-version "dotnet-isolated|<version>"
892
+
```
893
+
894
+
---
895
+
840
896
### Considerations for using .NET preview versions
841
897
842
898
Keep these considerations in mind when using Functions with preview versions of .NET:
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-core-tools-reference.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ When you supply `<PROJECT_FOLDER>`, the project is created in a new folder with
49
49
|**`--model`**| Sets the desired programming model for a target language when more than one model is available. Supported options are `V1` and `V2` for Python and `V3` and `V4` for Node.js. For more information, see the [Python developer guide](functions-reference-python.md#programming-model) and the [Node.js developer guide](functions-reference-node.md), respectively. |
50
50
|**`--source-control`**| Controls whether a git repository is created. By default, a repository isn't created. When `true`, a repository is created. |
51
51
|**`--worker-runtime`**| Sets the language runtime for the project. Supported values are: `csharp`, `dotnet`, `dotnet-isolated`, `javascript`,`node` (JavaScript), `powershell`, `python`, and `typescript`. For Java, use [Maven](functions-reference-java.md#create-java-functions). To generate a language-agnostic project with just the project files, use `custom`. When not set, you're prompted to choose your runtime during initialization. |
52
-
|**`--target-framework`**| Sets the target framework for the function app project. Valid only with `--worker-runtime dotnet-isolated`. Supported values are: `net6.0` (default), `net7.0`, `net8.0`, and `net48` (.NET Framework 4.8). |
52
+
|**`--target-framework`**| Sets the target framework for the function app project. Valid only with `--worker-runtime dotnet-isolated`. Supported values are: `net9.0` (preview), `net8.0` (default), `net6.0`, and `net48` (.NET Framework 4.8). |
| 4.x | GA |**_Recommended runtime version for functions in all languages._** Check out [Supported language versions](#languages). |
17
-
| 1.x | GA ([support ends September 14, 2026](https://aka.ms/azure-functions-retirements/hostv1)) | Supported only for C# apps that must use .NET Framework. This version is in maintenance mode, with enhancements provided only in later versions. **Support will end for version 1.x on September 14, 2026.** We highly recommend you [migrate your apps to version 4.x](migrate-version-1-version-4.md?pivots=programming-language-csharp), which supports .NET Framework 4.8, .NET 6, and .NET 8.|
17
+
| 1.x | GA ([support ends September 14, 2026](https://aka.ms/azure-functions-retirements/hostv1)) | Supported only for C# apps that must use .NET Framework. This version is in maintenance mode, with enhancements provided only in later versions. **Support will end for version 1.x on September 14, 2026.** We highly recommend you [migrate your apps to version 4.x](migrate-version-1-version-4.md?pivots=programming-language-csharp), which supports .NET Framework 4.8, .NET 6, .NET 8, and .NET 9.|
18
18
19
19
> [!IMPORTANT]
20
20
> As of December 13, 2022, function apps running on versions 2.x and 3.x of the Azure Functions runtime have reached the end of extended support. For more information, see [Retired versions](#retired-versions).
@@ -131,7 +131,7 @@ In Visual Studio, you select the runtime version when you create a project. Azur
131
131
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
132
132
```
133
133
134
-
You can choose `net8.0`, `net6.0`, or `net48` as the target framework if you are using the [isolated worker model](dotnet-isolated-process-guide.md). If you are using the [in-process model](./functions-dotnet-class-library.md), you can choose `net8.0` or `net6.0`, and you must include the `Microsoft.NET.Sdk.Functions` extension set to at least `4.4.0`.
134
+
If you are using the [isolated worker model](dotnet-isolated-process-guide.md), you can choose,`net8.0`, `net6.0`, or `net48` as the target framework. You can also choose to use [preview support](./dotnet-isolated-process-guide.md#preview-net-versions) for `net9.0`. If you are using the [in-process model](./functions-dotnet-class-library.md), you can choose `net8.0` or `net6.0`, and you must include the `Microsoft.NET.Sdk.Functions` extension set to at least `4.4.0`.
135
135
136
136
.NET 7 was previously supported on the isolated worker model but reached the end of official support on [May 14, 2024][dotnet-policy].
Copy file name to clipboardExpand all lines: articles/azure-functions/migrate-dotnet-to-isolated-model.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ On version 4.x of the Functions runtime, your .NET function app targets .NET 6 w
54
54
> [!TIP]
55
55
> **We recommend upgrading to .NET 8 on the isolated worker model.** This provides a quick migration path to the fully released version with the longest support window from .NET.
56
56
57
-
This guide doesn't present specific examples for .NET 7 or .NET 6. If you need to target these versions, you can adapt the .NET 8 examples.
57
+
This guide doesn't present specific examples for .NET 9 (Preview) or .NET 6. If you need to target these versions, you can adapt the .NET 8 examples.
Copy file name to clipboardExpand all lines: articles/azure-functions/update-language-versions.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,9 @@ Use these steps to update the project on your local computer:
37
37
38
38
1. Ensure you have [installed the target version of the .NET SDK](https://dotnet.microsoft.com/download/dotnet).
39
39
40
-
1. Update your references to the latest stable versions of: [Microsoft.Azure.Functions.Worker](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/) and [Microsoft.Azure.Functions.Worker.Sdk](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/).
40
+
If you are targeting a preview version, consult the [Functions guidance for preview .NET versions](./dotnet-isolated-process-guide.md#preview-net-versions) to ensure that the version is supported. Additional steps may be required for .NET previews.
41
+
42
+
1. Update your references to the latest versions of: [Microsoft.Azure.Functions.Worker](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/) and [Microsoft.Azure.Functions.Worker.Sdk](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/).
41
43
42
44
1. Update your project's target framework to the new version. For C# projects, you must update the `<TargetFramework>` element in the `.csproj` file. See [Target frameworks](/dotnet/standard/frameworks) for specifics related to the chosen version.
@@ -20,7 +21,7 @@ When you migrate your function app, you have the opportunity to choose the targe
20
21
21
22
<sup>2</sup> Support ends for the in-process model on November 10, 2026. For more information, see [this support announcement](https://aka.ms/azure-functions-retirements/in-process-model). For continued full support, you should [migrate your apps to the isolated worker model](../articles/azure-functions/migrate-dotnet-to-isolated-model.md).
22
23
23
-
<!-- <sup>2</sup> See [Preview .NET versions in the isolated worker model](../articles/azure-functions/dotnet-isolated-process-guide.md#preview-net-versions) for details on support, current restrictions, and instructions for using the preview version.-->
24
+
<sup>3</sup> See [Preview .NET versions in the isolated worker model](../articles/azure-functions/dotnet-isolated-process-guide.md#preview-net-versions) for details on support, current restrictions, and instructions for using the preview version.
24
25
25
26
[.NET Official Support Policy]: https://dotnet.microsoft.com/platform/support/policy
0 commit comments