Skip to content

Instantly share code, notes, and snippets.

@PatrickLang
Last active April 21, 2023 18:02
Show Gist options
  • Save PatrickLang/39831283ce88631ff9cdf5784e194ef1 to your computer and use it in GitHub Desktop.
Save PatrickLang/39831283ce88631ff9cdf5784e194ef1 to your computer and use it in GitHub Desktop.
Building a Windows Insider VM and running in Azure

Here's example steps for uploading a Windows VHD to Azure. I initially built mine using this Packer script, then used PowerShell to convert it - Convert-VHD -VHDType Fixed -Path <source.vhdx> -DestinationPath WindowsServer2016Insider.vhd, and last the Azure CLI 2.0 to upload it.

az login

# If you need to use a specific subscription, then 
# az account set --subscription <subscription name>

# Resource group to contain all resources
export rg=<resourcegroupname>

# Storage account name
export storageacct=<storageacctname>

# VHD filename
export vhdfilename=WindowsServer2016Insider.vhd

# Azure disk name
export diskname=vm1disk1

# VM name
export vmname=vm1

az group create --name $rg --location westus2
az storage account create --resource-group $rg --location westus2 --name $storageacct --kind Storage --sku Standard_LRS
az storage container create --account-name $storageacct --name mydisks
az storage account keys list --resource-group $rg --account-name $storageacct
# Get key from that step
az storage blob upload --account-name $storageacct --account-key "<key>" --container-name mydisks --type page --file /mnt/d/VMs/.../WindowsServer2016Insider.vhd --name WindowsServer2016Insider.vhd
az storage blob url --account-name $storageacct --account-key "<key>" --container-name mydisks --name $vhdfilename
az disk create --resource-group $rg --name $vm1disk1 --source "https://$storageacctname.blob.core.windows.net/mydisks/WindowsServer2016Insider.vhd"
az vm create --resource-group $rg  --location westus2 --name $vmname --os-type windows --attach-os-disk $diskname  --size standard_d2_v3

# Take note of public IP returned

# Now connect with remote desktop
mstsc.exe /v:<ip> &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment