I'm trying to import VHD via PowerShell in a Virtual Machine but am getting errors.
Add-AzureRmVhd : Resource group 'ResourceGroupName' could not be found.
At line:1 char:1
+ Add-AzureRmVhd -ResourceGroupName ResourceGroupName -destination
"https ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmVhd], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.StorageServices.AddAzureVhdCommand
These are the steps I am following:
Add-AzureRmVhd -ResourceGroupName VMWinServerFtH -destination "https://vhdexternal.blob.core.windows.net/oldvhd/test.vhd" -LocalFilePath "C:\Users\administrador\Desktop\disk.vhd"
I've already verified the correct spelling of the resource group name.
Note that: AzureRM PowerShell modules will be depreacted on 29 February 2024. Refer this MsDoc.
I have download VHD file from disk. To import VHD via PowerShell in a Virtual Machine check the below workaround.
Install-Module -Name az.compute -RequiredVersion 5.2.0
Get-Module
Now to import VHD file from local file to storage account you can make use of below commands:
The Add-AzVhd command uploads an on-premises virtual hard disk to a managed disk or a blob storage account.
Add-AzVhd -ResourceGroupName -<YourRGName> -Destination "http://contosoaccount.blob.core.windows.net/vhdstore/win7baseimage.vhd" -LocalFilePath "C:\vhd\WinImage.vhd"
To confirm in portal: