Skip to content

Commit ef23e87

Browse files
authored
[Functions] Add tabs and fix the migration steps
1 parent 2461a76 commit ef23e87

File tree

1 file changed

+94
-17
lines changed

1 file changed

+94
-17
lines changed

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

Lines changed: 94 additions & 17 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/14/2024
77
ms.custom: cc996988-fb4f-47, devx-track-azurecli, devx-track-azurepowershell
88
---
99

@@ -185,15 +185,27 @@ 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+
### [Consumption-to-Premium](#tab/to-premium/portal)
189189

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).
190+
1. In the Azure portal, navigate to your Consumption plan app and choose **Change App Service plan** under **App Service plan**.
191191

192-
### Consumption to Premium
192+
1. Select **Premium** under **Plan type**, create a new Premium plan, and select **OK**.
193+
194+
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).
195+
196+
### [Premium-to-Consumption](#tab/to-consumption/portal)
197+
198+
1. In the Azure portal, navigate to your Premium plan app and choose **Change App Service plan** under **App Service plan**.
199+
200+
1. Select **Consumption** under **Plan type**, create a new Consumption plan, and select **OK**.
201+
202+
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).
203+
204+
### [Consumption-to-Premium](#tab/to-premium/azure-cli)
193205

194206
Use the following procedure to migrate from a Consumption plan to a Premium plan on Windows:
195207

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:
208+
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:
197209

198210
```azurecli-interactive
199211
az functionapp plan create --name <NEW_PREMIUM_PLAN_NAME> --resource-group <MY_RESOURCE_GROUP> --location <REGION> --sku EP1
@@ -205,7 +217,7 @@ Use the following procedure to migrate from a Consumption plan to a Premium plan
205217
az functionapp update --name <MY_APP_NAME> --resource-group <MY_RESOURCE_GROUP> --plan <NEW_PREMIUM_PLAN>
206218
```
207219
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:
220+
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:
209221
210222
```azurecli-interactive
211223
az functionapp plan list --resource-group <MY_RESOURCE_GROUP> --query "[?sku.family=='Y'].{PlanName:name,Sites:numberOfSites}" -o table
@@ -219,45 +231,102 @@ Use the following procedure to migrate from a Consumption plan to a Premium plan
219231
az functionapp plan delete --name <CONSUMPTION_PLAN_NAME> --resource-group <MY_RESOURCE_GROUP>
220232
```
221233
222-
### Premium to Consumption
234+
### [Premium-to-Consumption](#tab/to-consumption/azure-cli)
223235
224236
Use the following procedure to migrate from a Premium plan to a Consumption plan on Windows:
225237
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.
238+
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:
227239
228240
```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>
241+
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>
230242
```
243+
244+
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:
231245
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.
246+
```azurecli-interactive
247+
az functionapp show --resource-group <MY_RESOURCE_GROUP> --name <NEW_CONSUMPTION_APP_NAME> --query "{appServicePlanId}" -o tsv
248+
```
249+
The Consumption plan name is the final segment of the fully-qualified resource ID that's returned.
250+
251+
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:
233252
234253
```azurecli-interactive
235254
az functionapp update --name <MY_APP_NAME> --resource-group <MY_RESOURCE_GROUP> --plan <NEW_CONSUMPTION_PLAN> --force
236255
```
237256
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.
257+
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:
239258
240259
```azurecli-interactive
241260
az functionapp delete --name <NEW_CONSUMPTION_APP_NAME> --resource-group <MY_RESOURCE_GROUP>
242261
```
243262
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.
263+
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:
245264
246265
```azurecli-interactive
247266
az functionapp plan list --resource-group <MY_RESOURCE_GROUP> --query "[?sku.family=='EP'].{PlanName:name,Sites:numberOfSites}" -o table
248267
```
249268
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.
269+
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:
251270
252271
```azurecli-interactive
253272
az functionapp plan delete --name <PREMIUM_PLAN> --resource-group <MY_RESOURCE_GROUP>
254273
```
274+
### [Consumption-to-Premium](#tab/to-premium/azure-powershell)
275+
276+
Use the following procedure to migrate from a Consumption plan to a Premium plan on Windows:
277+
278+
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:
279+
280+
```powershell-interactive
281+
New-AzFunctionAppPlan -Name <NEW_PREMIUM_PLAN_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -Location <REGION> -Sku EP1 -WorkerType Windows
282+
```
283+
284+
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:
285+
286+
```powershell-interactive
287+
Update-AzFunctionApp -Name <MY_APP_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -PlanName <NEW_PREMIUM_PLAN> -Force
288+
```
289+
290+
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:
291+
292+
```powershell-interactive
293+
Remove-AzFunctionAppPlan -Name <CONSUMPTION_PLAN_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -Force
294+
```
295+
296+
### [Premium-to-Consumption](#tab/to-consumption/azure-powershell)
297+
298+
Use the following procedure to migrate from a Premium plan to a Consumption plan on Windows:
299+
300+
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:
301+
302+
```powershell-interactive
303+
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
304+
```
305+
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:
306+
307+
```powershell-interactive
308+
Get-AzFunctionApp -ResourceGroupName <MY_RESOURCE_GROUP> -Name <NEW_CONSUMPTION_APP_NAME> | Select-Object -Property AppServicePlan | Format-List
309+
```
310+
311+
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:
312+
313+
```powershell-interactive
314+
Update-AzFunctionApp -Name <MY_APP_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -PlanName <NEW_CONSUMPTION_PLAN> -Force
315+
```
316+
317+
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:
318+
319+
```powershell-interactive
320+
Remove-AzFunctionAppPlan -Name <CONSUMPTION_PLAN_NAME> -ResourceGroupName <MY_RESOURCE_GROUP> -Force
321+
```
322+
323+
---
255324
256325
## Get your function access keys
257326
258327
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.
259328
260-
# [Portal](#tab/portal)
329+
### [Portal](#tab/portal)
261330
262331
1. Sign in to the Azure portal, then search for and select **Function App**.
263332
@@ -269,7 +338,7 @@ HTTP triggered functions can generally be called by using a URL in the format: `
269338
270339
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.
271340
272-
# [Azure CLI](#tab/azure-cli)
341+
### [Azure CLI](#tab/azure-cli)
273342
274343
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.
275344
@@ -283,7 +352,7 @@ az rest --method POST --uri $path --query functionKeys.default --output tsv
283352

284353
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.
285354

286-
# [Azure PowerShell](#tab/azure-powershell)
355+
### [Azure PowerShell](#tab/azure-powershell)
287356

288357
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.
289358

@@ -395,14 +464,16 @@ When you use a source control solution to develop and maintain your functions co
395464
396465
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.
397466
398-
#### Portal
467+
#### [Portal](#tab/portal)
399468
400469
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.
401470
402471
![Configure function app's CORS list](./media/functions-how-to-use-azure-function-app-settings/configure-function-app-cors.png)
403472

404473
The wildcard (\*) is ignored if there's another domain entry.
405474
475+
#### [Azure CLI](#tab/azure-cli)
476+
406477
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:
407478
408479
```azurecli-interactive
@@ -413,6 +484,12 @@ az functionapp cors add --name <FUNCTION_APP_NAME> \
413484
414485
Use the [`az functionapp cors show`](/cli/azure/functionapp/cors#az-functionapp-cors-show) command to list the current allowed origins.
415486
487+
#### [Azure PowerShell](#tab/azure-powershell)
488+
489+
You can't currently update CORS settings using Azure PowerShell.
490+
491+
---
492+
416493
### <a name="auth"></a>Authentication
417494

418495
![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)