{"id":110,"date":"2015-04-17T18:56:46","date_gmt":"2015-04-17T17:56:46","guid":{"rendered":"https:\/\/zorq.net\/b\/?p=110"},"modified":"2015-04-19T22:28:21","modified_gmt":"2015-04-19T21:28:21","slug":"first-steps-with-azure-cli","status":"publish","type":"post","link":"https:\/\/zorq.net\/b\/2015\/04\/17\/first-steps-with-azure-cli\/","title":{"rendered":"First steps with Azure CLI"},"content":{"rendered":"<p>This guide uses <a href=\"http:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/xplat-cli\/\">Azure&#8217;s cross platform CLI<\/a> to create and destroy a virtual machine.<\/p>\n<p>First things first, lets define some basic properties about the machine such as the adminstrator credentials and its hostname, which will be given the suffix of cloudapp.net:<\/p>\n<pre lang=\"bash\">\r\nHOST=cccu-dev-adfs\r\nUSERNAME=djb\r\nPASSWORD=Password1!\r\n<\/pre>\n<p>To make changes to your Azure account you&#8217;ll need to authenticate yourself using an X509 certificate. This can be generated by running the following command, which will launch your web browser:<\/p>\n<pre lang=\"bash\">\r\nazure account download\r\n<\/pre>\n<p>Once the certificate is downloaded you need to register it with the command line tool:<\/p>\n<pre lang=\"bash\">\r\nazure account import \"~\/Downloads\/credentials.publishsettings\"\r\n<\/pre>\n<p>Azure uses images (or templates) of operating systems with varying applications preinstalled. To create a new VM you need to pick an image, but these are identified by mixtures of random hexidecimal and textual description. To find the right identifier you can use another API call to search images by their human readable label. The following command downloads the list as json and uses the <a href=\"http:\/\/stedolan.github.io\/jq\/\">jq command line tool<\/a> to find the right json object and return its identifier:<\/p>\n<pre lang=\"bash\">\r\nSELECTOR='.[] | select(.label | contains(\"Windows Server 2012 R2 Datacenter\")) | .name'\r\nIMAGE=`azure vm image list --json | jq -r -c $SELECTOR | tail -n 1`\r\n<\/pre>\n<p>You can now <tt>create<\/tt> and <tt>start<\/tt> your new server:<\/p>\n<pre lang=\"bash\">\r\nazure vm create $HOST $IMAGE $USERNAME $PASSWORD \\\r\n    --rdp \\\r\n    --location \"West Europe\" \\\r\n    --vm-size Medium\r\nazure vm start $HOST\r\n<\/pre>\n<p>By default there won&#8217;t be any endpoints created on the Azure load balancer, save for 3389 used by RDP. To access a web server running on your new server use <tt>vm endpoint<\/tt>:<\/p>\n<pre lang=\"bash\">\r\nazure vm endpoint create $HOST 80\r\n<\/pre>\n<p>When you&#8217;re finished with the VM you&#8217;ll want to delete it to save a few pennies. Use the <tt>vm delete<\/tt> command and optionally also remove the VM&#8217;s disk storage:<\/p>\n<pre lang=\"bash\">\r\nazure vm delete $HOST --blob-delete --quiet\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This guide uses Azure&#8217;s cross platform CLI to create and destroy a virtual machine. First things first, lets define some basic properties about the machine such as the adminstrator credentials and its hostname, which will be given the suffix of cloudapp.net: HOST=cccu-dev-adfs USERNAME=djb PASSWORD=Password1! To make changes to your Azure account you&#8217;ll need to authenticate [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[16],"class_list":["post-110","post","type-post","status-publish","format-standard","hentry","category-cloud","tag-azure"],"_links":{"self":[{"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":19,"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":135,"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/posts\/110\/revisions\/135"}],"wp:attachment":[{"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zorq.net\/b\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}