You are browsing the archive for Azure subscription.

Step-by-step: Move an Azure IaaS VM between different Azure Subscriptions

11:22 am in Azure, Azure subscription, Cloud, IaaS, Microsoft Azure Storage Explorer, Public Cloud by Wim Matthyssen

From time to time, customers ask me to migrate Azure IaaS virtual machines (VMs) between Azure Subscriptions (for example moving a VM between the Dev subscription and the Prod subscription). There are several ways to accomplish this move, you can use Azure PowerShell or Azure Site Recovery (ASR), but mostly I do it the way that I will describe below.

1) First of all, you need to download an Azure Storage Explorer which enables you to move the VHD (page blob) which is used by the IaaS VM from one storage account (Azure Subscription 1) to another (Azure Subscription 2). Mostly I use the Microsoft Azure Storage Explorer which you can download for free via following link:


2) When downloaded and installed you’ll need to add the two Azure Blob Storage Accounts, the one you want to move the VHD from and the one you want to move the VHD to. Open up the Microsoft Azure Storage Explorer, right click Storage Accounts and select Connect to Azure storage…


3) To find the Storage Account name and the Account key, just logon to the Classic Azure portal ( Go to STORAGE select the correct Storage Account and click MANAGE ACCESS KEYS.



4) Fill in the correct Account name (STORAGE ACCOUNT NAME) and the Account key (PRIMARY ACCESS KEY)



5) Repeat steps 3 to 5 also for the Storage Account in the other Azure Subscription. At the end two Storage Accounts should be available to use in the Microsoft Azure Storage Explorer


6) Now stop the VM (logon trough RDP and choose shutdown) and you are good to copy/paste your VM’s VHD from one Storage Account to another


7) Open up Microsoft Azure Storage Explorer, right click the VHD for the VM you just stopped and select Copy


8) Open the other Storage Account’s Blob container (in my example azureos01 – Blob Containers – vhds) and select Paste. Be aware that this copy can take some time depending on the size of the VHD




9) When the VHD is completely copied, open the Azure classic portal and logon to the second Azure Subscription. Go to VIRTUAL MACHINES, then DISKS and select CREATE A DISK


10) Fill in a NAME (for example AZ-VM-SUB2) and select the correct VHD URL from the storage you just moved your VHD file to. Mark “The VHD contains an operating system.” and select Windows. Click the check mark to finish





11) As the next step create a new VM. Click NEW – COMPUTE – VIRTUAL MACHINE – FROM GALLERY


12) Select MY DISKS and select the newly created disk (in my example AZ-VM-SUB2)


13) In the next screen choose a proper VIRTUAL MACHINE NAME, the TIER and the VM SIZE


14) Create a new CLOUD SERVICE or select an existing one, choose the correct VNET and SUBNET. If an AVAILIBILITY SET is required, select or create it


15) Select the ENDPOINTS you require and finally press the check mark icon to start provisioning the VM


16) Like you can see the VM is created and starts Running. You should now able to connect to it again with RDP



17) If the VM looks and reacts like it should, you can delete the original VM with the attached VHD in the first Azure Subscription. Also don’t forget to delete the Cloud Service

This concludes this blog post, hope it helps!

Wim Matthyssen (@wmatthyssen)

Clean up Azure PowerShell when using different Azure subscriptions

12:34 pm in Azure, Azure PowerShell, Azure subscription, Cloud, PowerShell by Wim Matthyssen

Hi all,

These days I’m working on several Azure projects for different clients. As a result, my default subscription data file which is used by Azure PowerShell is completely filled up with settings from those different subscriptions. Frequently, I notice that Azure PowerShell mixes up all this information and does not perform as expected. I strongly assume this is caused by the cached credentials and other elements. In order to fix this, I regulary clean up my Azure PowerShell to have a better overview and to accomplish a better working scripting environment. Below you can find the Azure PowerShell cmdlets to clear a specific customer’s Azure subscription from Azure PowerShell. I will also show you how you can clear your complete Azure profile.

Delete a specific Azure subscription from PowerShell

1) Open up PowerShell ISE as an Administrator and run the following PowerShell cmdlets to list all Azure subscriptions available in the default subscription data file on the computer in use, which can be found under the following location C:\Users\%username%\AppData\Roaming\Windows Azure PowerShell and is named AzureProfile.json


2) To delete a specific subscription from the date file run the below cmdlet (adjust for your own purpose). You may be sure that this cmdlet will not delete the subscription from Azure in any way. You can use this cmdlet with the -Force parameter to suppress the confirmation prompt


3) If the above cmdlet ran without any errors the specific subscription will not be shown anymore when you’re re run the Get-AzureSubscription cmdlet and it should also be cleared from the subscription data file

Clear your complete Azure Profile

1) Open up PowerShell ISE as an Administrator and run the following PowerShell cmdlets to completely clear your Azure Profile on the computer in use


2) If the cmdlet ran without any errors your Azure Profile should be cleared.

This ends this short blog post, hope it helps and till next time!

Wim Matthyssen (@wmatthyssen)