Container Registry & App Service
ACR tiers · tags and cleanup · ACR Tasks · App Service containers · app settings and Key Vault references
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Registry tiers and basics
| Tier | Included storage (GiB) | Webhooks |
|---|---|---|
| Basic | 10 | 2 |
| Standard | 100 | 10 |
| Premium | 500 | 500 |
- Container registries are available in three tiers (SKUs): Basic, Standard, and Premium. All three provide the same programmatic capabilities and data plane APIs.
- Premium adds features such as geo-replication, private link with private endpoints, content trust, customer-managed keys, a retention policy for untagged manifests and dedicated agent pools for Tasks. Basic and Standard list these as N/A.
- The registry name must be unique within Azure and contain 5-50 alphanumeric characters.
- A registry stores Docker container images and related content formats such as Helm charts and images built to the Open Container Initiative (OCI) Image Format Specification.
- Create a registry:
az acr create --resource-group myResourceGroup --name mycontainerregistry008 --sku Basic.
The retention policy for untagged manifests is a preview feature of Premium registries.
Sign in and push images
| Method | Typical use | Notes |
|---|---|---|
Individual Microsoft Entra identity (az acr login) | Interactive push and pull by developers | The Microsoft Entra token must be renewed every 3 hours |
| Microsoft Entra service principal | Unattended push from a CI/CD pipeline, unattended pull | Default password expiry is 1 year |
| Managed identity for Azure resources | Unattended push from Azure CI/CD, unattended pull to Azure services | Registry permissions come from Azure RBAC role assignments |
Admin user (docker login) | Interactive push/pull by one developer or tester | Disabled by default; full push and pull permissions; single account per registry |
az acr login --name myregistryis the recommended command-line sign-in. The token it uses is valid for 3 hours, so sign in before running adockercommand.- Without a Docker daemon (for example Azure Cloud Shell), run
az acr login --name <acrName> --expose-token. It returns an access token instead of signing in through the Docker CLI. Pass it todocker loginwith00000000-0000-0000-0000-000000000000as the username. - Each registry has an admin account that is disabled by default. It has full permissions, so enable it only when necessary, and don't share its credentials among multiple users.
- Always specify the fully qualified registry name (all lowercase) when you use
docker loginand when you tag images for pushing.
docker tag nginx myregistry.azurecr.io/samples/nginxcreates an alias with the fully qualified registry path.docker push myregistry.azurecr.io/samples/nginxpushes it.docker pull myregistry.azurecr.io/samples/nginxpulls it back.
Tags, locks and cleanup
| Tag type | Use it for | Why |
|---|---|---|
Stable tags (for example :1, :1.0) | Base images for your container builds | The tag keeps receiving updates, so avoid it for deployments |
| Unique tags (for example a build ID) | Deployments, especially when scaling on multiple nodes | A restart or scale-out never pulls a newer version than the other nodes |
:1is a stable tag for the major version and:1.0is a stable tag that binds to updates of 1.0 without rolling forward to 1.1.- Unique tag patterns: date-time stamp, Git commit (only semi-stable once base image updates exist), manifest digest (SHA-256), and build ID, which may be best because it is likely incremental and correlates to the build.
- Lock a deployed image tag by setting its
write-enabledattribute tofalse. This prevents inadvertently removing it from the registry. - Updating an image under a stable tag untags the previous image and leaves an orphaned manifest. Auto-purge or a retention policy can remove untagged manifests.
| Action | Command | Result |
|---|---|---|
| Untag | az acr repository untag | Only the tag reference is deleted; no space is freed because the manifest and layer data remain |
| Delete by tag | az acr repository delete --name myregistry --image acr-helloworld:latest | Deletes unique layers and any other tags associated with the image |
| Delete by digest | az acr repository delete --name <acrName> --image <repositoryName>@<digest> | Deletes the image, its unique layers and all its tags; shared layer data is not deleted |
Retention policy for untagged manifests
- A preview feature of Premium registries. Enabled, the registry deletes untagged manifests after the number of days you set.
- The default retention period is seven days; you can specify 0 to 365 days. 0 removes untagged manifests as soon as they become untagged.
- It applies only to untagged manifests with timestamps after the policy is enabled. Untagged manifests with OCI media types are not supported; use the
acr purgecommand for them. - Set
delete-enabledtofalseon a manifest to exclude it. Deleted image data is unrecoverable. - Don't set the policy if systems pull images by manifest digest. Use a unique tag scheme instead.
ACR Tasks
| Task type | How it runs | Notes |
|---|---|---|
| Quick task | az acr build | Builds in Azure without a local Docker Engine and, by default, pushes the image |
| Run a container or multi-step task | az acr run with a YAML file | Step types: build, push, cmd; each step uses a container as its execution environment |
| Source code trigger | Commit (on by default), pull request (off by default) | Needs a personal access token; no commit or pull-request triggers for GitHub Enterprise repos |
| Base image update trigger | Rebuilds app images when the base image is updated | Also on by default for a timer task |
| Timer trigger | Cron expression with five fields | Several timers allowed if schedules differ |
| Pack build (preview) | az acr pack build | Builds from source with Cloud Native Buildpacks; no Dockerfile |
- Quick task example:
az acr build --image sample/hello-world:v1 --registry mycontainerregistry008 --file Dockerfile . - By default, tasks build images for Linux and the AMD64 architecture. Use
--platformto build Windows images or other Linux architectures. - In a multi-step YAML file,
when: ["-"]means no dependency on other steps, so the step starts at once and steps can run concurrently.when: ["id1", "id2"]waits for those steps. - The
$Registryalias (run variableRun.Registry) expands at runtime to the name of the registry the task runs in. - Timer example: the expression
"0 12 * * Mon-Fri"triggers a task at noon UTC on each weekday. - Enable a managed identity on a task with
--assign-identity(no value or[system]for system-assigned). A system-assigned identity lasts for the lifetime of the task. - Manually triggered runs stream log output to the console and store it. Automatically triggered runs only store logs.
- Information on the command line or in a URI may be logged in diagnostic tracing, so keep credentials and tokens out of it.
App Service custom containers
| Need | Setting or command |
|---|---|
| Container listens on a port other than 80 | WEBSITES_PORT app setting. App Service allows one port for HTTP requests |
| Pull from a private registry with credentials | az webapp config container set with --docker-registry-server-url, -user and -password |
| Pull from ACR with managed identity | Enable the identity, assign AcrPull on the registry, set acrUseManagedIdentityCreds to true; for user-assigned also set acrUserManagedIdentityID |
| Pull from a network-protected registry | Virtual network integration plus a private endpoint, then the vnetImagePullEnabled site setting |
| Files that survive restarts | WEBSITES_ENABLE_APP_SERVICE_STORAGE; the /home directory persists when enabled |
| Redeploy on every push | Deployment Center, Continuous deployment On: App Service adds a webhook to the registry |
- The registry must allow ARM audience tokens for managed identity pulls; otherwise pulls fail with an
UNAUTHORIZED"token validation failed" error. Check withaz acr config authentication-as-arm show -r <registry-name>. - Using a service principal for Windows container image pull authentication is no longer supported. Use managed identity for Windows and Linux containers.
- Persistent storage is disabled by default on Linux custom containers and enabled by default on Windows custom containers. Data written outside
/homeor a mounted Azure storage path isn't persistent during restarts. - Each restart runs
docker pull, which pulls only changed layers. After you point the app at a new container it may take a few minutes before it serves requests from it; the old container keeps serving until the new one is ready. - The registry credentials (
DOCKER_REGISTRY_SERVER_URL,_USERNAME,_PASSWORD) are reserved variable names and aren't exposed to the application. - With GitHub Actions as the source, CI/CD is handled directly by GitHub Actions and the Continuous deployment option isn't shown. For a Docker Compose app, select Container Registry.
App settings, connection strings and Key Vault references
- App settings are passed to the app as environment variables. For Linux apps and custom containers they are passed with the
--envflag. Adding, removing or editing a setting triggers an app restart. - App settings are always encrypted at rest. Their values are hidden in the portal by default. Values in App Service override
Web.configorappsettings.json. - On Linux, replace a colon in a nested key with a double underscore (
ApplicationInsights__InstrumentationKey) and a period with a single underscore. - A setting can be stuck to the current slot (slot setting).
- Set one:
az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings <setting-name>="<value>". Verify container variables athttps://<app-name>.scm.azurewebsites.net/Env.
| Connection string type | Environment variable prefix |
|---|---|
| SQL Server | SQLCONNSTR_ |
| MySQL | MYSQLCONNSTR_ |
| Azure SQL | SQLAZURECONNSTR_ |
| Custom | CUSTOMCONNSTR_ |
| PostgreSQL | POSTGRESQLCONNSTR_ |
- For non-.NET languages app settings are usually better. A connection string matters when Azure database types should be backed up with the app.
- .NET apps that target PostgreSQL, Notification Hubs, Service Bus, Event Hubs, Azure Cosmos DB or Redis cache should set the connection string type to Custom (a known issue workaround).
- A Key Vault reference has the form
@Microsoft.KeyVault({referenceString}), for example@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret)or@Microsoft.KeyVault(VaultName=myvault;SecretName=mysecret). - Setup: create a managed identity for the app (the system-assigned identity is used by default), then authorize read access to secrets: assign the Key Vault Secrets User role (Azure RBAC) or the Get secrets permission (vault access policy).
- For a user-assigned identity, set the
keyVaultReferenceIdentityproperty to its resource ID. - Without a secret version the app uses the latest version. App Service refetches references every 24 hours, so a rotated secret is picked up within 24 hours. Any configuration change restarts the app and refetches all references immediately.
- A reference that doesn't resolve is passed as the literal
@Microsoft.KeyVault(...)string. - Don't rely on the app's public outbound IP addresses for a network-restricted vault; configure the vault to accept traffic from a virtual network the app uses.
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| Create a Basic registry | az acr create --resource-group myResourceGroup --name mycontainerregistry008 --sku Basic | - |
| Sign in to a registry | az acr login --name myregistry | - |
| Get a token when no Docker daemon runs | az acr login --name <acrName> --expose-token | - |
| Enable the admin user | az acr update -n <acrName> --admin-enabled true | - |
| Alias an image for your registry | docker tag nginx myregistry.azurecr.io/samples/nginx | - |
| Push an image | docker push myregistry.azurecr.io/samples/nginx | - |
| Build and push in Azure (quick task) | az acr build --image sample/hello-world:v1 --registry mycontainerregistry008 --file Dockerfile . | - |
| Run a YAML task | az acr run --registry <acrName> -f build-push-hello-world.yaml https://github.com/Azure-Samples/acr-tasks.git | - |
| Delete an image by tag | az acr repository delete --name myregistry --image acr-helloworld:latest | - |
| Set a retention policy | az acr config retention update --registry myregistry --status enabled --days 30 --type UntaggedManifests | - |
| Set the app port | az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_PORT=8000 | - |
| Grant a web app's identity pull access | az role assignment create --assignee <principal-id> --scope <registry-resource-id> --role "AcrPull" | - |
| Use managed identity for registry pulls | az webapp config set --resource-group <group-name> --name <app-name> --generic-configurations '{"acrUseManagedIdentityCreds": true}' | - |
| Enable persistent storage (Linux) | az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=true | - |
Exam Tips
Tick each tip once you can answer it without looking.
“Registry name rule” → 5-50 alphanumeric characters, unique within Azure. Trap: Hyphens and underscores aren't alphanumeric.
“Image tag for deployments that scale out on many nodes” → Unique tag (for example the build ID). Trap: A stable tag keeps receiving updates, so nodes can end up on different versions.
“Image tag for base images” → Stable tags such as :1 and :1.0. Trap: :1 follows the newest 1.* image; only :1.0 stays on 1.0 updates.
“Stop a deployed image tag being overwritten or removed by mistake” → Lock it: set write-enabled to false. Trap: A retention policy only handles untagged manifests.
“Build and push an image in Azure with no local Docker Engine” → az acr build (quick task). Trap: docker build needs a local Docker Engine; az acr pack build is for source without a Dockerfile (preview).
“Rebuild app images when the base image changes” → ACR Tasks base image update trigger. Trap: A timer trigger runs on a cron schedule, not because a base image changed.
“Commit-triggered task from a Git repo” → Give the task a personal access token. Trap: GitHub Enterprise repos don't support commit or pull-request triggers. Pull-request triggers are off by default.
“Cron expression for noon UTC on weekdays” → "0 12 * * Mon-Fri". Trap: Five fields: minute, hour, day, month, day of week. The hour is the second field.
“az acr login token lifetime” → 3 hours; sign in again when it expires. Trap: Tokens aren't renewed for you; run the login command again to reauthenticate.
“az acr login in Cloud Shell, no Docker daemon” → --expose-token, then docker login with username 00000000-0000-0000-0000-000000000000. Trap: Plain az acr login needs the Docker CLI and daemon installed and running.
“Free space used by an image” → Delete by tag or digest (az acr repository delete). Trap: az acr repository untag removes only the tag; the manifest and layers stay.
“Retention policy for untagged manifests” → Premium (preview); default 7 days, range 0-365; only untagged manifests created after enabling; Docker manifests only. Trap: Don't enable it when systems pull by manifest digest; use acr purge for untagged OCI manifests.
“Custom container for App Service listens on 8080” → App setting WEBSITES_PORT=8080. Trap: App Service assumes port 80, and allows only one port for HTTP requests.
“App Service pulls from ACR with no stored credentials” → Managed identity with AcrPull plus acrUseManagedIdentityCreds true. Trap: The registry must allow ARM audience tokens. A service principal is no longer supported for Windows container pulls.
“Files in /home lost on restart of a Linux custom container” → Set WEBSITES_ENABLE_APP_SERVICE_STORAGE=true. Trap: Persistent storage is disabled by default on Linux custom containers; it is on by default on Windows.
“Secret stored as an app setting, rotated in Key Vault” → Key Vault reference @Microsoft.KeyVault(...); refetched every 24 hours, or at once after any configuration change. Trap: The identity needs the Key Vault Secrets User role (RBAC) or Get permission (access policy). An unresolved reference is passed as literal text.
“App Service connection string environment variable names” → Prefixed by type, such as MYSQLCONNSTR_ or CUSTOMCONNSTR_. Trap: .NET apps targeting PostgreSQL, Service Bus, Cosmos DB or Redis use the Custom type as a workaround.
Sources
- Introduction to Azure Container Registry
- Azure Container Registry SKU features and limits
- Authenticate with an Azure container registry
- Push and pull a container image
- Image tag best practices
- Delete image resources in ACR
- Retention policy for untagged manifests
- ACR Tasks overview
- Build an image on demand (quick task)
- Multi-step tasks
- ACR Tasks YAML reference
- Schedule ACR Tasks
- Managed identity in an ACR task
- Build images with Cloud Native Buildpacks
- Configure a custom container (App Service)
- Configure CI/CD to custom containers
- Configure an App Service app (app settings, connection strings)
- Use Key Vault references as app settings
Checked against Microsoft Learn on November 13, 2026.