21 comments

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

    Junle Li Beantwoorden

  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 Beantwoorden

  3. Thanks a lot, worked perfectly 😉

    Andi Beantwoorden

  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 Beantwoorden

  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 Beantwoorden

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

    claudio Beantwoorden

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

    thibault Beantwoorden

  8. 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 Beantwoorden

  9. 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 Beantwoorden

  10. 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 Beantwoorden

  11. Very easy to follow steps! Thanks!

    Lee Beantwoorden

  12. 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 Beantwoorden

  13. 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 Beantwoorden

  14. good blog!!

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

    Basharat Tamboli Beantwoorden

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

    JM Beantwoorden

  16. 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 Beantwoorden

  17. 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 Beantwoorden

  18. 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 Beantwoorden