Skip to content

Commit 9b5c50a

Browse files
grizzlytheodoreTheodore ChangVeryEarly
authored
add param to Set-AzVmssStorageProfile (Azure#19862)
* set-azvmssStorageProfile * set-azvm * Update Set-AzVM.md * Update ChangeLog.md Co-authored-by: Theodore Chang <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent b9eb3bd commit 9b5c50a

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

src/Compute/Compute/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* Added Disk Delete Optional parameters `OsDisk Deletion Option` and `Delete Option` to the `Set-AzVmssStorageProfile` (OS Disk) and `Add-AzVmssDataDisk` (Data Disk)
2626
* Improved printed output for `Get-AzComputeResourceSku`
2727
* Updated `Get-AzHost` cmdlet logic to return Host for `-ResourceId` parameterset.
28+
* Added `-OSDiskSizeGB` optional parameter for `Set-AzVmssStorageProfile`.
29+
* Improved cmdlet description for `Set-AzVM` and added examples.
2830
* Updated property mapping for parameter `Encryption` of `New-AzGalleryImageVersion`
2931
* Updated list format to display all VmssVmRunCommand properties for `Get-AzVmssVmRunCommand`
3032

src/Compute/Compute/Generated/VirtualMachineScaleSet/Config/SetAzureRmVmssStorageProfileCommand.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ public partial class SetAzureRmVmssStorageProfileCommand : Microsoft.Azure.Comma
150150
ValueFromPipelineByPropertyName = true)]
151151
public VirtualMachineScaleSetDataDisk[] DataDisk { get; set; }
152152

153+
[Parameter(
154+
Mandatory = false,
155+
ValueFromPipelineByPropertyName = true,
156+
HelpMessage = "Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.")]
157+
public int OSDiskSizeGB { get; set; }
158+
153159
[Parameter(
154160
Mandatory = false,
155161
HelpMessage = "Specifies the disk controller type configured for the VM and VirtualMachineScaleSet. This property is only supported for virtual machines whose operating system disk and VM sku supports Generation 2 (https://docs.microsoft.com/en-us/azure/virtual-machines/generation-2), please check the HyperVGenerations capability returned as part of VM sku capabilities in the response of Microsoft.Compute SKUs api for the region contains V2 (https://docs.microsoft.com/rest/api/compute/resourceskus/list) . <br> For more information about Disk Controller Types supported please refer to https://aka.ms/azure-diskcontrollertypes.")]
@@ -552,6 +558,26 @@ private void Run()
552558
this.VirtualMachineScaleSet.VirtualMachineProfile.StorageProfile.DiskControllerType = this.DiskControllerType;
553559
}
554560

561+
if (this.IsParameterBound(c => c.OSDiskSizeGB))
562+
{
563+
// VirtualMachineProfile
564+
if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
565+
{
566+
this.VirtualMachineScaleSet.VirtualMachineProfile = new PSVirtualMachineScaleSetVMProfile();
567+
}
568+
// StorageProfile
569+
if (this.VirtualMachineScaleSet.VirtualMachineProfile.StorageProfile == null)
570+
{
571+
this.VirtualMachineScaleSet.VirtualMachineProfile.StorageProfile = new VirtualMachineScaleSetStorageProfile();
572+
}
573+
// OsDisk
574+
if (this.VirtualMachineScaleSet.VirtualMachineProfile.StorageProfile.OsDisk == null)
575+
{
576+
this.VirtualMachineScaleSet.VirtualMachineProfile.StorageProfile.OsDisk = new VirtualMachineScaleSetOSDisk();
577+
}
578+
this.VirtualMachineScaleSet.VirtualMachineProfile.StorageProfile.OsDisk.DiskSizeGB = this.OSDiskSizeGB;
579+
}
580+
555581
WriteObject(this.VirtualMachineScaleSet);
556582
}
557583
}

src/Compute/Compute/help/Set-AzVM.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ schema: 2.0.0
99
# Set-AzVM
1010

1111
## SYNOPSIS
12-
Marks a virtual machine as generalized.
12+
This cmdlet can be used to do the followings: reapply or redeploy a virtual machine, mark a virtual machine as generalized, simulate eviction to a spot virtual machine.
1313

1414
## SYNTAX
1515

@@ -61,8 +61,8 @@ Set-AzVM [-Id] <String> [-SimulateEviction] [-AsJob] [-DefaultProfile <IAzureCon
6161
```
6262

6363
## DESCRIPTION
64-
The **Set-AzVM** cmdlet marks a virtual machine as generalized.
65-
Before you run this cmdlet, log on to the virtual machine and use Sysprep to prepare the hard disk.
64+
The **Set-AzVM** cmdlet can be used to redeploy or reapply a virtual machine. It can also be used to mark a virtual machine as generalized or simulate eviction to a spot virtual machine.<br>
65+
Before you mark a virtual machine as generalized, log on to the virtual machine and use Sysprep to prepare the hard disk. See [here](https://learn.microsoft.com/en-us/azure/virtual-machines/generalize#windows) for more information.
6666

6767
## EXAMPLES
6868

@@ -71,7 +71,30 @@ Before you run this cmdlet, log on to the virtual machine and use Sysprep to pre
7171
Set-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Generalized
7272
```
7373

74-
This command marks the virtual machine named VirtualMachine07 as generalized.
74+
This command marks the virtual machine named "VirtualMachine07" as generalized.
75+
76+
### Example 2: Simulate eviction to a spot virtual machine using resource ID
77+
```powershell
78+
$vm = Get-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
79+
Set-AzVM -Id $vm.id -SimulateEviction
80+
```
81+
82+
This command simulates eviction to the virtual machine named "VirtualMachine07" using the resource ID.
83+
84+
### Example 3: Reapply a virtual machine
85+
```powershell
86+
Set-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Reapply
87+
```
88+
89+
This command reapplies the virtual machine named "VirtualMachine07".
90+
91+
### Example 4: Redeploy a virtual machine using resource ID
92+
```powershell
93+
$vm = Get-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
94+
Set-AzVM -Id $vm.id -Redeploy
95+
```
96+
97+
This command deploys the virtual machine named "VirtualMachine07" using the resource ID.
7598

7699
## PARAMETERS
77100

src/Compute/Compute/help/Set-AzVmssStorageProfile.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ Set-AzVmssStorageProfile [-VirtualMachineScaleSet] <PSVirtualMachineScaleSet>
2020
[[-OsDiskCreateOption] <String>] [-OsDiskDeleteOption <String>] [[-OsDiskOsType] <OperatingSystemTypes>]
2121
[[-Image] <String>] [[-VhdContainer] <String[]>] [-ImageReferenceId <String>] [-OsDiskWriteAccelerator]
2222
[-DiffDiskSetting <String>] [-DiffDiskPlacement <String>] [-ManagedDisk <String>]
23-
[-DiskEncryptionSetId <String>] [-DataDisk <VirtualMachineScaleSetDataDisk[]>] [-DiskControllerType <String>]
24-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
23+
[-DiskEncryptionSetId <String>] [-DataDisk <VirtualMachineScaleSetDataDisk[]>] [-OSDiskSizeGB <Int32>]
24+
[-DiskControllerType <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
25+
[<CommonParameters>]
2526
```
2627

2728
## DESCRIPTION
@@ -332,6 +333,21 @@ Accept pipeline input: True (ByPropertyName)
332333
Accept wildcard characters: False
333334
```
334335
336+
### -OSDiskSizeGB
337+
Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
338+
339+
```yaml
340+
Type: System.Int32
341+
Parameter Sets: (All)
342+
Aliases:
343+
344+
Required: False
345+
Position: Named
346+
Default value: None
347+
Accept pipeline input: True (ByPropertyName)
348+
Accept wildcard characters: False
349+
```
350+
335351
### -OsDiskWriteAccelerator
336352
Specifies whether WriteAccelerator should be enabled or disabled on the OS disk.
337353

0 commit comments

Comments
 (0)