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
+62-7Lines changed: 62 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@ description: Learn how to use a .NET isolated process to run your C# functions i
4
4
5
5
ms.service: azure-functions
6
6
ms.topic: conceptual
7
-
ms.date: 06/01/2021
7
+
ms.date: 05/12/2022
8
8
ms.custom: template-concept
9
9
recommendations: false
10
10
#Customer intent: As a developer, I need to know how to create functions that run in an isolated process so that I can run my function code on current (not LTS) releases of .NET.
11
11
---
12
12
13
13
# Guide for running C# Azure Functions in an isolated process
14
14
15
-
This article is an introduction to using C# to develop .NET isolated process functions, which run out-of-process in Azure Functions. Running out-of-process lets you decouple your function code from the Azure Functions runtime. Isolated process C# functions run on both .NET 5.0 and .NET 6.0. [In-process C# class library functions](functions-dotnet-class-library.md) aren't supported on .NET 5.0.
15
+
This article is an introduction to using C# to develop .NET isolated process functions, which run out-of-process in Azure Functions. Running out-of-process lets you decouple your function code from the Azure Functions runtime. Isolated process C# functions run on .NET 5.0, .NET 6.0, and .NET Framework 4.8 (preview support). [In-process C# class library functions](functions-dotnet-class-library.md) aren't supported on .NET 5.0.
16
16
17
17
| Getting started | Concepts| Samples |
18
18
|--|--|--|
@@ -26,7 +26,7 @@ Because these functions run in a separate process, there are some [feature and f
26
26
27
27
### Benefits of running out-of-process
28
28
29
-
When running out-of-process, your .NET functions can take advantage of the following benefits:
29
+
When your .NET functions run out-of-process, you can take advantage of the following benefits:
30
30
31
31
+ Fewer conflicts: because the functions run in a separate process, assemblies used in your app won't conflict with different version of the same assemblies used by the host process.
32
32
+ Full control of the process: you control the start-up of the app and can control the configurations used and the middleware started.
@@ -42,13 +42,16 @@ A .NET isolated function project is basically a .NET console app project that ta
+ C# project file (.csproj) that defines the project and dependencies.
44
44
+ Program.cs file that's the entry point for the app.
45
+
+ Any code files [defining your functions](#bindings).
45
46
47
+
For complete examples, see the [.NET 6 isolated sample project](https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/FunctionApp) and the [.NET Framework 4.8 isolated sample project](https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/NetFxWorker).
48
+
46
49
> [!NOTE]
47
50
> To be able to publish your isolated function project to either a Windows or a Linux function app in Azure, you must set a value of `dotnet-isolated` in the remote [FUNCTIONS_WORKER_RUNTIME](functions-app-settings.md#functions_worker_runtime) application setting. To support [zip deployment](deployment-zip-push.md) and [running from the deployment package](run-functions-from-deployment-package.md) on Linux, you also need to update the `linuxFxVersion` site config setting to `DOTNET-ISOLATED|6.0`. To learn more, see [Manual version updates on Linux](set-runtime-version.md#manual-version-updates-on-linux).
48
51
49
52
## Package references
50
53
51
-
When running out-of-process, your .NET project uses a unique set of packages, which implement both core functionality and binding extensions.
54
+
When your functions run out-of-process, your .NET project uses a unique set of packages, which implement both core functionality and binding extensions.
52
55
53
56
### Core packages
54
57
@@ -65,7 +68,7 @@ You'll find these extension packages under [Microsoft.Azure.Functions.Worker.Ext
65
68
66
69
## Start-up and configuration
67
70
68
-
When using .NET isolated functions, you have access to the start-up of your function app, which is usually in Program.cs. You're responsible for creating and starting your own host instance. As such, you also have direct access to the configuration pipeline for your app. When running out-of-process, you can much more easily add configurations, inject dependencies, and run your own middleware.
71
+
When using .NET isolated functions, you have access to the start-up of your function app, which is usually in Program.cs. You're responsible for creating and starting your own host instance. As such, you also have direct access to the configuration pipeline for your app. When you run your functions out-of-process, you can much more easily add configurations, inject dependencies, and run your own middleware.
69
72
70
73
The following code shows an example of a [HostBuilder] pipeline:
71
74
@@ -77,6 +80,9 @@ A [HostBuilder] is used to build and return a fully initialized [IHost] instance
> If your project targets .NET Framework 4.8, you also need to add `FunctionsDebugger.Enable();` before creating the HostBuilder. It should be the first line of your `Main()` method. See [Debugging when targeting .NET Framework](#debugging-when-targeting-net-framework) for more information.
85
+
80
86
### Configuration
81
87
82
88
The [ConfigureFunctionsWorkerDefaults] method is used to add the settings required for the function app to run out-of-process, which includes the following functionality:
@@ -128,7 +134,7 @@ The following is an example of a middleware implementation which reads the `Http
For a more complete example of using custom middlewares in your function app, see the [custom middleware reference sample](https://github.com/Azure/azure-functions-dotnet-worker/blob/main/samples/CustomMiddleware).
137
+
For a more complete example of using custom middleware in your function app, see the [custom middleware reference sample](https://github.com/Azure/azure-functions-dotnet-worker/blob/main/samples/CustomMiddleware).
132
138
133
139
## Execution context
134
140
@@ -190,13 +196,62 @@ Use various methods of [ILogger] to write various log levels, such as `LogWarnin
190
196
191
197
An [ILogger] is also provided when using [dependency injection](#dependency-injection).
192
198
199
+
## Debugging when targeting .NET Framework
200
+
201
+
If your isolated project targets .NET Framework 4.8, the current preview scope requires manual steps to enable debugging. These steps are not required if using another target framework.
202
+
203
+
Your app should start with a call to `FunctionsDebugger.Enable();` as its first operation. This occurs in the `Main()` method before initializing a HostBuilder. Your `Program.cs` file should look similar to the following:
204
+
205
+
```csharp
206
+
usingSystem;
207
+
usingSystem.Diagnostics;
208
+
usingMicrosoft.Extensions.Hosting;
209
+
usingMicrosoft.Azure.Functions.Worker;
210
+
usingNetFxWorker;
211
+
212
+
namespaceMyDotnetFrameworkProject
213
+
{
214
+
internalclassProgram
215
+
{
216
+
staticvoidMain(string[] args)
217
+
{
218
+
FunctionsDebugger.Enable();
219
+
220
+
varhost=newHostBuilder()
221
+
.ConfigureFunctionsWorkerDefaults()
222
+
.Build();
223
+
224
+
host.Run();
225
+
}
226
+
}
227
+
}
228
+
```
229
+
230
+
Next, you need to manually attach to the process using a .NET Framework debugger. Visual Studio doesn't do this automatically for isolated process .NET Framework apps yet, and the "Start Debugging" operation should be avoided.
231
+
232
+
In your project directory (or its build output directory), run:
233
+
234
+
```azurecli
235
+
func host start --dotnet-isolated-debug
236
+
```
237
+
238
+
This will start your worker, and the process will stop with the following message:
239
+
240
+
```azurecli
241
+
Azure Functions .NET Worker (PID: <process id>) initialized in debug mode. Waiting for debugger to attach...
242
+
```
243
+
244
+
Where `<process id>` is the ID for your worker process. You can now use Visual Studio to manually attach to the process. For instructions on this operation, see [How to attach to a running process](/visualstudio/debugger/attach-to-running-processes-with-the-visual-studio-debugger#BKMK_Attach_to_a_running_process).
245
+
246
+
Once the debugger is attached, the process execution will resume and you will be able to debug.
247
+
193
248
## Differences with .NET class library functions
194
249
195
250
This section describes the current state of the functional and behavioral differences running on out-of-process compared to .NET class library functions running in-process:
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-dotnet-class-library.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
2
title: Develop C# class library functions using Azure Functions
3
-
description: Understand how to use C# to develop and publish code as class libraries that runs in-process with the Azure Functions runtime.
3
+
description: Understand how to use C# to develop and publish code as class libraries that run in-process with the Azure Functions runtime.
4
4
5
5
ms.topic: conceptual
6
6
ms.devlang: csharp
7
7
ms.custom: devx-track-csharp
8
-
ms.date: 02/08/2022
8
+
ms.date: 05/12/2022
9
9
10
10
---
11
11
# Develop C# class library functions using Azure Functions
@@ -15,7 +15,7 @@ ms.date: 02/08/2022
15
15
This article is an introduction to developing Azure Functions by using C# in .NET class libraries.
16
16
17
17
>[!IMPORTANT]
18
-
>This article supports .NET class library functions that run in-process with the runtime. Functions also supports .NET 5.x by running your C# functions out-of-process and isolated from the runtime. To learn more, see [.NET isolated process functions](dotnet-isolated-process-guide.md).
18
+
>This article supports .NET class library functions that run in-process with the runtime. Your C# functions can also run out-of-process and isolated from the Functions runtime. The isolated model is the only way to run .NET 5.x and the preview of .NET Framework 4.8 using recent versions of the Functions runtime. To learn more, see [.NET isolated process functions](dotnet-isolated-process-guide.md).
19
19
20
20
As a C# developer, you may also be interested in one of the following articles:
21
21
@@ -170,7 +170,7 @@ The generated *function.json* file includes a `configurationSource` property tha
170
170
171
171
The *function.json* file generation is performed by the NuGet package [Microsoft\.NET\.Sdk\.Functions](https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions).
172
172
173
-
The same package is used for both version 1.x and 2.x of the Functions runtime. The target framework is what differentiates a 1.x project from a 2.x project. Here are the relevant parts of *.csproj* files, showing different target frameworks with the same `Sdk` package:
173
+
The same package is used for both version 1.x and 2.x of the Functions runtime. The target framework is what differentiates a 1.x project from a 2.x project. Here are the relevant parts of the `.csproj` files, showing different target frameworks with the same `Sdk` package:
0 commit comments