How to upload a Virtual machine VM to Azure storage
In this blog, we will see how to upload a VHD that was created in on-perm Hyper-v or VMWare to Azure
Prerequisites for uploading a VHD to Azure
- An Azure subscription
- Microsoft Azure PowerShell
- A VHD file
How to configure the PowerShell check this article https://docs.microsoft.com/en-us/powershell/azureps-cmdlets-docs/
Step 1: Preparing the VHD
The VHD that you are going to upload we must sysprep the VM
1: log in to the OS
2: Open the command prompt and change the directory to %windir%system32sysprep and then run susprep.exe
3. The sysprep tool box will appear
4.In the System Preparation Tool, select Enter System Out of Box Experience (OOBE) and make sure that Generalize is checked.
5.In Shutdown Options, select Shutdown.
6. Click OK.
Step 2: Creating a storage account or use the old storage account
We will first see how to create a new storage account and then upload the storage account
Open Azure PowerShell and type the below command to log into the azure account
Once we run the above command we will get a login page to log into your account
Get the subscription IDs for your available subscriptions.
Run the following command available in the subscription.
We must select the subscription that we must need to use to upload the VHD
Select-AzureSubscription -SubscriptionName MSDN
Step 3: Create a storage accountUse the Storage account that is already present
We can run the below command to see the storage account that are already present in your subscription
To create a new storage account, we can run the below command
New-AzureRmStorageAccount -ResourceGroupName MSGuruResourceGroup -Name MSGurustorageaccount -Location “West US” ` -SkuName “Standard_LRS” -Kind “MSGuruStorage”
Valid value for Skuname
Standard_LRS – Locally redundant storage.
Standard_ZRS – Zone redundant storage.
Standard_GRS – Geo redundant storage.
Standard_RAGRS – Read access geo redundant storage.
Premium_LRS – Premium locally redundant storage.
We must create a container in the storage that was created so that we can upload the VHD to that container
We can do it using GUI or through command
We must go to the storage and click on the container tab to create a new container in the storage.
Step 1: Select the storage as the default
Set-AzureSubscription -CurrentStorageAccountName <StorageAccountName> -SubscriptionName <SubscriptionName>
Step 2: Create a new container
New-AzureStorageContainer -Name <ContainerName> -Permission Off
Step 4: Uploading the VHD to your storage
We can use the add-azureRMVhd command to upload the file
This command requires few variables to upload the file
$RGName = Resource group name
$urlOfUploadedImageVhd = this will be the URL of your storage
You must place the VHD on a local drive and that path must be specified
We can go to the portal and confirm that our VHD is present in the location that we have specified in the command
Microsoft MVP | Exchange Server
Keywords: How to upload a VHD to Azure, upload a VM to azure, upload a virtual machine to Azure