Skip to content

Commit 07546ea

Browse files
Merge pull request #213143 from cloudmelon/29092022-isolated-cancellationtoken
29092022 isolated cancellationtoken + ready-to-run
2 parents b37e2d2 + 636584e commit 07546ea

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to use a .NET isolated process to run your C# functions i
44

55
ms.service: azure-functions
66
ms.topic: conceptual
7-
ms.date: 07/06/2022
7+
ms.date: 09/29/2022
88
ms.custom: template-concept
99
recommendations: false
1010
#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.
@@ -136,6 +136,31 @@ The following is an example of a middleware implementation which reads the `Http
136136

137137
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).
138138

139+
## Cancellation tokens
140+
141+
A function can accept a [CancellationToken](/dotnet/api/system.threading.cancellationtoken) parameter, which enables the operating system to notify your code when the function is about to be terminated. You can use this notification to make sure the function doesn't terminate unexpectedly in a way that leaves data in an inconsistent state.
142+
143+
Cancellation tokens are supported in .NET functions when running in an isolated process. The following example shows how to use a cancellation token in a function:
144+
145+
:::code language="csharp" source="~/azure-functions-dotnet-worker/samples/Net7Worker/HttpFunction.cs" range="23-51":::
146+
147+
## ReadyToRun
148+
149+
You can compile your function app as [ReadyToRun binaries](/dotnet/core/deploying/ready-to-run). ReadyToRun is a form of ahead-of-time compilation that can improve startup performance to help reduce the impact of [cold-start](event-driven-scaling.md#cold-start) when running in a [Consumption plan](consumption-plan.md).
150+
151+
ReadyToRun is available in .NET 3.1, .NET 6 (both in-process and isolated process), and .NET 7, and it requires [version 3.0 or later](functions-versions.md) of the Azure Functions runtime.
152+
153+
To compile your project as ReadyToRun, update your project file by adding the `<PublishReadyToRun>` and `<RuntimeIdentifier>` elements. The following is the configuration for publishing to a Windows 32-bit function app.
154+
155+
```xml
156+
<PropertyGroup>
157+
<TargetFramework>net6.0</TargetFramework>
158+
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
159+
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
160+
<PublishReadyToRun>true</PublishReadyToRun>
161+
</PropertyGroup>
162+
```
163+
139164
## Execution context
140165

141166
.NET isolated passes a [FunctionContext] object to your function methods. This object lets you get an [ILogger] instance to write to the logs by calling the [GetLogger] method and supplying a `categoryName` string. To learn more, see [Logging](#logging).
@@ -251,7 +276,7 @@ This section describes the current state of the functional and behavioral differ
251276

252277
| Feature/behavior | In-process | Out-of-process |
253278
| ---- | ---- | ---- |
254-
| .NET versions | .NET Core 3.1<br/>.NET 6.0 | .NET 6.0<br/>.NET 7.0 (Preview)<br/>.NET Framework 4.8 (Preview) |
279+
| .NET versions | .NET Core 3.1<br/>.NET 6.0 | .NET 6.0<br/>.NET 7.0 (Preview)<br/>.NET Framework 4.8 (GA) |
255280
| Core packages | [Microsoft.NET.Sdk.Functions](https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/) | [Microsoft.Azure.Functions.Worker](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/)<br/>[Microsoft.Azure.Functions.Worker.Sdk](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk) |
256281
| Binding extension packages | [Microsoft.Azure.WebJobs.Extensions.*](https://www.nuget.org/packages?q=Microsoft.Azure.WebJobs.Extensions) | [Microsoft.Azure.Functions.Worker.Extensions.*](https://www.nuget.org/packages?q=Microsoft.Azure.Functions.Worker.Extensions) |
257282
| Durable Functions | [Supported](durable/durable-functions-overview.md) | [Supported (public preview)](https://github.com/microsoft/durabletask-dotnet#usage-with-azure-functions) |
@@ -263,9 +288,9 @@ This section describes the current state of the functional and behavioral differ
263288
| Middleware | Not supported | [Supported](#middleware) |
264289
| Logging | [ILogger] passed to the function<br/>[ILogger&lt;T&gt;] via dependency injection | [ILogger]/[ILogger&lt;T&gt;] obtained from [FunctionContext] or via [dependency injection](#dependency-injection)|
265290
| Application Insights dependencies | [Supported](functions-monitoring.md#dependencies) | [Supported (public preview)](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.ApplicationInsights) |
266-
| Cancellation tokens | [Supported](functions-dotnet-class-library.md#cancellation-tokens) | Not supported |
291+
| Cancellation tokens | [Supported](functions-dotnet-class-library.md#cancellation-tokens) | [Supported](#cancellation-tokens) |
267292
| Cold start times<sup>2</sup> | (Baseline) | Additionally includes process launch |
268-
| ReadyToRun | [Supported](functions-dotnet-class-library.md#readytorun) | _TBD_ |
293+
| ReadyToRun | [Supported](functions-dotnet-class-library.md#readytorun) | [Supported](#readytorun) |
269294

270295
<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.
271296

articles/azure-functions/functions-dotnet-class-library.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,23 @@ If you install the Core Tools using the Windows installer (MSI) package or by us
215215

216216
## ReadyToRun
217217

218-
You can compile your function app as [ReadyToRun binaries](/dotnet/core/whats-new/dotnet-core-3-0#readytorun-images). ReadyToRun is a form of ahead-of-time compilation that can improve startup performance to help reduce the impact of [cold-start](event-driven-scaling.md#cold-start) when running in a [Consumption plan](consumption-plan.md).
218+
You can compile your function app as [ReadyToRun binaries](/dotnet/core/deploying/ready-to-run). ReadyToRun is a form of ahead-of-time compilation that can improve startup performance to help reduce the impact of [cold-start](event-driven-scaling.md#cold-start) when running in a [Consumption plan](consumption-plan.md).
219219

220-
ReadyToRun is available in .NET 3.0 and requires [version 3.0 of the Azure Functions runtime](functions-versions.md).
220+
ReadyToRun is available in .NET 3.1 and .NET 6 (in-proc and isolated) and .NET 7 and requires [version 3.0 or 4.0 of the Azure Functions runtime](functions-versions.md).
221221

222222
To compile your project as ReadyToRun, update your project file by adding the `<PublishReadyToRun>` and `<RuntimeIdentifier>` elements. The following is the configuration for publishing to a Windows 32-bit function app.
223223

224224
```xml
225225
<PropertyGroup>
226-
<TargetFramework>netcoreapp3.1</TargetFramework>
227-
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
226+
<TargetFramework>net6.0</TargetFramework>
227+
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
228228
<PublishReadyToRun>true</PublishReadyToRun>
229229
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
230230
</PropertyGroup>
231231
```
232232

233233
> [!IMPORTANT]
234-
> ReadyToRun currently doesn't support cross-compilation. You must build your app on the same platform as the deployment target. Also, pay attention to the "bitness" that is configured in your function app. For example, if your function app in Azure is Windows 64-bit, you must compile your app on Windows with `win-x64` as the [runtime identifier](/dotnet/core/rid-catalog).
234+
> Starting in .NET 6, support for Composite ReadyToRun compilation has been added. Check out [ReadyToRun Cross platform and architecture restrictions](/dotnet/core/deploying/ready-to-run).
235235
236236
You can also build your app with ReadyToRun from the command line. For more information, see the `-p:PublishReadyToRun=true` option in [`dotnet publish`](/dotnet/core/tools/dotnet-publish).
237237

includes/functions-dotnet-supported-versions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ The following table shows the highest level of .NET Core or .NET Framework that
1717

1818
| Functions runtime version | In-process<br/>([.NET class library](../articles/azure-functions/functions-dotnet-class-library.md)) | Out-of-process<br/>([.NET Isolated](../articles/azure-functions/dotnet-isolated-process-guide.md)) |
1919
| ---- | ---- | --- |
20-
| Functions 4.x | .NET 6.0 | .NET 6.0<br/>.NET 7.0 (preview)<br/>.NET Framework 4.8 (preview)<sup>1</sup> |
21-
| Functions 3.x | .NET Core 3.1 | .NET 5.0<sup>2</sup> |
20+
| Functions 4.x | .NET 6.0 | .NET 6.0<br/>.NET 7.0 (preview)<br/>.NET Framework 4.8 (GA)<sup>1</sup> |
21+
| Functions 3.x | .NET Core 3.1 | .NET 5.0 <sup>2</sup> |
2222
| Functions 2.x | .NET Core 2.1<sup>3</sup> | n/a |
2323
| Functions 1.x | .NET Framework 4.8 | n/a |
2424

2525

26-
<sup>1</sup> Build process also requires [.NET 6 SDK](https://dotnet.microsoft.com/download). Support for .NET Framework 4.8 is in preview.
26+
<sup>1</sup> Build process also requires [.NET 6 SDK](https://dotnet.microsoft.com/download). Support for .NET Framework 4.8 is in GA.
2727

2828
<sup>2</sup> Build process also requires [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download).
2929

0 commit comments

Comments
 (0)