Add-AzVhd
Uploads a virtual hard disk from an on-premises machine to Azure (managed disk or blob).
Syntax
Add-AzVhd
[-ResourceGroupName] <String>
[-Destination] <Uri>
[-LocalFilePath] <FileInfo>
[[-NumberOfUploaderThreads] <Int32>]
[[-BaseImageUriToPatch] <Uri>]
[-OverWrite]
[-SkipResizing]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Add-AzVhd
[-ResourceGroupName] <String>
[-LocalFilePath] <FileInfo>
-DiskName <String>
[-Location] <String>
[-DiskSku <String>]
[-DiskZone <String[]>]
[-DiskHyperVGeneration <String>]
[-DiskOsType <OperatingSystemTypes>]
[[-NumberOfUploaderThreads] <Int32>]
[-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.
Example 6: Add a VHD file directly to a more configured disk.
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.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | Uri |
Aliases: | bs |
Position: | 4 |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DataAccessAuthMode
Additional authentication requirements when exporting or uploading to a disk or snapshot. Possible options are: "AzureActiveDirectory" and "None".
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | Uri |
Aliases: | dst |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DiskHyperVGeneration
The hypervisor generation of the Virtual Machine. Applicable to OS disks only. Posssible values are: 'V1', 'V2'.
Type: | String |
Aliases: | HyperVGeneration |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DiskName
Name of the new managed Disk
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DiskOsType
The Operating System type of the managed disk. Possible values are: 'Windows', 'Linux'.
Type: | OperatingSystemTypes |
Aliases: | OsType |
Accepted values: | Windows, Linux |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DiskSku
Sku for managed disk. Options: Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DiskZone
The Logical zone list for Disk.
Type: | String[] |
Aliases: | Zone |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-LocalFilePath
Specifies the path of the local .vhd file.
Type: | FileInfo |
Aliases: | lf |
Position: | 2 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Location
Location of new Managed Disk
Type: | String |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-NumberOfUploaderThreads
Specifies the number of uploader threads to be used when uploading the .vhd file.
Type: | Nullable<T>[Int32] |
Aliases: | th |
Position: | 3 |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-OverWrite
Indicates that this cmdlet overwrites an existing blob in the specified destination URI, if one exists.
Type: | SwitchParameter |
Aliases: | o |
Position: | 5 |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceGroupName
Specifies the name of the resource group of the virtual machine.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | 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.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Nullable<T>[[System.Int32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]