{"id":18451,"date":"2020-08-28T08:32:15","date_gmt":"2020-08-28T08:32:15","guid":{"rendered":"https:\/\/www.testpreptraining.com\/tutorial\/?page_id=18451"},"modified":"2022-04-11T06:05:04","modified_gmt":"2022-04-11T06:05:04","slug":"deploying-a-container-instance-using-the-azure-cli","status":"publish","type":"page","link":"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/","title":{"rendered":"Deploying a container instance using the Azure CLI"},"content":{"rendered":"\n<p class=\"has-text-align-right\"><strong><a href=\"https:\/\/www.testpreptraining.ai\/tutorial\/exam-az-104-microsoft-azure-administrator-associate\/\" target=\"_blank\" rel=\"noreferrer noopener\">Return to AZ-104 Tutorial<\/a><\/strong><\/p>\n\n\n\n<p>You&#8217;ll learn how to launch serverless Docker containers using Azure CLI for Azure Container Instances. When you don&#8217;t require a whole container on an orchestration platform like Azure Kubernetes Service, you&#8217;ll be able to deploy an application to a container instance on-demand.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"prerequisites\"><strong><span style=\"text-decoration: underline;\">Prerequisites<\/span>:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>In Azure Cloud Shell, use the Bash environment.<\/li><li>Install the Azure CLI if you prefer to execute CLI reference commands locally. Consider running Azure CLI in a Docker container if you&#8217;re using Windows or macOS.<ul><li>Sign in to the Azure CLI using the az login command if you&#8217;re using a local installation. Follow the instructions in your terminal to complete the authentication procedure.<\/li><li>When requested, install Azure CLI extensions the first time you use it.<\/li><li>To determine the version and dependent libraries that are installed, run az version. Run az upgrade to get the most recent version.<\/li><\/ul><\/li><li>The Azure CLI version 2.0.55 or later is required for this quickstart. The most recent version of Azure Cloud Shell is already installed.<\/li><\/ul>\n\n\n\n<p><strong>Also, here you&#8217;ll use the Azure CLI to deploy the container and make its application available with a fully qualified domain name. So, let&#8217;s begin:<\/strong><\/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, that can be used both Bash and PowerShell with Cloud Shell to work with Azure services. <\/p>\n\n\n\n<p>To run the code in Azure Cloud Shell, so follow the following steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>First of all, begin Cloud Shell.<\/li><li>Secondly, select the&nbsp;<strong>Copy<\/strong>&nbsp;button on a code block to copy the code.<\/li><li>After this, paste the code into the Cloud Shell session by selecting&nbsp;<strong>Ctrl<\/strong>+<strong>Shift<\/strong>+<strong>V<\/strong>.<\/li><li>Subsequently, select&nbsp;<strong>Enter<\/strong>&nbsp;to run the code.<\/li><\/ol>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-a-resource-group\"><strong>Create a resource group<\/strong><\/h4>\n\n\n\n<p>Azure container cases should be used in a resource group. Resource groups enable to organize and manage related Azure resources.<\/p>\n\n\n\n<p>So, first, create a resource group named&nbsp;<em>myResourceGroup<\/em>&nbsp;in the&nbsp;<em>eastus<\/em>&nbsp;place with the following&nbsp;command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">az group create --name myResourceGroup --location eastus<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-a-container\"><strong>Creating a container<\/strong><\/h4>\n\n\n\n<p>Now run a container in Azure. And, to create a container with the Azure CLI, you must provide a resource group name, container instance name, and Docker container image to the&nbsp;az container generate&nbsp;command. <\/p>\n\n\n\n<p>Also, you can expose the containers to the internet by designating one or more ports to open, a DNS name label, or both.<\/p>\n\n\n\n<p>In order to do so, set a&nbsp;&#8211;dns-name-label&nbsp;the value that&#8217;s unique within the Azure region where you create the instance. If in case you receive a &#8220;DNS name label not available&#8221; error message, try a different DNS name label.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">az container create --resource-group myResourceGroup --name mycontainer --image mcr.microsoft.com\/azuredocs\/aci-helloworld --dns-name-label aci-demo --ports 80<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/www.testpreptraining.ai\/microsoft-azure-administrator-associate-az-104-free-practice-test\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/06\/practice-test-2.png\" alt=\"Practice Test for AZ-104\"\/><\/a><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"pull-the-container-logs\"><strong>Pulling the container logs<\/strong><\/h4>\n\n\n\n<p>If you require to troubleshoot a container or the application it runs, begin by viewing the container instance&#8217;s logs.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">az container logs --resource-group myResourceGroup --name mycontainer<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"attach-output-streams\"><strong>Attaching output streams<\/strong><\/h4>\n\n\n\n<p>In addition to viewing the logs, you can now attach your local standard out and standard error streams to that of the container.<\/p>\n\n\n\n<p>So, first, execute the&nbsp;az container attach&nbsp;command to connect the local console to the container&#8217;s output streams:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">az container attach --resource-group myResourceGroup --name mycontainer<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"clean-up-resources\"><strong>Cleaning up resources<\/strong><\/h4>\n\n\n\n<p>After finishing with the container, delete it using the&nbsp;az container delete&nbsp;command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">az container delete --resource-group myResourceGroup --name mycontainer<\/pre>\n\n\n\n<p>And, to verify that the container has been deleted, execute the&nbsp;following list&nbsp;command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">az container list --resource-group myResourceGroup --output table<\/pre>\n\n\n\n<p>The&nbsp;<strong>mycontainer<\/strong>&nbsp;container must not rise in the command&#8217;s output. <\/p>\n\n\n\n<p>And, after completing with the&nbsp;<em>myResourceGroup<\/em>&nbsp;resource group and all the resources it contains, delete it with the&nbsp;az group delete&nbsp;command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">az group delete --name myResourceGroup<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/07\/testpreptraining.ai-2-750x117.png\" alt=\"Azure CLI exam az-104\"\/><\/figure><\/div>\n\n\n\n<p class=\"has-text-align-right\"><strong>Reference: <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/container-instances\/container-instances-quickstart\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Documentation<\/a><\/strong><\/p>\n\n\n\n<p><strong><a href=\"https:\/\/www.testpreptraining.ai\/tutorial\/exam-az-104-microsoft-azure-administrator-associate\/\" target=\"_blank\" rel=\"noreferrer noopener\">Return to AZ-104 Tutorial<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Return to AZ-104 Tutorial You&#8217;ll learn how to launch serverless Docker containers using Azure CLI for Azure Container Instances. When you don&#8217;t require a whole container on an orchestration platform like Azure Kubernetes Service, you&#8217;ll be able to deploy an application to a container instance on-demand. Prerequisites: In Azure Cloud Shell, use the Bash environment&#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":[],"tags":[],"class_list":["post-18451","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Deploying a container instance using the Azure CLI - Testprep Training<\/title>\n<meta name=\"description\" content=\"Enhance your AZ-104 exam preparation by learning the process of deploying a container instance using the Azure CLI 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\/deploying-a-container-instance-using-the-azure-cli\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deploying a container instance using the Azure CLI - Testprep Training\" \/>\n<meta property=\"og:description\" content=\"Enhance your AZ-104 exam preparation by learning the process of deploying a container instance using the Azure CLI Now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/\" \/>\n<meta property=\"og:site_name\" content=\"Testprep Training Tutorials\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-11T06:05:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/06\/practice-test-2.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\/deploying-a-container-instance-using-the-azure-cli\/\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/\",\"name\":\"Deploying a container instance using the Azure CLI - Testprep Training\",\"isPartOf\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#website\"},\"datePublished\":\"2020-08-28T08:32:15+00:00\",\"dateModified\":\"2022-04-11T06:05:04+00:00\",\"description\":\"Enhance your AZ-104 exam preparation by learning the process of deploying a container instance using the Azure CLI Now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deploying a container instance using the Azure CLI\"}]},{\"@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":"Deploying a container instance using the Azure CLI - Testprep Training","description":"Enhance your AZ-104 exam preparation by learning the process of deploying a container instance using the Azure CLI 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\/deploying-a-container-instance-using-the-azure-cli\/","og_locale":"en_US","og_type":"article","og_title":"Deploying a container instance using the Azure CLI - Testprep Training","og_description":"Enhance your AZ-104 exam preparation by learning the process of deploying a container instance using the Azure CLI Now!","og_url":"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/","og_site_name":"Testprep Training Tutorials","article_modified_time":"2022-04-11T06:05:04+00:00","og_image":[{"url":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/06\/practice-test-2.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\/deploying-a-container-instance-using-the-azure-cli\/","url":"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/","name":"Deploying a container instance using the Azure CLI - Testprep Training","isPartOf":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#website"},"datePublished":"2020-08-28T08:32:15+00:00","dateModified":"2022-04-11T06:05:04+00:00","description":"Enhance your AZ-104 exam preparation by learning the process of deploying a container instance using the Azure CLI Now!","breadcrumb":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/deploying-a-container-instance-using-the-azure-cli\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.testpreptraining.ai\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Deploying a container instance using the Azure CLI"}]},{"@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\/18451","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=18451"}],"version-history":[{"count":4,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/18451\/revisions"}],"predecessor-version":[{"id":54421,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/18451\/revisions\/54421"}],"wp:attachment":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/media?parent=18451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/categories?post=18451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/tags?post=18451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}