<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2522 " id="quads-ad2522" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>
<p>This is a step by step guide about deploying Linux or Windows servers on Azure via CLI.</p>
<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2527 " id="quads-ad2527" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2531 " id="quads-ad2531" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2526 " id="quads-ad2526" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<h2>Why Cli? </h2>
<p>Some people prefer using Linux rather than PowerShell and it seems sometimes easier and faster to learn esp if you’re not GUI type of person. </p>
<h2>Installation Options</h2>
<p>If you’re working on Windows and would like to use CLI, you’ll have two options to install CLI </p>
<h4>Option 1 </h4>
<p>Run Azure CLI installation directly from your Powershell (PowerShell needs to run from a privileged account) </p>
<p>Invoke-WebRequest -Uri <a href="https://aka.ms/installazurecliwindows">https://aka.ms/installazurecliwindows</a> -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList &#8216;/I AzureCLI.msi /quiet&#8217;</p>
<p>As soon as you run this command, it&#8217;ll take about 5 mins or less depending on the connection you have. </p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image001-2.png"><img width="860" height="138" title="clip_image001" style="margin: 0px; display: inline; background-image: none;" alt="clip_image001" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image001_thumb-2.png" border="0"></a> 

<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2528 " id="quads-ad2528" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>
 
</p>
<h4>Option 2</h4>
<p>Download the MSI file directly from MS&#8217;s link and install it on your Computer. </p>
<p><a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest">https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest</a></p>
<h4>Connect to Azure CLI from PowerShell</h4>
<p>Run PowerShell or CMD and type the following command to connect</p>
<p>Az Login then hit enter</p>
<p>As soon as you type this, a web page will be launched asking you for your Azure Account credentials so open the session for your Cli window.</p>
<p>The moment you verified your account, PowerShell will list your azure plans that you have / had before.</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image002-2.png"><img width="858" height="692" title="clip_image002" style="display: inline; background-image: none;" alt="clip_image002" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image002_thumb-2.png" border="0"></a></p>
<p>If you’re going to use Linux (Ubuntu, Debian) flavor then you’d have to following the following instructions </p>
<h5>Manual install instructions</h5>
<p>If you don&#8217;t want to run a script as superuser or the all-in-one script fails, follow these steps to install the Azure CLI.</p>
<ol>
<li>
<h2>Get packages needed for the install process:</h2>
<p>bash</p>
<pre>

<div>::CODECOLORER_BLOCK_1::</div>

</pre>
<li>
<h2>Download and install the Microsoft signing key:</h2>
<p>bash</p>
<pre>

<div>::CODECOLORER_BLOCK_2::</div>

</pre>
<li>
<h2>Add the Azure CLI software repository:<br />
</h2>
<p>bash</p>
<pre>

<div>::CODECOLORER_BLOCK_3::</div>

</pre>
<li>
<h2>Update repository information and install the</p>
<div>::CODECOLORER_BLOCK_4::</div>
<p>package:</h2>
<p>bash</p>
<pre>

<div>::CODECOLORER_BLOCK_5::</div>

</pre>
</li>
</ol>
<p>Run the Azure CLI with the</p>
<div>::CODECOLORER_BLOCK_6::</div>
<p>command. To sign in, use the <a href="https://docs.microsoft.com/en-us/cli/azure/reference-index#az-login">az login</a> command.</p>
<ol>
<li>
<h2>Run the</p>
<div>::CODECOLORER_BLOCK_7::</div>
<p>command.</h2>
<p>Azure CLI</p>
<p>Try It</p>
<pre>

<div>::CODECOLORER_BLOCK_8::</div>

</pre>
<p>If the CLI can open your default browser, it will do so and load an Azure sign-in page.</p>
<p>Otherwise, open a browser page at <a href="https://aka.ms/devicelogin">https://aka.ms/devicelogin</a> and enter the authorization code displayed in your terminal.</p>
<li>
<h2>Sign in with your account credentials in the browser.</h2>
</li>
</ol>
<p>To learn more about different authentication methods, see <a href="https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli?view=azure-cli-latest">Sign in with Azure CLI</a>.</p>
<h2>Deploying Linux (CentOS):</h2>
<h4>Creating a Resource Group for Azure Container Instances (ACI)</h4>
<p>We will start first by creating a Resource Group for our Machine, calling it a AzureLinuxServersGroup to easily identify that this group contains our Linux Servers</p>
<p>az group create &#8211;name AzureLinuxServersGroup &#8211;location westeurope</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image0014-1.png"><img width="934" height="222" title="clip_image001[4]" style="margin: 0px; display: inline; background-image: none;" alt="clip_image001[4]" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image0014_thumb-1.png" border="0"></a></p>
<h4>Next we will be creating a container to contain the Linux OS on the resource group which we have just created</h4>
<p>First, How we know which Image to use and if that will be proper for our deployment? </p>
<p>To answer that, we will use the following command which will view the available latest edition Linux OS with different flavors. </p>
<p>I would like to use CentOS since its identical to RedHat and used by majority of Enterprises. </p>
<h2>To list the Images, Enter the following command </h2>
<p>az vm image list &#8211;output table</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image0024.png"><img width="1028" height="219" title="clip_image002[4]" style="margin: 0px; display: inline; background-image: none;" alt="clip_image002[4]" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image0024_thumb.png" border="0"></a></p>
<p>Notice there are many columns, The one which we are going to use in terminal command line is the UrnAlias. It&#8217;s important to remember this.</p>
<p>az vm create \</p>
<p>&#8211;resource-group AzureLinuxServersGroup \</p>
<p>&#8211;name AzureCentOSWP \</p>
<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2523 " id="quads-ad2523" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<p>&#8211;image CentOS \</p>
<p>&#8211;admin-username Moh10lyUser \</p>
<p>&#8211;generate-ssh-keys</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image003-2.png"><img width="536" height="130" title="clip_image003" style="margin: 0px; display: inline; background-image: none;" alt="clip_image003" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image003_thumb-2.png" border="0"></a></p>
<p>Since we are using Bash, It&#8217;s a case sensitive and it complained about user having capital letters. So we&#8217;ll go ahead and use small letters</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image004-2.png"><img width="1028" height="34" title="clip_image004" style="margin: 0px; display: inline; background-image: none;" alt="clip_image004" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image004_thumb-2.png" border="0"></a></p>
<p>After running the command with small letters, it&#8217;s telling us where we can find the keys in order for us to reach and get them to use later to login to this newly created machine. </p>
<p>SSH key files &#8216;/home/moh10ly/.ssh/id_rsa&#8217; and &#8216;/home/moh10ly/.ssh/id_rsa.pub&#8217; have been generated under ~/.ssh to allow SSH access to the VM. If using machines without permanent storage, back up your keys to a safe location.</p>
<p>The deployment of the machine takes about 3 mins, and it&#8217;ll be created with the default minimum resources. Let&#8217;s view </p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image005-2.png"><img width="1028" height="54" title="clip_image005" style="margin: 0px; display: inline; background-image: none;" alt="clip_image005" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image005_thumb-2.png" border="0"></a></p>
<p>Our machine is ready to be accessed now</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image006-2.png"><img width="1028" height="172" title="clip_image006" style="margin: 0px; display: inline; background-image: none;" alt="clip_image006" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image006_thumb-2.png" border="0"></a></p>
<p>In order for you to get the SSH Keys, you&#8217;ll have to have a bit of knowledge </p>
<p>I am going to go the location mentioned previously after creating a machine and copy the keys from the bash screen into a file. Save the file and Import it into SSH client which I will be using (Bitvise in my case).</p>
<p>From the bash screen goto cd /</p>
<p>Cd /home/user/.ssh/</p>
<p>Cat id_rsa hit enter and copy the key and save it into notepad. </p>
<p>Cat id_rsa.pub and copy/save into a notepad as the public key.</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image007-2.png"><img width="1028" height="504" title="clip_image007" style="margin: 0px; display: inline; background-image: none;" alt="clip_image007" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image007_thumb-2.png" border="0"></a></p>
<p>After loading both keys, I was able to successfully login to the Server</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image008-2.png"><img width="969" height="337" title="clip_image008" style="margin: 0px; display: inline; background-image: none;" alt="clip_image008" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image008_thumb-2.png" border="0"></a></p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image009-2.png"><img width="1028" height="530" title="clip_image009" style="margin: 0px; display: inline; background-image: none;" alt="clip_image009" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image009_thumb-2.png" border="0"></a></p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image010-2.png"><img width="861" height="313" title="clip_image010" style="margin: 0px; display: inline; background-image: none;" alt="clip_image010" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image010_thumb-2.png" border="0"></a></p>
<h2>Get a list of Azure VMS </h2>
<p><a href="https://docs.microsoft.com/en-us/cli/azure/vm/image?view=azure-cli-latest#az-vm-image-list">az vm image list</a></p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image011-1.png"><img width="784" height="757" title="clip_image011" style="margin: 0px; display: inline; background-image: none;" alt="clip_image011" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image011_thumb-1.png" border="0"></a></p>
<h4>Let&#8217;s List and deploy a WordPress on CentOS</h4>
<p>To view the list of available CentOS images, we&#8217;ll use the following cli command</p>
<p>az vm image list -f CentOS &#8211;all</p>
<p>The image needs to be grabbed from dockerhub URL </p>
<p>cognosys:wordpress-with-centos-77-free:wordpress-with-centos-77-free:1.2019.1008</p>
<p>az container create &#8211;resource-group mohazbackupgroup &#8211;name mohcontainer &#8211;os-type Linux &#8211;image cognosys:wordpress-with-centos-77-free:wordpress-with-centos-77-free:1.2019.1008 &#8211;dns-name-label azmohlinux &#8211;ports 22</p>
<h4>Create Windows Server core with IIS </h4>
<p>az container create &#8211;resource-group mohazbackupgroup &#8211;name mohcontainer &#8211;os-type windows &#8211;image mcr.microsoft.com/windoervercore/centos &#8211;dns-name-label azmohlinux &#8211;ports 22ws/servercore/iis:nanoserver &#8211;dns-name-label azmohiis &#8211;ports 80</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image012-1.png"><img width="1028" height="52" title="clip_image012" style="margin: 0px; display: inline; background-image: none;" alt="clip_image012" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image012_thumb-1.png" border="0"></a></p>
<p>Here we go I got a machine ready (took about 5 mins) </p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image013-1.png"><img width="1028" height="486" title="clip_image013" style="margin: 0px; display: inline; background-image: none;" alt="clip_image013" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image013_thumb-1.png" border="0"></a></p>
<p>azmohiis.westeurope.azurecontainer.io</p>
<p>To delete the container, you can write the following</p>
<p>az container delete &#8211;resource-group mohazbackupgroup &#8211;name mohcontainer</p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image014-1.png"><img width="826" height="44" title="clip_image014" style="margin: 0px; display: inline; background-image: none;" alt="clip_image014" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image014_thumb-1.png" border="0"></a></p>
<p><a href="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image015-1.png"><img width="1003" height="597" title="clip_image015" style="display: inline; background-image: none;" alt="clip_image015" src="https://www.moh10ly.com/wp-content/uploads/2020/01/clip_image015_thumb-1.png" border="0"></a></p>
<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2524 " id="quads-ad2524" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>

<p>Stay tuned for more articles about Azure.</p>

<!-- WP QUADS Content Ad Plugin v. 2.0.92 -->
<div class="quads-location quads-ad2530 " id="quads-ad2530" style="float:none;margin:0px 3px 3px 3px;padding:0px 0px 0px 0px;" data-lazydelay="0">

</div>


Reset and manage your Active Directory users' Passwords Active Directory is one of the most…
Finding Exchange Database hidden mailboxes. Story:Maybe you have been in this situation before, trying to…
If you're using a Proxy server in your firewall or in your network and have…
Story:I got some clients that have reported some of their users being locked out and…
Delegate Permissions This is a code that I have wrote recently to check if an…
Story: I got a request from a client who constantly gets CVs and have to…