Quickstart: Deploy an existing container image with the command line

The Azure Container Apps service enables you to run microservices and containerized applications on a serverless platform. With Container Apps, you enjoy the benefits of running containers while you leave behind the concerns of manual cloud infrastructure configuration and complex container orchestrators.

This article demonstrates how to deploy an existing container to Azure Container Apps.


Private registry authorization is supported via registry username and password.



To sign in to Azure from the CLI, run the following command and follow the prompts to complete the authentication process.

az login

To ensure you're running the latest version of the CLI, run the upgrade command.

az upgrade

Next, install or update the Azure Container Apps extension for the CLI.

az extension add --name containerapp --upgrade

Now that the current extension or module is installed, register the Microsoft.App and Microsoft.OperationalInsights namespaces.


Azure Container Apps resources have migrated from the Microsoft.Web namespace to the Microsoft.App namespace. Refer to Namespace migration from Microsoft.Web to Microsoft.App in March 2022 for more details.

az provider register --namespace Microsoft.App
az provider register --namespace Microsoft.OperationalInsights

Set environment variables

Set the following environment variables. Replace <PLACEHOLDERS> with your values:


Create an Azure resource group

Create a resource group to organize the services related to your container app deployment.

az group create \
  --name $RESOURCE_GROUP \
  --location "$LOCATION"

Create an environment

An environment in Azure Container Apps creates a secure boundary around a group of container apps. Container Apps deployed to the same environment are deployed in the same virtual network and write logs to the same Log Analytics workspace.

To create the environment, run the following command:

az containerapp env create \
  --resource-group $RESOURCE_GROUP \
  --location "$LOCATION"

Create a container app

Now that you have an environment created, you can deploy your first container app. With the containerapp create command, deploy a container image to Azure Container Apps.

The example shown in this article demonstrates how to use a custom container image with common commands. Your container image might need more parameters for the following items:

  • Set the revision mode
  • Define secrets
  • Define environment variables
  • Set container CPU or memory requirements
  • Enable and configure Dapr
  • Enable external or internal ingress
  • Provide minimum and maximum replica values or scale rules

For details on how to provide values for any of these parameters to the create command, run az containerapp create --help or visit the online reference. To generate credentials for an Azure Container Registry, use az acr credential show.


(Replace the <placeholders> with your values.)

az containerapp create \
  --name my-container-app \
  --resource-group $RESOURCE_GROUP \
  --registry-server $REGISTRY_SERVER \
  --registry-username $REGISTRY_USERNAME \
  --registry-password $REGISTRY_PASSWORD
az containerapp create \
  --name my-container-app \
  --resource-group $RESOURCE_GROUP \

If you have enabled ingress on your container app, you can add `--query properties.configuration.ingress.fqdn` to the `create` command to return the public URL for the application.

Before you run this command, replace <REGISTRY_CONTAINER_NAME> with the full name the public container registry location, including the registry path and tag. For example, a valid container name is mcr.microsoft.com/k8se/quickstart:latest.

Verify deployment

To verify a successful deployment, you can query the Log Analytics workspace. You might have to wait a few minutes after deployment for the analytics to arrive for the first time before you're able to query the logs. This depends on the console logging implemented in your container app.

Use the following commands to view console log messages.

LOG_ANALYTICS_WORKSPACE_CLIENT_ID=`az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv`

az monitor log-analytics query \
  --analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'my-container-app' | project ContainerAppName_s, Log_s, TimeGenerated" \
  --out table

Clean up resources

If you're not going to continue to use this application, run the following command to delete the resource group along with all the resources created in this quickstart.


The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this quickstart exist in the specified resource group, they will also be deleted.

az group delete --name $RESOURCE_GROUP


Having issues? Let us know on GitHub by opening an issue in the Azure Container Apps repo.

Next steps