Copy a VHD from your post to Azure (and vice versa) [Exclusive Guide]

being currently on mission in Azure, you should see several articles on the Microsoft cloud in the coming weeks! 🙂 – In all these articles I’m going to assume that you already have a basic knowledge and that you have already handled the Azure portal ( see the same you know sign in PowerShell ).

Today, I propose to see together how connect in PowerShell to Azure then copy the VHD to one of your virtual machines to perform a backup or just to copy to better the re – use and/or duplicate so your virtual machine. We will see 2 cases: copy the VHD in Azure to your local station and vice versa .

Step 1 – Connect in PowerShell to your account Azure

Login-AzureRmAccount

this first command will start a window in which you can identify and access in PowerShell different resources Azure.

For a given account, you can have several subscribtions Azure. To see them, use the following command:

Get-AzureRmSubscription

for each subscribe owned, you will then have the SubscribtionID, the SubscribtionName, State, TenantId and possibly other information.

You must now choose the subscription that you want to work . To do this, use the following CmdLet:

replace of course with your data. In my case, I will connect to the subscription which depends on my MSDN account. It is easy to recognize because it has a name of the style: Visual Studio Premium with MSDN .

Step 2 – Copy a VHD from Azure your your post

as a first step, we must identify the VHD to the virtual machine that you want to archive. To do this, since the Azure portal, select your ResourceGroup and virtual machine. Click in the subsections Disks and you should see the drive hard system associated with your virtual machine.

If you go a little to the right, then you will see the exact path of the VHD storage corresponding to the virtual machine. Copy-paste this link, we will need to later .

Of course, we could recover information from this link with with the CmdLet Get-AzureRMVM and a few well-chosen parameters! 🙂

you can then use the following command ( with keep the same prompt PowerShell in which you are identified and selected the desired… subscribe ):

Ceci will have a backup of your VHD to a local path of your workstation to achieve (libre à vous d’adapter vers un disque dur externe ou tout autre chemin de stockage bien entendu) . ” Attention, you must dispose of enough space to store all of the VHD on your workstation if not you will have an error message.

After a few moments, and according to the type of Internet connection you have, you find the VHD in your folder ( indicatively fiber optic, it takes me between 10 and 20 minutes for 100 to 150 GB ).

You can now open your VHD from within Windows Explorer or open it in Hyper-V to carry out any changes you may need.

Step 3 – Copy a local VHD to Azure

in this third step, we’re going this time to perform the reverse operation. We have prepared a VHD on our position that we want to transfer it now on Azure . The goal is to transfer it from your desktop to your container on Azure.

To do this, always in your ResourceGroup , you must identify your Storage Account as well as the container in which you want to send your VHD . From the portal, proceed as shown on the picture below.

Once you have located your Storage Account and container concerned. Click on it and choose top-right Properties to get the link where we will store our VHD ( in my case it is the same but I’ll show you the approach ).

He is then to use the following CmdLet to send your local to Azure VHD in this container which we recovered the URL: