Steps to create Linux and Windows VM using code

609 0
MacBook Pro on top of brown table

Commands

  1. az login –subscription “Study”
  2. az account list-locations
  3. az group create –name “rgstudy” –location “eastasia”
  4. az group list -0 table
  5. az network vnet create –resource-group “rgstudy” –name “vnet-rgstudy” –address-prefix “10.1.0.0/16” –subnet-name “rgstudy-subnet-1”–subnet-prefix “10.1.1.0/24”
  6. az network vnet list -o table
  7. az network public-ip create –resource-group “rgstudy” –name “rgstudy-linux-pip-1”
  8. az network nsg create –resource-group “rgstudy” –name “rgstudy-linux-nsg-1”
  9. az network nsg list -o table
  10. az network nic create –resource-group “rgstudy” –name “rgstudy-linux-nic-1” –vnet-name “vnet-rgstudy” –subnet “rgstudy-subnet-1” –network-security-group “rgstudy-linux-nsg-1” –public-ip-address “rgstudy-linux-pip-1”
  11. az network nic list -o table
  12. ssh-keygen -m PEM -t rsa -b 4096
  13. az vm image list -o table
  14. az vm create –resource-group “rgstudy” –location “eastasia” –name “rgstudy-vm-linux-1” –nics “rgstudy-linux-nic-1” –image “RHEL” –admin-username “demoadmin” –authentication-type “ssh” –ssh-key-value ~/.ssh/id_rsa.pub
  15. az vm open-port –resource-group “rgstudy” –name “rgstudy-vm-linux-1” –port “22”
  16. az vm list-ip-addresses –name “rgstudy-vm-linux-1” –output table

    To  Create Windows VM, we can use same  resource group and existing vnet

 

  1. we’re going to place this server in the existing resource group.
  2.  we’re going to place this server in the same vnet
  3. az network public-ip create –resource-group “rgstudy” –name “rgstudy-win-1-pip-1”
  4. az network nsg create –resource-group “rgstudy” –name “rgstudy-win-nsg-1”
  5. az network nic create –resource-group “rgstudy” –name “rgstudy-win-1-nic-1” –vnet-name “vnet-rgstudy” –subnet “rgstudy-subnet-1” –network-security-group “rgstudy-win-nsg-1” –public-ip-address “rgstudy-win-1-pip-1”
  6. az vm create –resource-group “rgstudy” –name “rgstudy-win-1” –location “eastasia” –nics “rgstudy-win-1-nic-1” –image “win2016datacenter” –admin-username “sls-admin” –admin-password “VFBnwLTX8ufnHuRTAjt5”
  7. az vm open-port –port “3389” –resource-group “rgstudy” –name “rgstudy-win-1”
  8. az vm list-ip-addresses –name “rgstudy-win-1”  –output table

https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest

https://docs.microsoft.com/en-us/cli/azure/format-output-azure-cli?view=azure-cli-latest

 

Leave a Reply