Set-AzVMOSDisk
Sets the operating system disk properties on a virtual machine.
Syntax
Set-AzVMOSDisk
[-VM] <PSVirtualMachine>
[[-Name] <String>]
[[-VhdUri] <String>]
[[-Caching] <CachingTypes>]
[[-SourceImageUri] <String>]
[[-CreateOption] <String>]
[-DiskSizeInGB <Int32>]
[-ManagedDiskId <String>]
[-StorageAccountType <String>]
[-DiskEncryptionSetId <String>]
[-WriteAccelerator]
[-DiffDiskSetting <String>]
[-DiffDiskPlacement <String>]
[-DeleteOption <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Set-AzVMOSDisk
[-VM] <PSVirtualMachine>
[[-Name] <String>]
[[-VhdUri] <String>]
[[-Caching] <CachingTypes>]
[[-SourceImageUri] <String>]
[[-CreateOption] <String>]
[-Windows]
[-DiskSizeInGB <Int32>]
[-ManagedDiskId <String>]
[-StorageAccountType <String>]
[-DiskEncryptionSetId <String>]
[-WriteAccelerator]
[-DiffDiskSetting <String>]
[-DiffDiskPlacement <String>]
[-DeleteOption <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Set-AzVMOSDisk
[-VM] <PSVirtualMachine>
[[-Name] <String>]
[[-VhdUri] <String>]
[[-Caching] <CachingTypes>]
[[-SourceImageUri] <String>]
[[-CreateOption] <String>]
[-Windows]
[-DiskEncryptionKeyUrl] <String>
[-DiskEncryptionKeyVaultId] <String>
[[-KeyEncryptionKeyUrl] <String>]
[[-KeyEncryptionKeyVaultId] <String>]
[-DiskSizeInGB <Int32>]
[-ManagedDiskId <String>]
[-StorageAccountType <String>]
[-DiskEncryptionSetId <String>]
[-WriteAccelerator]
[-DiffDiskSetting <String>]
[-DiffDiskPlacement <String>]
[-DeleteOption <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Set-AzVMOSDisk
[-VM] <PSVirtualMachine>
[[-Name] <String>]
[[-VhdUri] <String>]
[[-Caching] <CachingTypes>]
[[-SourceImageUri] <String>]
[[-CreateOption] <String>]
[-Linux]
[-DiskSizeInGB <Int32>]
[-ManagedDiskId <String>]
[-StorageAccountType <String>]
[-DiskEncryptionSetId <String>]
[-WriteAccelerator]
[-DiffDiskSetting <String>]
[-DiffDiskPlacement <String>]
[-DeleteOption <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Set-AzVMOSDisk
[-VM] <PSVirtualMachine>
[[-Name] <String>]
[[-VhdUri] <String>]
[[-Caching] <CachingTypes>]
[[-SourceImageUri] <String>]
[[-CreateOption] <String>]
[-Linux]
[-DiskEncryptionKeyUrl] <String>
[-DiskEncryptionKeyVaultId] <String>
[[-KeyEncryptionKeyUrl] <String>]
[[-KeyEncryptionKeyVaultId] <String>]
[-DiskSizeInGB <Int32>]
[-ManagedDiskId <String>]
[-StorageAccountType <String>]
[-DiskEncryptionSetId <String>]
[-WriteAccelerator]
[-DiffDiskSetting <String>]
[-DiffDiskPlacement <String>]
[-DeleteOption <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Set-AzVMOSDisk cmdlet sets the operating system disk properties on a virtual machine.
Examples
Example 1: Set properties on a virtual machine from platform image
$AvailabilitySet = Get-AzAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet13"
$VirtualMachine = New-AzVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id
Set-AzVMOSDisk -VM $VirtualMachine -Name "OsDisk12" -VhdUri "os.vhd" -Caching ReadWrite
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Linux -ComputerName "MainComputer" -Credential (Get-Credential)
$VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName "Canonical" -Offer "UbuntuServer" -Skus "15.10" -Version "latest"
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name "osDisk.vhd" -VhdUri "https://mystorageaccount.blob.core.windows.net/disks/" -CreateOption FromImage
New-AzVM -VM $VirtualMachine -ResourceGroupName "ResourceGroup11"
The first command gets the availability set named AvailabilitySet13 in the resource group named ResourceGroup11, and then stores that object in the $AvailabilitySet variable. The second command creates a virtual machine object, and then stores it in the $VirtualMachine variable. The command assigns a name and size to the virtual machine. The virtual machine belongs to the availability set stored in $AvailabilitySet. The final command sets the properties on the virtual machine in $VirtualMachine.
Example 2: Sets properties on a virtual machine from generalized user image
$AvailabilitySet = Get-AzAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet13"
$VirtualMachine = New-AzVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1"
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Linux -ComputerName "MainComputer" -Credential (Get-Credential)
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name "osDisk.vhd" -SourceImageUri "https://mystorageaccount.blob.core.windows.net/vhds/myOSImage.vhd" -VhdUri "https://mystorageaccount.blob.core.windows.net/disks/" -CreateOption fromImage -Linux
New-AzVM -VM $VirtualMachine -ResourceGroupName "ResourceGroup11"
The first command gets the availability set named AvailabilitySet13 in the resource group named ResourceGroup11 and stores that object in the $AvailabilitySet variable. The second command creates a virtual machine object and stores it in the $VirtualMachine variable. The command assigns a name and size to the virtual machine. The virtual machine belongs to the availability set stored in $AvailabilitySet. The final command sets the properties on the virtual machine in $VirtualMachine.
Example 3: Sets properties on a virtual machine from specialized user image
$AvailabilitySet = Get-AzAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet13"
$VirtualMachine = New-AzVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1"
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name "osDisk.vhd" -VhdUri "https://mystorageaccount.blob.core.windows.net/disks/" -CreateOption Attach -Linux
New-AzVM -VM $VirtualMachine -ResourceGroupName "ResourceGroup11"
The first command gets the availability set named AvailabilitySet13 in the resource group named ResourceGroup11 and stores that object in the $AvailabilitySet variable. The second command creates a virtual machine object and stores it in the $VirtualMachine variable. The command assigns a name and size to the virtual machine. The virtual machine belongs to the availability set stored in $AvailabilitySet. The final command sets the properties on the virtual machine in $VirtualMachine.
Example 4: Set the disk encryption settings on a virtual machine operating system disk
$VirtualMachine = New-AzVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1"
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name "OsDisk12" -VhdUri "os.vhd" -Caching ReadWrite -Windows -CreateOption "Attach" -DiskEncryptionKeyUrl "https://mytestvault.vault.azure.net/secrets/Test1/514ceb769c984379a7e0230bddaaaaaa" -DiskEncryptionKeyVaultId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.KeyVault/vaults/mytestvault"
New-AzVM -VM $VirtualMachine -ResourceGroupName " ResourceGroup11"
This example sets the disk encryption settings on a virtual machine operating system disk.
Parameters
Specifies the caching mode of the operating system disk. Valid values are:
- ReadOnly
- ReadWrite The default value is ReadWrite. Changing the caching value causes the virtual machine to restart. This setting affects the performance of the disk.
Type: | Nullable<T>[CachingTypes] |
Accepted values: | None, ReadOnly, ReadWrite |
Position: | 3 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies whether this cmdlet creates a disk in the virtual machine from a platform or user image, or attaches an existing disk. Valid values are:
- Attach. Specify this option to create a virtual machine from a specialized disk. When you specify this option, do not specify the SourceImageUri parameter. Instead, use the Set-AzVMSourceImage cmdlet. You must also use the use the Windows or Linux parameters to tell the azure platform the type of the operating system on the VHD. The VhdUri parameter is enough to tell the azure platform the location of the disk to attach.
- FromImage. Specify this option to create a virtual machine from a platform image or a generalized user image. In the case of a generalized user image, you also need to specify the SourceImageUri parameter and either the Windows or Linux parameters to tell the Azure platform the location and type of the operating system disk VHD instead of using the Set-AzVMSourceImage cmdlet. In the case of a platform image, the VhdUri parameter is sufficient.
- Empty.
Type: | String |
Position: | 5 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies OS Disk delete option after VM deletion. Options are Detach, Delete
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e. cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer Ephemeral OS disk size requirements for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. This parameter can only be used if the parameter DiffDiskSetting is set to 'Local'.
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the differencing disk settings for operating system disk.
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the location of the disk encryption key.
Type: | String |
Position: | 7 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the resource ID of the Key Vault containing the disk encryption key.
Type: | String |
Position: | 8 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the resource Id of customer managed disk encryption set. This can only be specified for managed disk.
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the size, in GB, of the operating system disk.
Type: | Nullable<T>[Int32] |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the location of the key encryption key.
Type: | String |
Position: | 9 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the resource ID of the Key Vault containing the key encryption key.
Type: | String |
Position: | 10 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Indicates that the operating system on the user image is Linux. Specify this parameter for user image based virtual machine deployment.
Type: | SwitchParameter |
Position: | 6 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the ID of a managed disk.
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the name of the operating system disk.
Type: | String |
Aliases: | OSDiskName, DiskName |
Position: | 1 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the URI of the VHD for user image scenarios.
Type: | String |
Aliases: | SourceImage |
Position: | 4 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the storage account type of managed disk.
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the Uniform Resource Identifier (URI) of a virtual hard disk (VHD). For an image based virtual machine, this parameter specifies the VHD file to create when a platform image or user image is specified. This is the location from which the image binary large object (BLOB) is copied to start the virtual machine. For a disk based virtual machine boot scenario, this parameter specifies the VHD file that the virtual machine uses directly for starting up.
Type: | String |
Aliases: | OSDiskVhdUri, DiskVhdUri |
Position: | 2 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the local virtual machine object on which to set operating system disk properties. To obtain a virtual machine object, use the Get-AzVM cmdlet.
Type: | PSVirtualMachine |
Aliases: | VMProfile |
Position: | 0 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates that the operating system on the user image is Windows.
Type: | SwitchParameter |
Position: | 6 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies whether WriteAccelerator should be enabled or disabled on the OS disk.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Outputs
Related Links
Feedback
Submit and view feedback for