{"id":5503,"date":"2019-08-10T18:24:19","date_gmt":"2019-08-10T22:24:19","guid":{"rendered":"\/db-blog\/?p=5503"},"modified":"2020-02-22T22:08:44","modified_gmt":"2020-02-23T03:08:44","slug":"azure-configure-the-azure-cli-in-the-development-environment-for-containerization","status":"publish","type":"post","link":"https:\/\/droidbasement.com\/db-blog\/azure-configure-the-azure-cli-in-the-development-environment-for-containerization\/","title":{"rendered":"Azure \u2013 Configure the CLI in the Development Environment for Containerization"},"content":{"rendered":"\n<p>In this article we will setup the Azure CLI to interact with AWS AKS (Azure Kubernetes Service) and Azure ACR (Azure Container Registry)). <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>&#8211;&gt;<br>UI Console -&gt; Azure Active Directory<br>App registrations -&gt; New registration -&gt; * Name: container-admin -&gt; Supported account types: Accounts in this organizational directory only -&gt; Register<\/p>\n\n\n\n<p>container-admin -&gt; Certificates &amp; secrets -&gt; New client secret -&gt; Description: azure-cli ; Expires: In 1 year -&gt; Add -&gt; Take note of the &lt;Client secret value&gt;<\/p>\n\n\n\n<p>Search for (top left): Subscriptions -&gt; Click your subscription -&gt; Access control (IAM) -&gt; Add -&gt; Add role assignment -&gt; Role: Azure Kubernetes Service Cluster Admin Role -&gt; Assign access to: Azure AD user, group, or service principal -&gt; Select: (search for) container-admin -&gt; Save<\/p>\n\n\n\n<p>Azure Active Directory -&gt; App registrations -&gt; container-admin -&gt; Overview -&gt; Take note of the &lt;Application (client) ID&gt; and &lt;Directory (tenant) ID&gt;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> $ [[ ! -d ~\/.azure ]] &amp;&amp; mkdir ~\/.azure<\/pre>\n\n\n\n<p>(Replace &lt;Application (client) ID&gt;, &lt;Client secret value&gt; and &lt;Directory (tenant) ID&gt;  below):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat &lt;&lt; \"EOF\" &gt; ~\/.azure\/credentials\n&gt; [container-admin]\n&gt; application_id=&lt;Application (client) ID&gt;\n&gt; client_secret=&lt;Client secret value&gt;\n&gt; directory_id=&lt;Directory (tenant) ID&gt;\n&gt; EOF\n$ chmod o-rw,g-w ~\/.azure\/credentials<\/pre>\n\n\n\n<p>Add a function in to your startup to parse the above file for pertinent login information as a servicePrincipal and run az login in a sub-shell when you execute it (ensure you get pertinent output regarding the Subscription):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat &lt;&lt; 'EOF' >> ~\/.bashrc\n>\n> function az-login-sp() {\n>         (export $(grep -v '^\\[' $HOME\/.azure\/credentials | xargs) &amp;&amp; az login --service-principal -u $application_id -p $client_secret --tenant $directory_id)\n> }\n> EOF\n$ . ~\/.bashrc\n$ az-login-sp<\/pre>\n\n\n\n<p>Ensure you get appropriate output (the value will be []):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ az aks list<\/pre>\n\n\n\n<p>Ensure you get appropriate output (the value will be []):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ az acr list<\/pre>\n\n\n\n<p>&lt;&#8211;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>References:<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article we will setup the Azure CLI to interact with AWS AKS (Azure Kubernetes Service) and Azure ACR (Azure Container Registry)). &#8211;&gt;UI Console -&gt; Azure Active DirectoryApp registrations -&gt; New registration -&gt; * Name: container-admin -&gt; Supported account types: Accounts in this organizational directory only -&gt; Register container-admin -&gt; Certificates &amp; secrets -&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-5503","post","type-post","status-publish","format-standard","hentry","category-devops"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts\/5503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/comments?post=5503"}],"version-history":[{"count":14,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts\/5503\/revisions"}],"predecessor-version":[{"id":5814,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts\/5503\/revisions\/5814"}],"wp:attachment":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/media?parent=5503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/categories?post=5503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/tags?post=5503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}