author | ms.service | ms.custom | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|
craigshoemaker |
container-apps |
devx-track-azurecli |
include |
11/09/2022 |
cshoe |
-
Change into the src folder of the cloned repository.
cd my-container-app cd src
-
Create Azure resources and deploy a container app with the
az containerapp up
command.az containerapp up \ --name my-container-app \ --source . \ --ingress external
-
In the command output, note the name of the Azure Container Registry.
-
Get the full resource ID of the container registry.
az acr show --name <ACR_NAME> --query id --output tsv
Replace
<ACR_NAME>
with the name of your registry. -
Enable managed identity for the container app.
az containerapp identity assign \ --name my-container-app \ --resource-group my-container-app-rg \ --system-assigned \ --output tsv
Note the principal ID of the managed identity in the command output.
-
Assign the
AcrPull
role for the Azure Container Registry to the container app's managed identity.az role assignment create \ --assignee <MANAGED_IDENTITY_PRINCIPAL_ID> \ --role AcrPull \ --scope <ACR_RESOURCE_ID>
Replace
<MANAGED_IDENTITY_PRINCIPAL_ID>
with the principal ID of the managed identity and<ACR_RESOURCE_ID>
with the resource ID of the Azure Container Registry. -
Configure the container app to use the managed identity to pull images from the Azure Container Registry.
az containerapp registry set \ --name my-container-app \ --resource-group my-container-app-rg \ --server <ACR_NAME>.azurecr.io \ --identity system
Replace
<ACR_NAME>
with the name of your Azure Container Registry.