Build and deploy container images in the cloud

  1. Home
  2. Build and deploy container images in the cloud

This guide will assist you with Creating and deploying cloud-based container images. ACR Tasks is a set of tools in Azure Container Registry that allows you to develop Docker container images quickly and easily. Here, you learn how to use the quick task feature of ACR Tasks.

Use Azure Cloud Shell

Azure hosts Azure Cloud Shell, an interactive shell environment that you can use with the help of your browser. You can use ny of them – Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this tutorial without having to install anything on your local environment.

Build in Azure with ACR Tasks

Now that you’ve pulled the source code down to your machine, follow the below mentioned steps to create a container registry and build the container image with ACR Tasks.

The lessons in this series make use of shell environment variables to make executing the example commands simpler. To set the ACR NAME variable, use the command below. <registry-name> should be replaced with a unique name for your new container registry. The registration name must be unique inside Azure, contain only lower case letters, and be between 5 and 50 characters long. Because the name of the other resources you generate in the lesson is reliant on it, you should only need to change this single variable.

ACR_NAME=

After you’ve filled in the container registry environment variable, you should be able to copy and paste the rest of the commands in the guide without having to change any of the settings. To create a resource group and container registry, use the instructions listed below:

RES_GROUP=$ACR_NAME # Resource Group name

az group create –resource-group $RES_GROUP –location eastus
az acr create –resource-group $RES_GROUP –name $ACR_NAME –sku Standard –location eastus

Now that you have a registry, use ACR Tasks to build a container image from the sample code. Execute the az acr build command to perform a quick task:

az acr build –registry $ACR_NAME –image helloacrtasks:v1 .

The upload of the source code (the “context”) to Azure, as well as the specifics of the docker build operation that the ACR job does on the cloud, will be visible. Because ACR Tasks uses docker build to create your images, you won’t need to make any modifications to your Dockerfiles to get started with ACR Tasks right away.

Deploy to Azure Container Instances

ACR tasks automatically push successfully built images to your registry by default. This is allowing you to deploy them from your registry immediately.

Configure registry authentication

All production scenarios should use service principals to access an Azure container registry. Service principals allow you to provide role-based access control to your container images. For instance, you can configure a service principal with pull-only access to a registry.

Create a key vault

If you don’t already have a vault in Azure Key Vault, you have to create one with the Azure CLI using the below mentioned commands.

AKV_NAME=$ACR_NAME-vault

az keyvault create –resource-group $RES_GROUP –name $AKV_NAME

Deploy a container with Azure CLI

Now that the service principal credentials are stored as Azure Key Vault secrets. Further your applications and services can use them to access your private registry.

The --dns-name-label value must be unique within Azure, so the preceding command appends your container registry’s name to the container’s DNS name label. 

Do not forget to clean up the resources after completion of process.

free practice test for AZ- 303

Go back to home page

Reference documentation – Tutorial: Build and deploy container images in the cloud with Azure Container Registry Tasks

Menu