Skip to content

Commit 52f339d

Browse files
restructuring migration topics
1 parent 7fad90f commit 52f339d

7 files changed

+332
-149
lines changed

articles/azure-functions/migrate-version-1-version-4.md

Lines changed: 111 additions & 100 deletions
Large diffs are not rendered by default.

articles/azure-functions/migrate-version-3-version-4.md

Lines changed: 133 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This article shows you how to upgrade your existing function apps r
44
ms.service: azure-functions
55
ms.custom: devx-track-dotnet, devx-track-extended-java, devx-track-js, devx-track-python
66
ms.topic: how-to
7-
ms.date: 11/05/2022
7+
ms.date: 07/31/2023
88
zone_pivot_groups: programming-languages-set-functions
99
---
1010

@@ -23,6 +23,12 @@ Azure Functions version 4.x is highly backwards compatible to version 3.x. Most
2323
2424
This article walks you through the process of safely migrating your function app to run on version 4.x of the Functions runtime. Because project upgrade instructions are language dependent, make sure to choose your development language from the selector at the [top of the article](#top).
2525

26+
## Identify function apps to upgrade
27+
28+
Use the following PowerShell script to generate a list of function apps in your subscription that currently target versions 2.x or 3.x:
29+
30+
:::code language="powershell" source="~/functions-azure-product/EOLHostMigration/CheckEOLAppsPerAzSub.ps1" range="4-20":::
31+
2632
::: zone pivot="programming-language-csharp"
2733

2834
## Choose your target .NET version
@@ -40,33 +46,22 @@ On version 3.x of the Functions runtime, your C# function app targets .NET Core
4046

4147
## Prepare for migration
4248

43-
Before you upgrade your app to version 4.x of the Functions runtime, you should do the following tasks:
49+
If you haven't already, identify the list of apps that need to be migrated in your current Azure Subscription by using the [Azure PowerShell](#identify-function-apps-to-upgrade).
4450

45-
* Review the list of [breaking changes between 3.x and 4.x](#breaking-changes-between-3x-and-4x).
46-
* [Run the pre-upgrade validator](#run-the-pre-upgrade-validator).
47-
* Identify the list of v2&v3 Function Apps in your current Azure Subscription by using the [Azure PowerShell](#identify-function-apps-to-upgrade).
48-
* When possible, [upgrade your local project environment to version 4.x](#upgrade-your-local-project). Fully test your app locally using version 4.x of the [Azure Functions Core Tools](functions-run-local.md).
49-
* Upgrade your function app in Azure to the new version. If you need to minimize downtime, consider using a [staging slot](functions-deployment-slots.md) to test and verify your migrated app in Azure on the new runtime version. You can then deploy your app with the updated version settings to the production slot. For more information, see [Migrate using slots](#upgrade-using-slots).
50-
* Republished your migrated project to the upgraded function app. When you use Visual Studio to publish a version 4.x project to an existing function app at a lower version, you're prompted to let Visual Studio upgrade the function app to version 4.x during deployment. This upgrade uses the same process defined in [Migrate without slots](#upgrade-without-slots).
51+
Before you upgrade an app to version 4.x of the Functions runtime, you should do the following tasks:
5152

52-
## Run the pre-upgrade validator
53+
1. Review the list of [breaking changes between 3.x and 4.x](#breaking-changes-between-3x-and-4x).
54+
1. Complete the steps in [Upgrade your local project](#upgrade-your-local-project) to migrate your local project to version 4.x.
55+
1. After migrating your project, fully test the app locally using version 4.x of the [Azure Functions Core Tools](functions-run-local.md).
56+
1. [Run the pre-upgrade validator](#run-the-pre-upgrade-validator) on the app hosted in Azure, and resolve any identified issues.
57+
1. Upgrade your function app in Azure to the new version. If you need to minimize downtime, consider using a [staging slot](functions-deployment-slots.md) to test and verify your migrated app in Azure on the new runtime version. You can then deploy your app with the updated version settings to the production slot. For more information, see [Migrate using slots](#upgrade-using-slots).
58+
1. Publish your migrated project to the upgraded function app.
5359

54-
Azure Functions provides a pre-upgrade validator to help you identify potential issues when migrating your function app to 4.x. To run the pre-upgrade validator:
55-
56-
1. In the [Azure portal](https://portal.azure.com), navigate to your function app.
60+
::: zone pivot="programming-language-csharp"
5761

58-
1. Open the **Diagnose and solve problems** page.
59-
60-
1. In **Function App Diagnostics**, start typing `Functions 4.x Pre-Upgrade Validator` and then choose it from the list.
62+
When you use Visual Studio to publish a version 4.x project to an existing function app at a lower version, you're prompted to let Visual Studio upgrade the function app to version 4.x during deployment. This upgrade uses the same process defined in [Migrate without slots](#upgrade-without-slots).
6163

62-
1. After validation completes, review the recommendations and address any issues in your app. If you need to make changes to your app, make sure to validate the changes against version 4.x of the Functions runtime, either [locally using Azure Functions Core Tools v4](#upgrade-your-local-project) or by [using a staging slot](#upgrade-using-slots).
63-
64-
65-
## Identify function apps to upgrade
66-
67-
Use the following PowerShell script to generate a list of function apps in your subscription that currently target versions 2.x or 3.x:
68-
69-
:::code language="powershell" source="~/functions-azure-product/EOLHostMigration/CheckEOLAppsPerAzSub.ps1" range="4-20":::
64+
::: zone-end
7065

7166
## Upgrade your local project
7267

@@ -109,73 +104,150 @@ The following example is a .csproj project file that uses .NET Core 3.1 on versi
109104

110105
Use one of the following procedures to update this XML file to run in Functions version 4.x:
111106

107+
# [.NET 6 (isolated)](#tab/net6-isolated)
108+
109+
[!INCLUDE [functions-dotnet-migrate-project-v4-isolated](../../includes/functions-dotnet-migrate-project-v4-isolated.md)]
110+
112111
# [.NET 6 (in-process)](#tab/net6-in-proc)
113112

114113
[!INCLUDE [functions-dotnet-migrate-project-v4-inproc](../../includes/functions-dotnet-migrate-project-v4-inproc.md)]
115114

115+
# [.NET 7](#tab/net7)
116+
117+
[!INCLUDE [functions-dotnet-migrate-project-v4-isolated-2](../../includes/functions-dotnet-migrate-project-v4-isolated-2.md)]
118+
119+
# [.NET Framework 4.8](#tab/v4)
120+
121+
[!INCLUDE [functions-dotnet-migrate-project-v4-isolated-net-framework](../../includes/functions-dotnet-migrate-project-v4-isolated-net-framework.md)]
122+
123+
---
124+
125+
### Package and namespace changes
126+
127+
Based on the model you are migrating to, you may need to upgrade or change the packages your application references. When you adopt the target packages, you may then need to update the namespace of using statements and some types you reference. You can see the effect of these namespace changes on `using` statements in the [HTTP trigger template examples](#http-trigger-template) later in this article.
128+
116129
# [.NET 6 (isolated)](#tab/net6-isolated)
117130

118-
[!INCLUDE [functions-dotnet-migrate-project-v4-isolated](../../includes/functions-dotnet-migrate-project-v4-isolated.md)]
131+
[!INCLUDE [functions-dotnet-migrate-packages-v4-isolated](../../includes/functions-dotnet-migrate-packages-v4-isolated.md)]
132+
133+
# [.NET 6 (in-process)](#tab/net6-in-proc)
134+
135+
[!INCLUDE [functions-dotnet-migrate-packages-v4-in-process](../../includes/functions-dotnet-migrate-packages-v4-in-process.md)]
119136

120137
# [.NET 7](#tab/net7)
121138

122-
[!INCLUDE [functions-dotnet-migrate-project-v4-isolated-2](../../includes/functions-dotnet-migrate-project-v4-isolated-2.md)]
139+
[!INCLUDE [functions-dotnet-migrate-packages-v4-isolated](../../includes/functions-dotnet-migrate-packages-v4-isolated.md)]
140+
141+
# [.NET Framework 4.8](#tab/v4)
142+
143+
[!INCLUDE [functions-dotnet-migrate-packages-v4-isolated](../../includes/functions-dotnet-migrate-packages-v4-isolated.md)]
123144

124145
---
125146

126-
### program.cs file
147+
### Program.cs file
127148

128149
When migrating to run in an isolated worker process, you must add the following program.cs file to your project:
129150

151+
# [.NET 6 (isolated)](#tab/net6-isolated)
152+
153+
:::code language="csharp" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp-Isolated/Program.cs" range="23-29":::
154+
130155
# [.NET 6 (in-process)](#tab/net6-in-proc)
131156

132157
A program.cs file isn't required when running in-process.
133158

134-
# [.NET 6 (isolated)](#tab/net6-isolated)
159+
# [.NET 7](#tab/net7)
135160

136161
:::code language="csharp" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp-Isolated/Program.cs" range="23-29":::
137162

138-
# [.NET 7](#tab/net7)
163+
# [.NET Framework 4.8](#tab/v4)
139164

140-
:::code language="csharp" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp-Isolated/Program.cs" range="23-29":::
165+
:::code language="csharp" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp-Isolated/Program.cs" range="2-20":::
141166

142167
---
143168

144169
### local.settings.json file
145170

146-
The local.settings.json file is only used when running locally. For information, see [Local settings file](functions-develop-local.md#local-settings-file). When migrating from running in-process to running in an isolated worker process, you need to change the `FUNCTIONS_WORKER_RUNTIME` value, as in the following example:
171+
The local.settings.json file is only used when running locally. For information, see [Local settings file](functions-develop-local.md#local-settings-file).
172+
173+
When you upgrade to version 4.x, make sure that your local.settings.json file has at least the following elements:
174+
175+
# [.NET 6 (isolated)](#tab/net6-isolated)
176+
177+
:::code language="json" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp-Isolated/local.settings.json":::
178+
179+
> [!NOTE]
180+
> When migrating from running in-process to running in an isolated worker process, you need to change the `FUNCTIONS_WORKER_RUNTIME` value to "dotnet-isolated".
147181
148182
# [.NET 6 (in-process)](#tab/net6-in-proc)
149183

150184
:::code language="json" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp/local.settings.json":::
151185

152-
# [.NET 6 (isolated)](#tab/net6-isolated)
186+
# [.NET 7](#tab/net7)
153187

154188
:::code language="json" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp-Isolated/local.settings.json":::
155189

156-
# [.NET 7](#tab/net7)
190+
> [!NOTE]
191+
> When migrating from running in-process to running in an isolated worker process, you need to change the `FUNCTIONS_WORKER_RUNTIME` value to "dotnet-isolated".
192+
193+
# [.NET Framework 4.8](#tab/v4)
157194

158195
:::code language="json" source="~/functions-quickstart-templates/Functions.Templates/ProjectTemplate_v4.x/CSharp-Isolated/local.settings.json":::
159196

197+
> [!NOTE]
198+
> When migrating from running in-process to running in an isolated worker process, you need to change the `FUNCTIONS_WORKER_RUNTIME` value to "dotnet-isolated".
199+
160200
---
161201

162-
### Namespace changes
202+
### Class name changes
163203

164-
C# functions that run in an isolated worker process uses libraries in a different namespace than those libraries used when running in-process. In-process libraries are generally in the namespace `Microsoft.Azure.WebJobs.*`. Isolated worker process function apps use libraries in the namespace `Microsoft.Azure.Functions.Worker.*`. You can see the effect of these namespace changes on `using` statements in the [HTTP trigger template examples](#http-trigger-template) that follow.
204+
Some key classes changed names between versions. These changes are a result either of changes in .NET APIs or in differences between in-process and isolated worker process. The following table indicates key .NET classes used by Functions that could change when migrating:
165205

166-
### Class name changes
206+
# [.NET 6 (isolated)](#tab/net6-isolated)
167207

168-
Some key classes change names as a result of differences between in-process and isolated worker process APIs.
208+
| .NET Core 3.1 | .NET 5 | .NET 6 (isolated) |
209+
| --- | --- | --- |
210+
| `FunctionName` (attribute) | `Function` (attribute) | `Function` (attribute) |
211+
| `ILogger` | `ILogger` | `ILogger`, `ILogger<T>` |
212+
| `HttpRequest` | `HttpRequestData` | `HttpRequestData`, `HttpRequest` (using [ASP.NET Core integration])|
213+
| `IActionResult` | `HttpResponseData` | `HttpResponseData`, `IActionResult` (using [ASP.NET Core integration])|
214+
| `FunctionsStartup` (attribute) | Uses [`Program.cs`](#programcs-file) instead | Uses [`Program.cs`](#programcs-file) instead |
215+
216+
# [.NET 6 (in-process)](#tab/net6-in-proc)
217+
218+
| .NET Core 3.1 | .NET 5 | .NET 6 (in-process) |
219+
| --- | --- | --- |
220+
| `FunctionName` (attribute) | `Function` (attribute) | `FunctionName` (attribute) |
221+
| `ILogger` | `ILogger` | `ILogger` |
222+
| `HttpRequest` | `HttpRequestData` | `HttpRequest` |
223+
| `IActionResult` | `HttpResponseData` | `IActionResult` |
224+
| `FunctionsStartup` (attribute) | Uses [`Program.cs`](#programcs-file) instead | `FunctionsStartup` (attribute) |
225+
226+
# [.NET 7](#tab/net7)
169227

170-
The following table indicates key .NET classes used by Functions that could change when migrating from in-process:
228+
| .NET Core 3.1 | .NET 5 | .NET 7 |
229+
| --- | --- | --- |
230+
| `FunctionName` (attribute) | `Function` (attribute) | `Function` (attribute) |
231+
| `ILogger` | `ILogger` | `ILogger`, `ILogger<T>` |
232+
| `HttpRequest` | `HttpRequestData` | `HttpRequestData`, `HttpRequest` (using [ASP.NET Core integration])|
233+
| `IActionResult` | `HttpResponseData` | `HttpResponseData`, `IActionResult` (using [ASP.NET Core integration])|
234+
| `FunctionsStartup` (attribute) | Uses [`Program.cs`](#programcs-file) instead | Uses [`Program.cs`](#programcs-file) instead |
171235

172-
| .NET Core 3.1 | .NET 6 (in-process) | .NET 6 (isolated) | .NET 7 |
173-
| --- | --- | --- | --- |
174-
| `FunctionName` (attribute) | `FunctionName` (attribute) | `Function` (attribute) | `Function` (attribute) |
175-
| `HttpRequest` | `HttpRequest` | `HttpRequestData` | `HttpRequestData` |
176-
| `OkObjectResult` | `OkObjectResult` | `HttpResponseData` | `HttpResponseData` |
236+
# [.NET Framework 4.8](#tab/v4)
177237

178-
There might also be class name differences in bindings. For more information, see the reference articles for the specific bindings.
238+
| .NET Core 3.1 | .NET 5 |.NET Framework 4.8 |
239+
| --- | --- | --- |
240+
| `FunctionName` (attribute) | `Function` (attribute) | `Function` (attribute) |
241+
| `ILogger` | `ILogger` | `ILogger`, `ILogger<T>` |
242+
| `HttpRequest` | `HttpRequestData` | `HttpRequestData`|
243+
| `IActionResult` | `HttpResponseData` | `HttpResponseData`|
244+
| `FunctionsStartup` (attribute) | Uses [`Program.cs`](#programcs-file) instead | Uses [`Program.cs`](#programcs-file) instead |
245+
246+
---
247+
248+
[ASP.NET Core integration]: ./dotnet-isolated-process-guide.md#aspnet-core-integration-preview
249+
250+
There might also be class name differences in bindings. For more information, see the reference articles for the specific bindings.
179251

180252
### HTTP trigger template
181253

@@ -185,15 +257,19 @@ The differences between in-process and isolated worker process can be seen in HT
185257

186258
The HTTP trigger template for the migrated version looks like the following example:
187259

260+
# [.NET 6 (isolated)](#tab/net6-isolated)
261+
262+
:::code language="csharp" source="~/functions-quickstart-templates/Functions.Templates/Templates/HttpTrigger-CSharp-Isolated/HttpTriggerCSharp.cs":::
263+
188264
# [.NET 6 (in-process)](#tab/net6-in-proc)
189265

190266
Sames as version 3.x (in-process).
191267

192-
# [.NET 6 (isolated)](#tab/net6-isolated)
268+
# [.NET 7](#tab/net7)
193269

194270
:::code language="csharp" source="~/functions-quickstart-templates/Functions.Templates/Templates/HttpTrigger-CSharp-Isolated/HttpTriggerCSharp.cs":::
195271

196-
# [.NET 7](#tab/net7)
272+
# [.NET Framework 4.8](#tab/v4)
197273

198274
:::code language="csharp" source="~/functions-quickstart-templates/Functions.Templates/Templates/HttpTrigger-CSharp-Isolated/HttpTriggerCSharp.cs":::
199275

@@ -240,6 +316,18 @@ To update your project to Azure Functions 4.x:
240316
3. If you're using Python 3.6, move to one of the [supported versions](functions-reference-python.md#python-version).
241317
::: zone-end
242318

319+
### Run the pre-upgrade validator
320+
321+
Azure Functions provides a pre-upgrade validator to help you identify potential issues when migrating your function app to 4.x. To run the pre-upgrade validator:
322+
323+
1. In the [Azure portal](https://portal.azure.com), navigate to your function app.
324+
325+
1. Open the **Diagnose and solve problems** page.
326+
327+
1. In **Function App Diagnostics**, start typing `Functions 4.x Pre-Upgrade Validator` and then choose it from the list.
328+
329+
1. After validation completes, review the recommendations and address any issues in your app. If you need to make changes to your app, make sure to validate the changes against version 4.x of the Functions runtime, either [locally using Azure Functions Core Tools v4](#upgrade-your-local-project) or by [using a staging slot](#upgrade-using-slots).
330+
243331
[!INCLUDE [functions-migrate-v4](../../includes/functions-migrate-v4.md)]
244332

245333
## Breaking changes between 3.x and 4.x
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
author: mattchenderson
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 07/31/2023
6+
ms.author: mahender
7+
---
8+
9+
Update your project to reference the latest stable version of [Microsoft.NET.Sdk.Functions](https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions).
10+
11+
Depending on the triggers and bindings your app uses, your app may need to reference an additional set of packages. See [Supported bindings](../articles/azure-functions/functions-triggers-bindings.md#supported-bindings) for a list of extensions to consider, and consult each extension's documentation for full installation instructions for the in-process process model. Be sure to install the latest stable version of any packages you are targeting.
12+
13+
> [!TIP]
14+
> Your app may also depend on Azure SDK types, either as part of your triggers and bindings or as a standalone dependency. You should take this opportunity to upgrade these as well. The latest versions of the Functions extensions work with the latest versions of the [Azure SDK for .NET](/dotnet/azure/sdk/azure-sdk-for-dotnet), almost all of the packages for which are the form `Azure.*`.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
author: mattchenderson
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 07/31/2023
6+
ms.author: mahender
7+
---
8+
9+
Update your project to reference the latest stable versions of:
10+
- [Microsoft.Azure.Functions.Worker](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/)
11+
- [Microsoft.Azure.Functions.Worker.Sdk](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/)
12+
13+
Depending on the triggers and bindings your app uses, your app may need to reference an additional set of packages. See [Supported bindings](../articles/azure-functions/functions-triggers-bindings.md#supported-bindings) for a list of extensions to consider, and consult each extension's documentation for full installation instructions for the isolated process model. The packages for these extensions will all be under the [Microsoft.Azure.Functions.Worker.Extensions](https://www.nuget.org/packages?q=Microsoft.Azure.Functions.Worker.Extensions) prefix. Be sure to install the latest stable version of any packages you are targeting.
14+
15+
**Your application should not reference any packages in the `Microsoft.Azure.WebJobs.*` namespaces.** If you have any remaining references to these, they should be removed.
16+
17+
> [!TIP]
18+
> Your app may also depend on Azure SDK types, either as part of your triggers and bindings or as a standalone dependency. You should take this opportunity to upgrade these as well. The latest versions of the Functions extensions work with the latest versions of the [Azure SDK for .NET](/dotnet/azure/sdk/azure-sdk-for-dotnet), almost all of the packages for which are the form `Azure.*`.

includes/functions-dotnet-migrate-project-v4-isolated-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ After you make these changes, your updated project should look like the followin
3737
<Nullable>enable</Nullable>
3838
</PropertyGroup>
3939
<ItemGroup>
40-
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
41-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
40+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.18.0" />
41+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.13.0" />
4242
</ItemGroup>
4343
<ItemGroup>
4444
<None Update="host.json">

0 commit comments

Comments
 (0)