Skip to content

Commit 30fc380

Browse files
committed
Fix last code snippets
1 parent 0b0345d commit 30fc380

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

articles/azure-functions/how-to-create-function-azure-cli.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,29 @@ In Azure Functions, a function project is a container for one or more individual
184184
185185
To enable the Functions host to connect to the default storage account using shared secrets, you must replace the `AzureWebJobsStorage` connection string setting with a complex setting, prefixed with `AzureWebJobsStorage`, that uses the user-assigned managed identity to connect to the storage account.
186186
187-
1. Remove the existing `AzureWebJobsStorage` connection string setting:
187+
1. Use this script to get the client ID of the user-assigned managed identity, and with it define a managed identity connections to storage and Application Insights:
188+
189+
```azurecli
190+
clientId=$(az identity show --name func-host-storage-user \
191+
--resource-group AzureFunctionsQuickstart-rg --query 'clientId' -o tsv)
192+
az functionapp config appsettings set --name <APP_NAME> --resource-group "AzureFunctionsQuickstart-rg" \
193+
--settings AzureWebJobsStorage__accountName=<STORAGE_NAME> \
194+
AzureWebJobsStorage__credential=managedidentity AzureWebJobsStorage__clientId=$clientId \
195+
APPLICATIONINSIGHTS_AUTHENTICATION_STRING="ClientId=$clientId;Authorization=AAD"
196+
```
188197
189-
:::code language="azurecli" source="~/azure_cli_scripts/azure-functions/create-function-app-flex-plan-identities/create-function-app-flex-plan-identities.md" range="52" :::
198+
In this script, replace `<APP_NAME>` and `<STORAGE_NAME>` with the names of your function app and storage account, respectively.
199+
190200
191-
The [az functionapp config appsettings delete](/cli/azure/functionapp/config/appsettings#az-functionapp-config-appsettings-delete) command removes this setting from your app.
201+
1. Run the [az functionapp config appsettings delete](/cli/azure/functionapp/config/appsettings#az-functionapp-config-appsettings-delete) command to remove the existing `AzureWebJobsStorage` connection string setting, which contains a shared secret key:
192202
193-
1. Add equivalent settings, with an `AzureWebJobsStorage__` prefix, that define a user-assigned managed identity connection to the default storage account:
194-
195-
:::code language="azurecli" source="~/azure_cli_scripts/azure-functions/create-function-app-flex-plan-identities/create-function-app-flex-plan-identities.md" range="47-51" :::
196-
197-
At this point, the Functions host is able to connect to the storage account securely using managed identities. You can now deploy your project code to the Azure resources.
203+
```azurecli
204+
az functionapp config appsettings delete --name <APP_NAME> --resource-group "AzureFunctionsQuickstart-rg" --setting-names AzureWebJobsStorage
205+
```
206+
207+
In this example, replace `<APP_NAME>` with the names of your function app.
208+
209+
At this point, the Functions host is able to connect to the storage account securely using managed identities instead of shared secrets. You can now deploy your project code to the Azure resources.
198210
199211
[!INCLUDE [functions-publish-project-cli](../../includes/functions-publish-project-cli.md)]
200212

0 commit comments

Comments
 (0)