Skip to content

Commit 5bf6dcf

Browse files
authored
Fix bugs in procedures
1 parent fde955c commit 5bf6dcf

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

articles/azure-functions/functions-deploy-container-apps.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,27 @@ Use these commands to create your required Azure resources:
6868
```
6969
This command can take a few minutes to complete.
7070
71-
1. Create a general-purpose storage account in your resource group and region.
71+
1. Create a general-purpose storage account in your resource group and region, without shared key access.
7272
7373
```azurecli
74-
az storage account create --name <STORAGE_NAME> --location eastus --resource-group AzureFunctionsContainers-rg --sku Standard_LRS
74+
az storage account create --name <STORAGE_NAME> --location eastus --resource-group AzureFunctionsContainers-rg --sku Standard_LRS --allow-blob-public-access false --allow-shared-key-access false
7575
```
7676
77-
The [`az storage account create`](/cli/azure/storage/account#az-storage-account-create) command creates the storage account.
77+
The [`az storage account create`](/cli/azure/storage/account#az-storage-account-create) command creates the storage account that can only be accessed by using Micrososft Entra-authenticated identities that have been granted permissions to specific resources.
7878
7979
In the previous example, replace `<STORAGE_NAME>` with a name that is appropriate to you and unique in Azure Storage. Storage names must contain 3 to 24 characters numbers and lowercase letters only. `Standard_LRS` specifies a general-purpose account [supported by Functions](storage-considerations.md#storage-account-requirements).
8080
81-
1. Create a managed identity and grant it access to your storage account and pull permissions in your registry instance.
81+
1. Create a managed identity and use the returned `principalId` to grant it both access to your storage account and pull permissions in your registry instance.
8282
8383
```azurecli
84-
ACR_ID=$(az acr show --name <REGISTRY_NAME> --query id --output tsv)
85-
86-
UAMI_ID=$(az identity create --name <USER_IDENTITY_NAME> --resource-group AzureFunctionsContainers-rg --location eastus --query principalId -o tsv)
87-
az role assignment create --assignee $UAMI_ID --role acrpull --scope $ACR_ID
84+
principalId=$(az identity create --name <USER_IDENTITY_NAME> --resource-group AzureFunctionsContainers-rg --location eastus --query principalId -o tsv)
85+
acrId=$(az acr show --name <REGISTRY_NAME> --query id --output tsv)
86+
az role assignment create --assignee-object-id $principalId --assignee-principal-type ServicePrincipal --role acrpull --scope $acrId
87+
storageId=$(az storage account show --resource-group AzureFunctionsContainers-rg --name glengatestaca2 --query 'id' -o tsv)
88+
az role assignment create --assignee-object-id $principalId --assignee-principal-type ServicePrincipal --role "Storage Blob Data Owner" --scope $storageId
8889
```
8990
90-
The [`az identity create`](/cli/azure/identity#az-identity-create) command creates a user-assigned managed identity and the [`az role assignment create`](/cli/azure/role/assignment#az-role-assignment-create) adds your identity to the `acrpull` role in your registry. Replace `<REGISTRY_NAME>` and `<USER_IDENTITY_NAME>` with the name your existing container registry and name for your managed identity, respectively. The managed identity can now be used by an app to access Azure Container Registry without using shared secrets.
91+
The [`az identity create`](/cli/azure/identity#az-identity-create) command creates a user-assigned managed identity and the [`az role assignment create`](/cli/azure/role/assignment#az-role-assignment-create) commands adds your identity to the required roles. Replace `<REGISTRY_NAME>`, `<USER_IDENTITY_NAME>`, and `<STORAGE_NAME>` with the name your existing container registry, the name for your managed identity, and the storage account name, respectively. The managed identity can now be used by an app to access both the storage account and Azure Container Registry without using shared secrets.
9192
9293
## Create and configure a function app on Azure with the image
9394
@@ -100,7 +101,7 @@ Use the [`az functionapp create`](/cli/azure/functionapp#az-functionapp-create)
100101
>[!TIP]
101102
> To make sure that your function app uses a managed identity-based connection to your registry instance, don't set the `--image` parameter in `az functionapp create`. When you set `--image` to the fully qualified name of your image in the repository, shared secret credentials are obtained from your registry and stored in app settings.
102103
103-
First you must get fully qualified ID value of your user-assigned managed identity with pull access to the registry, and then use the [`az functionapp create`](/cli/azure/functionapp#az-functionapp-create) command to create a function app using the default image and with this identity assigned to it.
104+
First you must get the fully qualified ID value of your user-assigned managed identity with pull access to the registry, and then use the [`az functionapp create`](/cli/azure/functionapp#az-functionapp-create) command to create a function app using the default image and with this identity assigned to it.
104105
105106
```azurecli
106107
UAMI_RESOURCE_ID=$(az identity show --name $uami_name --resource-group $group --query id -o tsv)
@@ -145,16 +146,16 @@ To enable the Functions host to connect to the default storage account using sha
145146
1. Remove the existing `AzureWebJobsStorage` connection string setting:
146147

147148
```azurecli
148-
az functionapp config appsettings delete --name `<APP_NAME>` --resource-group AzureFunctionsQuickstart-rg --setting-names AzureWebJobsStorage
149+
az functionapp config appsettings delete --name <APP_NAME> --resource-group AzureFunctionsContainers-rg --setting-names AzureWebJobsStorage
149150
```
150151
151152
The [az functionapp config appsettings delete](/cli/azure/functionapp/config/appsettings#az-functionapp-config-appsettings-delete) command removes this setting from your app. Replace `<APP_NAME>` with the name of your function app.
152153
153154
1. Add equivalent settings, with an `AzureWebJobsStorage__` prefix, that define a user-assigned managed identity connection to the default storage account:
154155
155156
```azurecli
156-
clientId=$(az identity show --name <USER_IDENTITY_NAME> --resource-group AzureFunctionsQuickstart-rg --query 'clientId' -o tsv)
157-
az functionapp config appsettings set --name <APP_NAME> --resource-group AzureFunctionsQuickstart-rg --settings AzureWebJobsStorage__accountName=<STORAGE_NAME> AzureWebJobsStorage__credential=managedidentity AzureWebJobsStorage__clientId=$clientId
157+
clientId=$(az identity show --name <USER_IDENTITY_NAME> --resource-group AzureFunctionsContainers-rg --query 'clientId' -o tsv)
158+
az functionapp config appsettings set --name <APP_NAME> --resource-group AzureFunctionsContainers-rg --settings AzureWebJobsStorage__accountName=<STORAGE_NAME> AzureWebJobsStorage__credential=managedidentity AzureWebJobsStorage__clientId=$clientId
158159
```
159160
160161
In this example, replace `<APP_NAME>`, `<USER_IDENTITY_NAME>`, `<STORAGE_NAME>` with your function app name, the name of your identity, and the storage account name, respectively.

0 commit comments

Comments
 (0)