There have been multiple blogs on this on internet but still I faced problems during assigning values to variable or while checking order of commands. So here comes my blog with sample values and easy to understand and use.
Here we will see , how you can copy Images(internally vhd) from one subscription to another.
Steps to follow:-
1. Define Source Subscription Details and create Source Context
You can get the storage account key from Azure management portal. Go to Storage tab->Select your Storage-> Manage Access Keys –> Copy Primary Access key.
To get information about Source Image. Go to Virtual Machine Tab-> Images-> Select Image –> On details page you can see the vhd location which is the blob url. This url also helps you to identify blob name, storage account name and container name.
2. Define Destination Subscription Details and create destination Context
3. Create Destination container if not exists
4. Start Copying the Blob vhd
After this command is executed successfully, you may need to wait for some time for copy operation to be completed. Though your PowerShell window will complete execution within no time, the copy operation in Azure takes some time to complete. The whole script will look like below:-
Once your vhd is copied. Follow below steps to create Image:-
1. Go To Virtual Machine Tab –> Images
2. Click on create –> Give Name and Description –> Browse VHD, just copied using above steps.
3. Click on OK
Your Image is ready, you can now use it to create Virtual Machines. Happy Coding!!!