How can you move your generalized (sysprepped) Windows VHD to Azure ARM in just a few steps?
1) Prepare your standard Azure management client environment as explained in my previous blog. Keep all the modules up to date.
2) Create a new Resource Group in Azure https://portal.azure.com.
3) Inside the Resource Group create a new Storage Account of your choice, prefer Locally Redundant Storage for simple requirements and its pricing advantages.
4) Create a new container in the Storage Account. Copy the sysprepped generalized Windows VHD file from on-premises to the Storage Account container either by using Microsoft Azure Storage Explorer or AZCopy command, of blob type as page blob.
5) Change the variables below accordingly. Then run the powershell command to create your VM in a new VNET and subnet.
# variables - update these variables according to your needs and current settings $rgName = "myRGinWestEurope" $StorageAccountName = "myStorageAccount" $vmSize = "Standard_A2" $urlOfUploadedImageVhd = "https://myawesometorage1.blob.core.windows.net/testblobs/WinServer12r2.vhd" $vnetAddressPrefix = "10.0.0.0/16" $vnetSubnetAddressPrefix = "10.0.64.0/24" $pipName = "testpip6" $subnet1Name = "testsub6" $nicname = "testnic6" $vnetName = "testvnet6" $vmName = "testupldvm6" $osDiskName = "testupos6" $computerName = "testupldcomp6" $subs = "Visual Studio Ultimate with MSDN" $newadminuser = "localadmin" $newadminpassword = 'Pa55word5' $cred = Get-CredentialLogin-AzureRmAccount -Credential $cred Get-AzureRmSubscription –SubscriptionName $subs | Select-AzureRmSubscription | Set-AzureRmContext $storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $rgName -Name $StorageAccountName $pip = New-AzureRmPublicIpAddress -Name $pipName -ResourceGroupName $rgName -Location $location -AllocationMethod Dynamic $subnetconfig = New-AzureRmVirtualNetworkSubnetConfig -Name $subnet1Name -AddressPrefix $vnetSubnetAddressPrefix $vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $location -AddressPrefix $vnetAddressPrefix -Subnet $subnetconfig $nic = New-AzureRmNetworkInterface -Name $nicname -ResourceGroupName $rgName -Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id $vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
# if you are deploying a Linux machine, replace the -Windows switch with a -Linux switch.
# Setup OS & Image $securePassword = ConvertTo-SecureString $newadminpassword -AsPlainText -Force $crednew = New-Object System.Management.Automation.PSCredential ($newadminuser, $securePassword) $vm = Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows -ComputerName $computerName -ProvisionVMAgent -EnableAutoUpdate -Credential $crednew $vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id $osDiskUri = '{0}vhds/{1}{2}.vhd' -f $storageAcc.PrimaryEndpoints.Blob.ToString(), $vmName.ToLower(), $osDiskName
# if you are deploying a Linux machine, replace the -Windows switch with a -Linux switch.
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption fromImage -SourceImageUri $urlOfUploadedImageVhd -Windows $result = New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm $result