Leave a Reply

21 comments

  1. Thank you for your awesome post! It solves my problem!

    Junle Li Reply

  2. Man,

    I was struggling to move resources from Free Trial (It was a production environment & about to expire) to Azure in Open subscription. Even the MS support was awful. Then I have decided to create the environment from scratch. I have created all the resources but VMs with Live Data 😐

    Luckily I have found this.

    You have saved my life. Thanks a million.

    Harsha Perera Reply

  3. Thanks a lot, worked perfectly 😉

    Andi Reply

  4. Worked a treat 🙂
    Existing VM on wrong VNet, deleted VM, grabed URL of VHD and used instead of uploading. Followed your script steps = success.

    Steve Reply

  5. AWESOME POST!

    I’m new to Azure and I’ve been working with MS Support and the litany of confusing information that I’ve receive left me really frustrated. Your post is clear and concise.

    Thank you, thank you!

    Darrell Reply

  6. I still don’t understand why this can’t be done via GUI.

    claudio Reply

  7. So many blog posts readen and this one saved my life.
    Thank you for you post. No nonsense. Just works.

    thibault Reply

  8. […] big thank you to Leon which this article allowed me to move forward on this point: https://blogs.infosupport.com/creating-a-vm-in-azure-based-on-an-uploaded-vhd/ . […]

    Creating a VM to Azure in PowerShell from a VHD existing [Exclusive Guide] | Tech Revwz Reply

  9. this is exactly what i needed, did a migration from asm to arm, trying to move subscriptions to CSP, issues with switching key vaults cross subscription.

    glad i found this, worked perfect.
    thank you

    johnson Reply

  10. Thank you so much. Life saver. MS support were awful in dealing with our migration from one subscription to the other. You scripts were easy to use and understandable

    Blue Reply

  11. Is there a way to add the VMs to an availability set during creation?

    It was possible to add Vms into an availability set in Classic mode, however it doesn’t seem possible in Resource Manager!

    Blue Reply

  12. Very easy to follow steps! Thanks!

    Lee Reply

  13. Been struggling for ages to be able to do this with little to no MS official support, combined with the Azure Storage Explorer this guide got the ball rolling with cloning Azure VMs for testing purposes. Thanks!

    Doc Reply

  14. Excellent and straight forward solution. We’re migrating VMs from our outdated servers on perm to Azure. I looked everywhere and this was by far the best tutorial. I should mention though that AzurePS kept asking for a logon to the subscription despite I already did several times. it turned out that the installation of AzurePS should be from the msi installer https://github.com/Azure/azure-powershell/releases/download/v4.4.0-September2017/azure-powershell.4.4.0.msi

    Good luck.
    M. Taha

    Mohammad Taha Reply

  15. good blog!!

    I want to do the same thing in Azure Stack what all changes do I need to make?

    Basharat Tamboli Reply

  16. Hi Leon,
    Is this applicable for Linux VM?
    Can I replace the script to Linux Redhat?
    -CreateOption Attach -Windows
    Thanks

    JM Reply

  17. Leon this is a great guide, could you please advise what needs to be adjusted to fire up a Linux VM in the same manner?

    Darren Smith Reply

  18. Amazing! Fixed an issue that I had been worried about digging into as it looked like a daunting task; your guide saved the day.

    Mike Morris Reply

  19. If your Network and VM is in different RG, Then you can use following Powershell. (Linux VM)

    Connect-AzureRmAccount
    Select-AzureRmSubscription -Subscription “”

    $RGvirtualNetworkName = “”
    $VMresourceGroupName = “”
    $virtualNetworkName = “”
    $VMName = “”
    $PIPName = “”
    $NICName = “”
    $VmSize = “”
    $destinationVhd = “”
    $locationName = “westeurope”

    $virtualNetwork = Get-AzureRmVirtualNetwork -ResourceGroupName $RGvirtualNetworkName -Name $virtualNetworkName
    $publicIp = New-AzureRmPublicIpAddress -Name $PIPName -ResourceGroupName $VMResourceGroupName -Location $locationName -AllocationMethod Dynamic
    $networkInterface = New-AzureRmNetworkInterface -ResourceGroupName $VMResourceGroupName -Name $NICName -Location $locationName -SubnetId $virtualNetwork.Subnets[1].Id -PublicIpAddressId $publicIp.Id

    $vmConfig = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
    $vmConfig = Set-AzureRmVMOSDisk -VM $vmConfig -Name $VMName -VhdUri $destinationVhd -CreateOption Attach -Linux
    $vmConfig = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $networkInterface.Id

    $vm = New-AzureRmVM -VM $vmConfig -Location $locationName -ResourceGroupName $VMresourceGroupName

    Ghanshyam Dusane Reply