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.
- Open your web browser and go to the given address and enter the code where asked and hit continue.
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.
- 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'

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'
Comments
Post a Comment