Cuir in eagar

Comhroinn trí


Connect to a container console in Azure Container Apps

Connecting to a container's console is useful when you want to troubleshoot your application inside a container. Azure Container Apps allows you to connect to a container's console using the Azure portal or Azure CLI.

Azure portal

To connect to a container's console in the Azure portal, follow these steps.

  1. In the Azure portal, select Console in the Monitoring menu group from your container app page.
  2. Select the revision, replica, and container you want to connect to.
  3. Choose to access your console via bash, sh, or a custom executable. If you choose a custom executable, it must be available in the container.

Screenshot of Azure Container Apps Console page.

Azure CLI

To connect to a container console, Use the az containerapp exec command. To exit the console, select Ctrl-D.

For example, connect to a container console in a container app with a single container using the following command. Replace the <PLACEHOLDERS> with your container app's values.

az containerapp exec \
  --name <CONTAINER_APP_NAME> \
  --resource-group <RESOURCE_GROUP>

To connect to a container console in a container app with multiple revisions, replicas, and containers include the following parameters in the az containerapp exec command.

Argument Description
--revision The revision names of the container to connect to.
--replica The replica name of the container to connect to.
--container The container name of the container to connect to.

You can get the revision names with the az containerapp revision list command. Replace the <PLACEHOLDERS> with your container app's values.

az containerapp revision list \
  --name <CONTAINER_APP_NAME> \
  --resource-group <RESOURCE_GROUP> \
  --query "[].name"

Use the az containerapp replica list command to get the replica and container names. Replace the <PLACEHOLDERS> with your container app's values.

az containerapp replica list \
  --name <CONTAINER_APP_NAME> \
  --resource-group <RESOURCE_GROUP> \
  --revision <REVISION_NAME> \
  --query "[].{Containers:properties.containers[].name, Name:name}"

Connect to the container console with the az containerapp exec command. Replace the <PLACEHOLDERS> with your container app's values.

az containerapp exec \
  --name <CONTAINER_APP_NAME> \
  --resource-group <RESOURCE_GROUP> \
  --revision <REVISION_NAME> \
  --replica <REPLICA_NAME> \
  --container <CONTAINER_NAME>