{"id":544,"date":"2025-06-11T11:33:00","date_gmt":"2025-06-11T11:33:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=544"},"modified":"2025-06-11T11:33:00","modified_gmt":"2025-06-11T11:33:00","slug":"setting-azure-cli-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=544","title":{"rendered":"Setting Up Azure CLI on Ubuntu Linux"},"content":{"rendered":"<p>Azure has a great web interface called azure portal for performing all the functions. But if you prefer command line tools over graphical user interface, you can make use of azure command line interface to manage all azure resources.<\/p>\n<h2 id=\"setting-up-azure-cli-on-ubuntu\">Setting up Azure CLI on Ubuntu<\/h2>\n<p>This tutorial will guide you for setting up azure cli on Ubuntu Linux systems.<\/p>\n<p>For this setup, we have used the following versions of the components,<\/p>\n<ol>\n<li>Ubuntu 24.04<\/li>\n<li>Sudo\/root permission to execute the commands (Local workstation)<\/li>\n<li>Azure user credentials<\/li>\n<\/ol>\n<h3 id=\"step-1-install-the-required-packages-to-install-the-azure-cli\">Step 1: Install the required packages to install the Azure CLI <\/h3>\n<p>Use the following command to install the packages<\/p>\n<pre><code>sudo apt-get update\nsudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release<\/code><\/pre>\n<h3 id=\"step-2-install-the-singing-key\">Step 2: Install the singing Key<\/h3>\n<p>The official signing key will help verify the package<\/p>\n<pre><code>sudo mkdir -p \/etc\/apt\/keyrings\ncurl -sLS https:\/\/packages.microsoft.com\/keys\/microsoft.asc |\n  gpg --dearmor | sudo tee \/etc\/apt\/keyrings\/microsoft.gpg &gt; \/dev\/null\nsudo chmod go+r \/etc\/apt\/keyrings\/microsoft.gpg<\/code><\/pre>\n<h3 id=\"step-3-add-the-azure-cli-repository\">Step 3: Add the Azure CLI Repository<\/h3>\n<p>Use the following command to add the repo files on the machine where you want to install the Azure CLI<\/p>\n<pre><code>AZ_DIST=$(lsb_release -cs)\necho \"Types: deb\nURIs: https:\/\/packages.microsoft.com\/repos\/azure-cli\/\nSuites: ${AZ_DIST}\nComponents: main\nArchitectures: $(dpkg --print-architecture)\nSigned-by: \/etc\/apt\/keyrings\/microsoft.gpg\" | sudo tee \/etc\/apt\/sources.list.d\/azure-cli.sources<\/code><\/pre>\n<h3 id=\"step-4-install-the-azure-cli-package\">Step 4: Install the Azure CLI Package<\/h3>\n<p>Use the following command to install the Azure CLI on the Ubuntu machine<\/p>\n<pre><code>sudo apt-get update\nsudo apt-get install azure-cli<\/code><\/pre>\n<h3 id=\"step-5-verify-installation\">Step 5: Verify Installation<\/h3>\n<p>Once installed, verify the installation using the following command. <\/p>\n<pre><code>az version<\/code><\/pre>\n<p>You will get a similar output<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/06\/image-33.png\" class=\"kg-image\" alt=\"The output of the azure cli version\" loading=\"lazy\" width=\"960\" height=\"510\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/06\/image-33.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/06\/image-33.png 960w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"configuring-cli-with-azure-subscription\">Configuring CLI with Azure Subscription<\/h2>\n<p>To connect to your Azure subscription, you should configure your CLI for authentication. You can do this by executing the following command.<\/p>\n<pre><code>az login<\/code><\/pre>\n<p>This will open an interactive web page and prompt you to provide your Azure cloud user credentials, such as Mail ID and the Password.<\/p>\n<p>Once you are done with it, you will see the confirmation in your command line as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/06\/image-35.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1106\" height=\"714\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/06\/image-35.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/06\/image-35.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/06\/image-35.png 1106w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\">If you want to authenticate the Azure CLI with the Azure Service Principle refer this blog &#8211;&gt; <a href=\"https:\/\/devopscube.com\/authenticate-azure-cli\/\" rel=\"noreferrer\">Authenticate Azure CLI Using Service Principal<\/a><\/div>\n<\/div>\n<h3 id=\"adding-subscriptions\">Adding Subscriptions<\/h3>\n<p>If you have different subscriptions with your Azure account, you can add a specific subscription for the CLI. To do that, get the subscription name using the following command.<\/p>\n<pre><code>az account list --output table\n<\/code><\/pre>\n<p>Add then, you can set a specific subscription using the following command.<\/p>\n<pre><code>az account set --subscription \"&lt;subscription-name-or-id&gt;\"\n<\/code><\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>The document covered the installation of the Azure CLI on an Ubuntu machine and authenticating with the user credentials.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/setting-azure-cli-ubuntu-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">Setting Up Azure CLI on Ubuntu Linux \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/setting-azure-cli-ubuntu-linux\/<\/p>\n","protected":false},"author":1,"featured_media":545,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-544","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=544"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/544\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/545"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}