Skip to content

Commit b5f2ad6

Browse files
Merge pull request #278389 from ggailey777/patch-3
[Functions] Add tabs and fix the migration steps
2 parents 5e2cb6c + 1cb6020 commit b5f2ad6

File tree

1 file changed

+114
-19
lines changed

1 file changed

+114
-19
lines changed

articles/azure-functions/functions-how-to-use-azure-function-app-settings.md

Lines changed: 114 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Configure function app settings in Azure Functions
33
description: Learn how to configure function app settings in Azure Functions.
44
ms.assetid: 81eb04f8-9a27-45bb-bf24-9ab6c30d205c
55
ms.topic: conceptual
6-
ms.date: 12/28/2023
6+
ms.date: 06/15/2024
77
ms.custom: cc996988-fb4f-47, devx-track-azurecli, devx-track-azurepowershell
88
---
99

@@ -159,7 +159,7 @@ az appservice plan list --query "[?id=='$appServicePlanId'].sku.tier" --output t
159159

160160
In the previous example replace `<RESOURCE_GROUP>` and `<FUNCTION_APP_NAME>` with the resource group and function app names, respective.
161161

162-
# [Azure PowerShell](#tab/azure-powershell)
162+
### [Azure PowerShell](#tab/azure-powershell)
163163

164164
Run the following Azure PowerShell command to get your hosting plan type:
165165

@@ -176,7 +176,7 @@ In the previous example replace `<RESOURCE_GROUP>` and `<FUNCTION_APP_NAME>` wit
176176

177177
## Plan migration
178178

179-
You can use either the Azure portal or Azure CLI commands to migrate a function app between a Consumption plan and a Premium plan on Windows. When migrating between plans, keep in mind the following considerations:
179+
You can migrate a function app between a Consumption plan and a Premium plan on Windows. When migrating between plans, keep in mind the following considerations:
180180

181181
+ Direct migration to a Dedicated (App Service) plan isn't currently supported.
182182
+ Migration isn't supported on Linux.
@@ -185,15 +185,45 @@ You can use either the Azure portal or Azure CLI commands to migrate a function
185185
+ Downtime in your function executions occurs as the function app is migrated between plans.
186186
+ State and other app-specific content is maintained, since the same Azure Files share is used by the app both before and after migration.
187187

188-
### Migration in the portal
188+
You can migrate your plan using these tools:
189+
190+
### [Portal](#tab/portal)
191+
192+
You can use the [Azure portal](https://portal.azure.com) to switch to a different plan.
193+
194+
### [Azure CLI](#tab/azure-cli)
195+
196+
You can use the Azure CLI commands to manually create a new plan, switch your app to use the new plan, and delete the original plan.
197+
198+
### [Azure PowerShell](#tab/azure-powershell)
199+
200+
You can use Azure PowerShell commands to manually create a new plan, switch your app to use the new plan, and delete the original plan.
201+
202+
---
203+
204+
Choose the direction of the migration for your app on Windows.
205+
206+
### [Consumption-to-Premium](#tab/to-premium/portal)
189207

190-
In the Azure portal, navigate to your Consumption or Premium plan app and choose **Change App Service plan** under **App Service plan**. Select the other **Plan type**, create a new App Service plan of the new type, and select **OK**. For more information, see [Move an app to another App Service plan](../app-service/app-service-plan-manage.md#move-an-app-to-another-app-service-plan).
208+
1. In the Azure portal, navigate to your Consumption plan app and choose **Change App Service plan** under **App Service plan**.
191209

192-
### Consumption to Premium
210+
1. Select **Premium** under **Plan type**, create a new Premium plan, and select **OK**.
211+
212+
For more information, see [Move an app to another App Service plan](../app-service/app-service-plan-manage.md#move-an-app-to-another-app-service-plan).
213+
214+
### [Premium-to-Consumption](#tab/to-consumption/portal)
215+
216+
1. In the Azure portal, navigate to your Premium plan app and choose **Change App Service plan** under **App Service plan**.
217+
218+
1. Select **Consumption** under **Plan type**, create a new Consumption plan, and select **OK**.
219+
220+
For more information, see [Move an app to another App Service plan](../app-service/app-service-plan-manage.md#move-an-app-to-another-app-service-plan).
221+
222+
### [Consumption-to-Premium](#tab/to-premium/azure-cli)
193223

194224
Use the following procedure to migrate from a Consumption plan to a Premium plan on Windows:
195225

196-
1. Run the [az functionapp plan create](/cli/azure/functionapp/plan#az-functionapp-plan-create) command as follows to create a new App Service plan (Elastic Premium) in the same region and resource group as your existing function app:
226+
1. Run the [az functionapp create](/cli/azure/functionapp/plan#az-functionapp-plan-create) command as follows to create a new App Service plan (Elastic Premium) in the same region and resource group as your existing function app:
197227

198228
```azurecli-interactive
199229
az functionapp plan create --name <NEW_PREMIUM_PLAN_NAME> --resource-group <MY_RESOURCE_GROUP> --location <REGION> --sku EP1
@@ -205,7 +235,7 @@ Use the following procedure to migrate from a Consumption plan to a Premium plan
205235
az functionapp update --name <MY_APP_NAME> --resource-group <MY_RESOURCE_GROUP> --plan <NEW_PREMIUM_PLAN>
206236
```
207237
208-
1. If you no longer need your previous Consumption function app plan, delete your original function app plan after confirming you have successfully migrated to the new one. Run the [az functionapp plan list](/cli/azure/functionapp/plan#az-functionapp-plan-list) command as follows to get a list of all Consumption plans in your resource group:
238+
1. When you no longer need the Consumption plan originally used by the app, delete your original plan after confirming you have successfully migrated to the new one. Run the [az functionapp plan list](/cli/azure/functionapp/plan#az-functionapp-plan-list) command as follows to get a list of all Consumption plans in your resource group:
209239
210240
```azurecli-interactive
211241
az functionapp plan list --resource-group <MY_RESOURCE_GROUP> --query "[?sku.family=='Y'].{PlanName:name,Sites:numberOfSites}" -o table
@@ -219,45 +249,102 @@ Use the following procedure to migrate from a Consumption plan to a Premium plan
219249
az functionapp plan delete --name <CONSUMPTION_PLAN_NAME> --resource-group <MY_RESOURCE_GROUP>
220250
```
221251
222-
### Premium to Consumption
252+
### [Premium-to-Consumption](#tab/to-consumption/azure-cli)
223253
224254
Use the following procedure to migrate from a Premium plan to a Consumption plan on Windows:
225255
226-
1. Run the [az functionapp plan create](/cli/azure/functionapp/plan#az-functionapp-plan-create) command as follows to create a new function app (Consumption) in the same region and resource group as your existing function app. This command also creates a new Consumption plan in which the function app runs.
256+
1. Run the [az functionapp create](/cli/azure/functionapp#az-functionapp-create) command as follows to create a new function app (Consumption) in the same region and resource group as your existing function app. This command also creates a new Consumption plan in which the function app runs:
227257
228258
```azurecli-interactive
229-
az functionapp create --resource-group <MY_RESOURCE_GROUP> --name <NEW_CONSUMPTION_APP_NAME> --consumption-plan-location <REGION> --runtime dotnet --functions-version 3 --storage-account <STORAGE_NAME>
259+
az functionapp create --resource-group <MY_RESOURCE_GROUP> --name <NEW_CONSUMPTION_APP_NAME> --consumption-plan-location <REGION> --runtime <LANGUAGE_RUNTIME> --functions-version 4 --storage-account <STORAGE_NAME>
230260
```
261+
262+
1. Run the [az functionapp show](/cli/azure/functionapp#az-functionapp-show) command as follows to get the name of the Consumption plan created with the new function app:
231263
232-
1. Run the [az functionapp update](/cli/azure/functionapp#az-functionapp-update) command as follows to migrate the existing function app to the new Consumption plan.
264+
```azurecli-interactive
265+
az functionapp show --resource-group <MY_RESOURCE_GROUP> --name <NEW_CONSUMPTION_APP_NAME> --query "{appServicePlanId}" -o tsv
266+
```
267+
The Consumption plan name is the final segment of the fully-qualified resource ID that's returned.
268+
269+
1. Run the [az functionapp update](/cli/azure/functionapp#az-functionapp-update) command as follows to migrate the existing function app to the new Consumption plan:
233270
234271
```azurecli-interactive
235272
az functionapp update --name <MY_APP_NAME> --resource-group <MY_RESOURCE_GROUP> --plan <NEW_CONSUMPTION_PLAN> --force
236273
```
237274
238-
1. Run the [az functionapp delete](/cli/azure/functionapp#az-functionapp-delete) command as follows to delete the function app you created in step 1, since you only need the plan that was created to run the existing function app.
275+
1. Run the [az functionapp delete](/cli/azure/functionapp#az-functionapp-delete) command as follows to delete the function app you created in step 1, since you only need the plan that was created to run the existing function app:
239276
240277
```azurecli-interactive
241278
az functionapp delete --name <NEW_CONSUMPTION_APP_NAME> --resource-group <MY_RESOURCE_GROUP>
242279
```
243280
244-
1. If you no longer need your previous Premium function app plan, delete your original function app plan after confirming you have successfully migrated to the new one. Until the Premium plan is deleted, you continue to be charged for it. Run the [az functionapp plan list](/cli/azure/functionapp/plan#az-functionapp-plan-list) command as follows to get a list of all Premium plans in your resource group.
281+
1. When you no longer need the Premium plan originally used by the app, delete your original plan after confirming you have successfully migrated to the new one. Until the Premium plan is deleted, you continue to be charged for it. Run the [az functionapp plan list](/cli/azure/functionapp/plan#az-functionapp-plan-list) command as follows to get a list of all Premium plans in your resource group:
245282
246283
```azurecli-interactive
247284
az functionapp plan list --resource-group <MY_RESOURCE_GROUP> --query "[?sku.family=='EP'].{PlanName:name,Sites:numberOfSites}" -o table
248285
```
249286
250-
1. Run the [az functionapp plan delete](/cli/azure/functionapp/plan#az-functionapp-plan-delete) command as follows to delete the Premium plan you migrated from.
287+
1. Run the [az functionapp plan delete](/cli/azure/functionapp/plan#az-functionapp-plan-delete) command as follows to delete the Premium plan you migrated from:
251288
252289
```azurecli-interactive
253290
az functionapp plan delete --name <PREMIUM_PLAN> --resource-group <MY_RESOURCE_GROUP>
254291
```
292+
### [Consumption-to-Premium](#tab/to-premium/azure-powershell)
293+
294+
Use the following procedure to migrate from a Consumption plan to a Premium plan on Windows:
295+
296+
1. Run the [New-AzFunctionAppPlan](/powershell/module/az.functions/new-azfunctionappplan) command as follows to create a new App Service plan (Elastic Premium) in the same region and resource group as your existing function app:
297+
298+
```powershell-interactive
299+
New-AzFunctionAppPlan -Name <NEW_PREMIUM_PLAN_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -Location <REGION> -Sku EP1 -WorkerType Windows
300+
```
301+
302+
1. Run the [Update-AzFunctionApp](/powershell/module/az.functions/update-azfunctionapp) command as follows to migrate the existing function app to the new Premium plan:
303+
304+
```powershell-interactive
305+
Update-AzFunctionApp -Name <MY_APP_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -PlanName <NEW_PREMIUM_PLAN> -Force
306+
```
307+
308+
1. When you no longer need the Consumption plan originally used by the app, you can run the [Remove-AzFunctionAppPlan](/powershell/module/az.functions/remove-azfunctionappplan) command as follows to delete the Consumption plan you migrated from:
309+
310+
```powershell-interactive
311+
Remove-AzFunctionAppPlan -Name <CONSUMPTION_PLAN_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -Force
312+
```
313+
314+
### [Premium-to-Consumption](#tab/to-consumption/azure-powershell)
315+
316+
Use the following procedure to migrate from a Premium plan to a Consumption plan on Windows:
317+
318+
1. Run the [New-AzFunctionApp](/powershell/module/az.functions/new-azfunctionapp) command as follows to create a new function app (Consumption) in the same region and resource group as your existing function app. This command also creates a new Consumption plan in which the function app runs:
319+
320+
```powershell-interactive
321+
New-AzFunctionApp -Name <NEW_CONSUMPTION_APP_NAME> -StorageAccountName <STORAGE_NAME> -Location <REGION> -ResourceGroupName <MY_RESOURCE_GROUP> -Runtime <LANGUAGE_RUNTIME> -RuntimeVersion <LANGUAGE_VERSION> -FunctionsVersion 4 -OSType Windows
322+
```
323+
1. Run the [Get-AzFunctionApp](/powershell/module/az.functions/get-azfunctionapp) command as follows to get the name of the Consumption plan created with the new function app:
324+
325+
```powershell-interactive
326+
Get-AzFunctionApp -ResourceGroupName <MY_RESOURCE_GROUP> -Name <NEW_CONSUMPTION_APP_NAME> | Select-Object -Property AppServicePlan | Format-List
327+
```
328+
329+
1. Run the [Update-AzFunctionApp](/powershell/module/az.functions/update-azfunctionapp) command as follows to migrate the existing function app to the new Consumption plan:
330+
331+
```powershell-interactive
332+
Update-AzFunctionApp -Name <MY_APP_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -PlanName <NEW_CONSUMPTION_PLAN> -Force
333+
```
334+
335+
1. When you no longer need the Consumption plan originally used by the app, you can run the [Remove-AzFunctionAppPlan](/powershell/module/az.functions/remove-azfunctionappplan) command as follows to delete the Consumption plan you migrated from:
336+
337+
```powershell-interactive
338+
Remove-AzFunctionAppPlan -Name <CONSUMPTION_PLAN_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -Force
339+
```
340+
341+
---
255342
256343
## Get your function access keys
257344
258345
HTTP triggered functions can generally be called by using a URL in the format: `https://<APP_NAME>.azurewebsites.net/api/<FUNCTION_NAME>`. When the authorization to your function is set a value other than `anonymous`, you must also provide an access key in your request. The access key can either be provided in the URL using the `?code=` query string or in the request header. To learn more, see [Function access keys](functions-bindings-http-webhook-trigger.md#authorization-keys). There are several ways to get your access keys.
259346
260-
# [Portal](#tab/portal)
347+
### [Portal](#tab/portal)
261348
262349
1. Sign in to the Azure portal, then search for and select **Function App**.
263350
@@ -269,7 +356,7 @@ HTTP triggered functions can generally be called by using a URL in the format: `
269356
270357
You can also practice least privilege by using the key just for the specific function key by selecting **Function keys** under **Developer** in your HTTP triggered function.
271358
272-
# [Azure CLI](#tab/azure-cli)
359+
### [Azure CLI](#tab/azure-cli)
273360
274361
Run the following script in Azure Cloud Shell, the output of which is the [default (host) key](functions-bindings-http-webhook-trigger.md#authorization-scopes-function-level) that can be used to access any HTTP triggered function in the function app.
275362
@@ -283,7 +370,7 @@ az rest --method POST --uri $path --query functionKeys.default --output tsv
283370

284371
In this script, replace `<SUBSCRIPTION_ID>` and `<APP_NAME>` with the ID of your subscription and your function app name, respective. This script runs on Bash in Cloud Shell. It must be modified to run in a Windows command prompt.
285372

286-
# [Azure PowerShell](#tab/azure-powershell)
373+
### [Azure PowerShell](#tab/azure-powershell)
287374

288375
Run the following script, the output of which is the [default (host) key](functions-bindings-http-webhook-trigger.md#authorization-scopes-function-level) that can be used to access any HTTP triggered function in the function app.
289376

@@ -395,14 +482,16 @@ When you use a source control solution to develop and maintain your functions co
395482
396483
To prevent malicious code execution on the client, modern browsers block requests from web applications to resources running in a separate domain. [Cross-origin resource sharing (CORS)](https://developer.mozilla.org/docs/Web/HTTP/CORS) lets an `Access-Control-Allow-Origin` header declare which origins are allowed to call endpoints on your function app.
397484
398-
#### Portal
485+
#### [Portal](#tab/portal)
399486
400487
When you configure the **Allowed origins** list for your function app, the `Access-Control-Allow-Origin` header is automatically added to all responses from HTTP endpoints in your function app.
401488
402489
![Configure function app's CORS list](./media/functions-how-to-use-azure-function-app-settings/configure-function-app-cors.png)
403490

404491
The wildcard (\*) is ignored if there's another domain entry.
405492
493+
#### [Azure CLI](#tab/azure-cli)
494+
406495
Use the [`az functionapp cors add`](/cli/azure/functionapp/cors#az-functionapp-cors-add) command to add a domain to the allowed origins list. The following example adds the contoso.com domain:
407496
408497
```azurecli-interactive
@@ -413,6 +502,12 @@ az functionapp cors add --name <FUNCTION_APP_NAME> \
413502
414503
Use the [`az functionapp cors show`](/cli/azure/functionapp/cors#az-functionapp-cors-show) command to list the current allowed origins.
415504
505+
#### [Azure PowerShell](#tab/azure-powershell)
506+
507+
You can't currently update CORS settings using Azure PowerShell.
508+
509+
---
510+
416511
### <a name="auth"></a>Authentication
417512

418513
![Configure authentication for a function app](./media/functions-how-to-use-azure-function-app-settings/configure-function-app-authentication.png)

0 commit comments

Comments
 (0)