5a. Deploy to Azure App Service
Run your container on a managed Linux App Service plan, with the app pulling from ACR using a managed identity.
1. Create a Linux App Service plan
az appservice plan create \
--resource-group $RG \
--name plan-containerdemo \
--is-linux \
--sku B1
2. Create the web app from your image
az webapp create \
--resource-group $RG \
--plan plan-containerdemo \
--name $APP_NAME \
--container-image-name $ACR_NAME.azurecr.io/$IMAGE:$TAG
3. Tell App Service which port to use
az webapp config appsettings set \
--resource-group $RG \
--name $APP_NAME \
--settings WEBSITES_PORT=8080
4. Let the app pull from ACR with a managed identity
az webapp identity assign --resource-group $RG --name $APP_NAME
PRINCIPAL_ID=$(az webapp identity show --resource-group $RG --name $APP_NAME --query principalId --output tsv)
ACR_ID=$(az acr show --name $ACR_NAME --query id --output tsv)
az role assignment create \
--assignee $PRINCIPAL_ID \
--role AcrPull \
--scope $ACR_ID
az webapp config set \
--resource-group $RG \
--name $APP_NAME \
--generic-configurations '{"acrUseManagedIdentityCreds": true}'
5. Browse and watch the logs
az webapp browse --resource-group $RG --name $APP_NAME
az webapp log config --resource-group $RG --name $APP_NAME --docker-container-logging filesystem
az webapp log tail --resource-group $RG --name $APP_NAME
Your site is available at https://APP_NAME.azurewebsites.net.
Updating the app
az webapp config container set \
--resource-group $RG \
--name $APP_NAME \
--container-image-name $ACR_NAME.azurecr.io/$IMAGE:v2
az webapp restart --resource-group $RG --name $APP_NAME
Good to know
- Role assignments can take a few minutes to propagate. If the first pull fails, restart the app.
- Enable Always On on Basic and higher plans to avoid cold starts.
- Use deployment slots (Standard and higher) for zero-downtime swaps.
- Set configuration and secrets through app settings or Key Vault references, not inside the image.