Add-AzVhd
Uploads a virtual hard disk from an on-premises machine to Azure (managed disk or blob).
Syntax
DefaultParameterSet (Default)
Add-AzVhd
[-ResourceGroupName] <String>
[-Destination] <Uri>
[-LocalFilePath] <FileInfo>
[[-NumberOfUploaderThreads] <Int32>]
[[-BaseImageUriToPatch] <Uri>]
[-OverWrite]
[-SkipResizing]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
DirectUploadToManagedDiskSet
Add-AzVhd
[-ResourceGroupName] <String>
[-LocalFilePath] <FileInfo>
[-Location] <String>
[[-NumberOfUploaderThreads] <Int32>]
-DiskName <String>
[-DiskSku <String>]
[-DiskZone <String[]>]
[-DiskHyperVGeneration <String>]
[-DiskOsType <OperatingSystemTypes>]
[-DataAccessAuthMode <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Add-AzVhd cmdlet uploads an on-premise virtual hard disk to a managed disk or a blob storage account.
The virtual hard disk being uploaded needs to be a .vhd file and in size N * Mib + 512 bytes. Using Hyper-V
functionality, Add-AzVhd will convert any .vhdx file to a .vhd file and resize before uploading.
To allow this functionality, you will need to enable Hyper-V .
If you are using a Linux machine or choose to not use this functionality, you will need to resize the VHD file manually .
Additionally, Add-AzVhd will convert dynamically sized VHD files to fixed size during upload. Use -Verbose
to follow all the process.
For Default Parameter set (upload to blob), also supported is the ability to upload a patched version of an on-premises .vhd file.
When a base virtual hard disk has already been uploaded, you can upload differencing disks that use the base image as the parent.
Shared access signature (SAS) URI is supported also.
For Direct Upload to Managed Disk Parameter set, parameters: ResourceGroupName, DiskName, Location, DiskSku, and Zone will be used to
create a new disk, then the virtual hard disk will be uploaded to it.
More information on using Add-AzVhd to directly upload to a managed disk .
For VHD files greater than 50 GB, we recommend using AzCopy for faster upload.
Examples
Example 1: Add a VHD file to a blob
Add-AzVhd -Destination "http://contosoaccount.blob.core.windows.net/vhdstore/win7baseimage.vhd" -LocalFilePath "C:\vhd\Win7Image.vhd"
This command adds a .vhd file to a storage account.
Example 2: Add a VHD file to a blob and overwrite the destination
Add-AzVhd -Destination "http://contosoaccount.blob.core.windows.net/vhdstore/win7baseimage.vhd" -LocalFilePath "C:\vhd\Win7Image.vhd" -Overwrite
This command adds a .vhd file to a storage account.
The command overwrites an existing file.
Example 3: Add a VHD file to a blob with number of threads specified
Add-AzVhd -Destination "http://contosoaccount.blob.core.windows.net/vhdstore/win7baseimage.vhd" -LocalFilePath "C:\vhd\Win7Image.vhd" -NumberOfUploaderThreads 32
This command adds a .vhd file to a storage account.
The command specifies the number of threads to use to upload the file.
Example 4: Add a VHD file to a blob and specify the SAS URI
Add-AzVhd -Destination "http://contosoaccount.blob.core.windows.net/vhdstore/win7baseimage.vhd?st=2013-01 -09T22%3A15%3A49Z&se=2013-01-09T23%3A10%3A49Z&sr=b&sp=w&sig=13T9Ow%2FRJAMmhfO%2FaP3HhKKJ6AY093SmveO SIV4%2FR7w%3D" -LocalFilePath "C:\vhd\win7baseimage.vhd"
This command adds a .vhd file to a storage account and specifies the SAS URI.
Example 5: Add a VHD file directly to a managed disk.
Add-AzVhd -LocalFilePath C:\data.vhd -ResourceGroupName rgname -Location eastus -DiskName newDisk
This command create a managed disk with given ResourceGroupName, Location, and DiskName; and uploads the VHD file to it.
Add-AzVhd -LocalFilePath C:\Data.vhdx -ResourceGroupName rgname -Location eastus -DiskName newDisk -Zone 1 -DiskSku Premium_LRS
This command will tried to convert vhdx file to vhd file first using Hyper-V. If Hyper-V is not found, it will return an error asking to use a vhd file. After successful conversion, it will create a managed disk with provided parameters, then upload the vhd file.
Parameters
-AsJob
Run cmdlet in the background and return a Job to track progress.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-BaseImageUriToPatch
Specifies the URI to a base image blob in Azure Blob Storage.
An SAS can be specified as the value for this parameter.
Parameter properties
Type: Uri
Default value: None
Supports wildcards: False
DontShow: False
Aliases: bs
Parameter sets
DefaultParameterSet
Position: 4
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DataAccessAuthMode
Additional authentication requirements when exporting or uploading to a disk or snapshot. Possible options are: "AzureActiveDirectory" and "None".
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
DirectUploadToManagedDiskSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Destination
Specifies the URI of a blob in Blob Storage.
The parameter supports SAS URI, although patching scenarios destination cannot be an SAS URI.
Parameter properties
Type: Uri
Default value: None
Supports wildcards: False
DontShow: False
Aliases: dst
Parameter sets
DefaultParameterSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DiskHyperVGeneration
The hypervisor generation of the Virtual Machine. Applicable to OS disks only. Posssible values are: 'V1', 'V2'.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: HyperVGeneration
Parameter sets
DirectUploadToManagedDiskSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DiskName
Name of the new managed Disk
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
DirectUploadToManagedDiskSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DiskOsType
The Operating System type of the managed disk. Possible values are: 'Windows', 'Linux'.
Parameter properties
Type: OperatingSystemTypes
Default value: None
Accepted values: Windows, Linux
Supports wildcards: False
DontShow: False
Aliases: OsType
Parameter sets
DirectUploadToManagedDiskSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DiskSku
Sku for managed disk. Options: Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
DirectUploadToManagedDiskSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DiskZone
The Logical zone list for Disk.
Parameter properties
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
Aliases: Zone
Parameter sets
DirectUploadToManagedDiskSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-LocalFilePath
Specifies the path of the local .vhd file.
Parameter properties
Type: FileInfo
Default value: None
Supports wildcards: False
DontShow: False
Aliases: lf
Parameter sets
(All)
Position: 2
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Location
Location of new Managed Disk
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
DirectUploadToManagedDiskSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-NumberOfUploaderThreads
Specifies the number of uploader threads to be used when uploading the .vhd file.
Parameter properties
Type: Nullable<T> [ Int32 ]
Default value: None
Supports wildcards: False
DontShow: False
Aliases: th
Parameter sets
(All)
Position: 3
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-OverWrite
Indicates that this cmdlet overwrites an existing blob in the specified destination URI, if one exists.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: o
Parameter sets
DefaultParameterSet
Position: 5
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceGroupName
Specifies the name of the resource group of the virtual machine.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-SkipResizing
Skips the resizing of the VHD file.
Users that wish to upload a VHD files that has its size misaligned (not N * Mib + 512 bytes) to a blob can use this switch parameter.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
DefaultParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs