{"id":15672,"date":"2020-08-07T07:36:29","date_gmt":"2020-08-07T07:36:29","guid":{"rendered":"https:\/\/www.testpreptraining.com\/tutorial\/?page_id=15672"},"modified":"2022-03-05T11:20:12","modified_gmt":"2022-03-05T11:20:12","slug":"build-and-deploy-container-images-in-the-cloud","status":"publish","type":"page","link":"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/","title":{"rendered":"Build and deploy container images in the cloud"},"content":{"rendered":"\n<p>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\u00a0<em>quick task<\/em>\u00a0feature of ACR Tasks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"use-azure-cloud-shell\"><strong>Use Azure Cloud Shell<\/strong><\/h3>\n\n\n\n<p>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 &#8211;  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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"build-in-azure-with-acr-tasks\"><strong>Build in Azure with ACR Tasks<\/strong><\/h3>\n\n\n\n<p>Now that you&#8217;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.<\/p>\n\n\n\n<p>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. &lt;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.<\/p>\n\n\n\n<p>ACR_NAME=<\/p>\n\n\n\n<p>After you&#8217;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:<\/p>\n\n\n\n<p>RES_GROUP=$ACR_NAME # Resource Group name<\/p>\n\n\n\n<p>az group create &#8211;resource-group $RES_GROUP &#8211;location eastus<br>az acr create &#8211;resource-group $RES_GROUP &#8211;name $ACR_NAME &#8211;sku Standard &#8211;location eastus<\/p>\n\n\n\n<p>Now that you have a registry, use ACR Tasks to build a container image from the sample code. Execute the&nbsp;az acr build&nbsp;command to perform a&nbsp;<em>quick task<\/em>:<\/p>\n\n\n\n<p>az acr build &#8211;registry $ACR_NAME &#8211;image helloacrtasks:v1 .<\/p>\n\n\n\n<p>The upload of the source code (the &#8220;context&#8221;) 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&#8217;t need to make any modifications to your Dockerfiles to get started with ACR Tasks right away.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"deploy-to-azure-container-instances\"><strong>Deploy to Azure Container Instances<\/strong><\/h3>\n\n\n\n<p>ACR tasks automatically push successfully built images to your registry by default. This is allowing you to deploy them from your registry immediately.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-registry-authentication\"><strong>Configure registry authentication<\/strong><\/h3>\n\n\n\n<p>All production scenarios should use&nbsp;service principals&nbsp;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.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-a-key-vault\"><strong>Create a key vault<\/strong><\/h4>\n\n\n\n<p>If you don&#8217;t already have a vault in&nbsp;Azure Key Vault, you have to create one with the Azure CLI using the below mentioned commands.<\/p>\n\n\n\n<p>AKV_NAME=$ACR_NAME-vault<\/p>\n\n\n\n<p>az keyvault create &#8211;resource-group $RES_GROUP &#8211;name $AKV_NAME<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"deploy-a-container-with-azure-cli\"><strong>Deploy a container with Azure CLI<\/strong><\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The&nbsp;<code>--dns-name-label<\/code>&nbsp;value must be unique within Azure, so the preceding command appends your container registry&#8217;s name to the container&#8217;s DNS name label.&nbsp;<\/p>\n\n\n\n<p><strong>Do not forget to clean up the resources after completion of process. <\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.testpreptraining.ai\/microsoft-azure-architect-technologies-az-303-free-practice-test\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"150\" src=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/07\/Untitled-design-5.png\" alt=\"free practice test for AZ- 303\" class=\"wp-image-13928\" srcset=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/07\/Untitled-design-5.png 960w, https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/07\/Untitled-design-5-750x117.png 750w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/figure><\/div>\n\n\n\n<p><a href=\"https:\/\/www.testpreptraining.ai\/tutorial\/exam-az-303-microsoft-azure-architect-technologies\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Go back to home page <\/strong><\/a><\/p>\n\n\n\n<p class=\"has-text-align-right\"><strong>Reference documentation &#8211; <\/strong><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/container-registry\/container-registry-tutorial-quick-task#code-try-6\" target=\"_blank\" rel=\"noreferrer noopener\">Tutorial: Build and deploy container images in the cloud with Azure Container Registry Tasks<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u00a0quick task\u00a0feature of ACR Tasks. Use Azure Cloud Shell Azure hosts Azure Cloud Shell, an&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"categories":[174],"tags":[],"class_list":["post-15672","page","type-page","status-publish","hentry","category-microsoft-azure"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Build and deploy container images in the cloud - Testprep Training Tutorials<\/title>\n<meta name=\"description\" content=\"Enhance and upgrade your Azure Architect skills by preparing from tutorial - Build and deploy container images in the cloud. Crack the exam now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Build and deploy container images in the cloud - Testprep Training Tutorials\" \/>\n<meta property=\"og:description\" content=\"Enhance and upgrade your Azure Architect skills by preparing from tutorial - Build and deploy container images in the cloud. Crack the exam now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/\" \/>\n<meta property=\"og:site_name\" content=\"Testprep Training Tutorials\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-05T11:20:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/07\/Untitled-design-5.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/\",\"name\":\"Build and deploy container images in the cloud - Testprep Training Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#website\"},\"datePublished\":\"2020-08-07T07:36:29+00:00\",\"dateModified\":\"2022-03-05T11:20:12+00:00\",\"description\":\"Enhance and upgrade your Azure Architect skills by preparing from tutorial - Build and deploy container images in the cloud. Crack the exam now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Build and deploy container images in the cloud\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#website\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\",\"name\":\"Testprep Training Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.testpreptraining.ai\/tutorial\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#organization\",\"name\":\"Testprep Training\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png\",\"contentUrl\":\"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png\",\"width\":583,\"height\":153,\"caption\":\"Testprep Training\"},\"image\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Build and deploy container images in the cloud - Testprep Training Tutorials","description":"Enhance and upgrade your Azure Architect skills by preparing from tutorial - Build and deploy container images in the cloud. Crack the exam now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/","og_locale":"en_US","og_type":"article","og_title":"Build and deploy container images in the cloud - Testprep Training Tutorials","og_description":"Enhance and upgrade your Azure Architect skills by preparing from tutorial - Build and deploy container images in the cloud. Crack the exam now!","og_url":"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/","og_site_name":"Testprep Training Tutorials","article_modified_time":"2022-03-05T11:20:12+00:00","og_image":[{"url":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/07\/Untitled-design-5.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/","url":"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/","name":"Build and deploy container images in the cloud - Testprep Training Tutorials","isPartOf":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#website"},"datePublished":"2020-08-07T07:36:29+00:00","dateModified":"2022-03-05T11:20:12+00:00","description":"Enhance and upgrade your Azure Architect skills by preparing from tutorial - Build and deploy container images in the cloud. Crack the exam now!","breadcrumb":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/build-and-deploy-container-images-in-the-cloud\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.testpreptraining.ai\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Build and deploy container images in the cloud"}]},{"@type":"WebSite","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#website","url":"https:\/\/www.testpreptraining.ai\/tutorial\/","name":"Testprep Training Tutorials","description":"","publisher":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.testpreptraining.ai\/tutorial\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#organization","name":"Testprep Training","url":"https:\/\/www.testpreptraining.ai\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png","contentUrl":"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png","width":583,"height":153,"caption":"Testprep Training"},"image":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/15672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/comments?post=15672"}],"version-history":[{"count":4,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/15672\/revisions"}],"predecessor-version":[{"id":52078,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/15672\/revisions\/52078"}],"wp:attachment":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/media?parent=15672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/categories?post=15672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/tags?post=15672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}