Azure - CLI 2.0(Latest) - Set up a Windows VM on Azure from MacOS

Problem Definition

How to set up a resource group, virtual machine, enable port 80 and finally delete the resource group using CLI 2.0.

Prerequisites

  • Azure portal subscription.
  • Microsoft Remote desktop app installed on your MacOS.
  • Azure CLI 2.0 installed on your mac. If its not please visit.

Step by Step process

Log-in
There are more than 1 way to log in to Azure Portal using CLI 2.0 such as Interactive, Command Line, Log-in with specific tenant and Log-in with specific service. Easiest and most user friendly way to login is interactive where we use 'az login' command on Azure CLI and then follow the guided instructions to complete the process.                

  • Write az login on terminal window and hit enter




  • Open your web browser and go to the given address and enter the code where asked and hit continue.

  • Now you will asked to login with you portal credentials

  • On your terminal window you should see JSON displaying various details.



Create Resource Group
Since we have successfully made a connection with Azure from CLI. Next step in the process is to create a resource group.


  • use command 'az group create --rg-name BRodeo --location eastus'


  • Confirmation from Portal


Create Windows 2016 VM
 Next step in the process is to try to create a windows VM from terminal.


  • use command 'az vm create  --resource-group BRodeo --vm-name brwin201601 --image win2016datacenter --admin-username ********* --admin-password ********'


  • Confirmation from Portal. Also notice the default size of VM its Standard DS1 v2.



Use your VM public IP and Port in Microsoft Remote Desktop app and use admin credentials specified while creation to log in into your newly created VM.


Enable 80 Port for public access
On Azure CLI run the command 'az vm open-port --port 80  --resource-group BRodeo --vm-name brwin201601 '

Install WebServer feature on your VM
On your virtual machine run the command 'Install-WindowsFeature -name Web-Server -IncludeManagementTools'



Use your public IP in your browser and it should pull default IIS page confirming your VM and your Web Server(IIS) are up and running.





Delete Resource Group
If you do not need your VM any more like more me there is no purpose for this VM. You can delete the resource group it will clean up all the resources associated with the VM like OS disks, subnets etc.

On Azure CLI run the command ' az group delete  --resource-group BRodeo'

Reference

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-cli

Related

Azure - CLI 2.0(Latest) - Setup on MacOS

Comments

Popular posts from this blog

Azure - Manage Blob Storage - Part #7 - Add Metadata to an Existing Container using C#

Azure - Manage Blob Storage - Part #5 - Create Folder Structure and upload a file to folder using an Existing Container using C#

Algorithm - Breadth First Search(BFS) - Python(3)