Skip to content

Commit b8faa9f

Browse files
authored
Merge pull request #8887 from hyonholee/march
[Compute] Add HyperVGeneration parameter
2 parents e876f82 + af2ba48 commit b8faa9f

File tree

9 files changed

+747
-643
lines changed

9 files changed

+747
-643
lines changed

src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ function Test-Disk
3737
$diskconfig = New-AzDiskConfig -Location $loc -DiskSizeGB 500 -SkuName UltraSSD_LRS -OsType Windows -CreateOption Empty -DiskMBpsReadWrite 8 -DiskIOPSReadWrite 500;
3838
Assert-AreEqual "UltraSSD_LRS" $diskconfig.Sku.Name;
3939
Assert-AreEqual 500 $diskconfig.DiskIOPSReadWrite;
40-
Assert-AreEqual 8 $diskconfig.DiskMBpsReadWrite
40+
Assert-AreEqual 8 $diskconfig.DiskMBpsReadWrite;
4141

42-
$diskconfig = New-AzDiskConfig -Location $loc -Zone "1" -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
42+
$diskconfig = New-AzDiskConfig -Location $loc -Zone "1" -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty `
43+
-EncryptionSettingsEnabled $true -HyperVGeneration "V1";
4344
# Encryption test
4445
$diskconfig = Set-AzDiskDiskEncryptionKey -Disk $diskconfig -SecretUrl $mocksecret -SourceVaultId $mocksourcevault;
4546
$diskconfig = Set-AzDiskKeyEncryptionKey -Disk $diskconfig -KeyUrl $mockkey -SourceVaultId $mocksourcevault;
@@ -140,6 +141,7 @@ function Test-Disk
140141
Assert-AreEqual Windows $disk.OsType;
141142
Assert-AreEqual Empty $disk.CreationData.CreateOption;
142143
Assert-AreEqual $false $disk.EncryptionSettings.Enabled;
144+
Assert-AreEqual "V1" $disk.HyperVGeneration;
143145

144146
# Grant access test
145147
$job = Grant-AzDiskAccess -ResourceGroupName $rgname -DiskName $diskname -Access $access -DurationInSecond 5 -AsJob;
@@ -197,7 +199,8 @@ function Test-Snapshot
197199
$access = 'Read';
198200

199201
# Config and create test
200-
$snapshotconfig = New-AzSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
202+
$snapshotconfig = New-AzSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty `
203+
-EncryptionSettingsEnabled $true -HyperVGeneration "V2";
201204

202205
# Encryption test
203206
$snapshotconfig = Set-AzSnapshotDiskEncryptionKey -Snapshot $snapshotconfig -SecretUrl $mocksecret -SourceVaultId $mocksourcevault;
@@ -287,6 +290,7 @@ function Test-Snapshot
287290
Assert-AreEqual Windows $snapshot.OsType;
288291
Assert-AreEqual Empty $snapshot.CreationData.CreateOption;
289292
Assert-AreEqual $false $snapshot.EncryptionSettings.Enabled;
293+
Assert-AreEqual "V2" $snapshot.HyperVGeneration;
290294

291295
# Grant access test
292296
$job = Grant-AzSnapshotAccess -ResourceGroupName $rgname -SnapshotName $snapshotname -Access $access -DurationInSecond 5 -AsJob;
@@ -494,6 +498,7 @@ function Test-DiskEncrypt
494498
Assert-AreEqual $mocksecret $disk.EncryptionSettings.DiskEncryptionKey.SecretUrl;
495499
Assert-AreEqual $mocksourcevault $disk.EncryptionSettings.KeyEncryptionKey.SourceVault.Id;
496500
Assert-AreEqual $mockkey $disk.EncryptionSettings.KeyEncryptionKey.KeyUrl;
501+
Assert-Null $disk.HyperVGeneration;
497502

498503
# Grant access test
499504
$job = Grant-AzDiskAccess -ResourceGroupName $rgname -DiskName $diskname -Access $access -DurationInSecond 5 -AsJob;
@@ -686,6 +691,7 @@ function Test-SnapshotEncrypt
686691
Assert-AreEqual $mocksecret $snapshot.EncryptionSettings.DiskEncryptionKey.SecretUrl;
687692
Assert-AreEqual $mocksourcevault $snapshot.EncryptionSettings.KeyEncryptionKey.SourceVault.Id;
688693
Assert-AreEqual $mockkey $snapshot.EncryptionSettings.KeyEncryptionKey.KeyUrl;
694+
Assert-Null $snapshot.HyperVGeneration;
689695

690696
# Grant access test
691697
$job = Grant-AzSnapshotAccess -ResourceGroupName $rgname -SnapshotName $snapshotname -Access $access -DurationInSecond 5 -AsJob;

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiskRPTests/TestDisk.json

Lines changed: 302 additions & 302 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiskRPTests/TestSnapshot.json

Lines changed: 328 additions & 328 deletions
Large diffs are not rendered by default.

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Additional information about change #1
2020
-->
2121
## Upcoming Release
22+
* Add HyperVGeneration parameter to New-AzDiskConfig and New-AzSnapshotConfig
2223
* Allow VM creation with galley image from other tenants.
2324

2425
## Version 1.6.0

src/Compute/Compute/Generated/Disk/Config/NewAzureRmDiskConfigCommand.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public partial class NewAzureRmDiskConfigCommand : Microsoft.Azure.Commands.Reso
7070
ValueFromPipelineByPropertyName = true)]
7171
public string[] Zone { get; set; }
7272

73+
[Parameter(
74+
Mandatory = false,
75+
ValueFromPipelineByPropertyName = true)]
76+
[PSArgumentCompleter("V1", "V2")]
77+
public string HyperVGeneration { get; set; }
78+
7379
[Parameter(
7480
Mandatory = false,
7581
ValueFromPipelineByPropertyName = true)]
@@ -251,6 +257,7 @@ private void Run()
251257
{
252258
Zones = this.MyInvocation.BoundParameters.ContainsKey("Zone") ? this.Zone : null,
253259
OsType = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
260+
HyperVGeneration = this.MyInvocation.BoundParameters.ContainsKey("HyperVGeneration") ? this.HyperVGeneration : null,
254261
DiskSizeGB = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
255262
DiskIOPSReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskIOPSReadWrite") ? this.DiskIOPSReadWrite : (int?)null,
256263
DiskMBpsReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskMBpsReadWrite") ? this.DiskMBpsReadWrite : (int?)null,

src/Compute/Compute/Generated/Snapshot/Config/NewAzureRmSnapshotConfigCommand.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public partial class NewAzureRmSnapshotConfigCommand : Microsoft.Azure.Commands.
6565
[LocationCompleter("Microsoft.Compute/snapshots")]
6666
public string Location { get; set; }
6767

68+
[Parameter(
69+
Mandatory = false,
70+
ValueFromPipelineByPropertyName = true)]
71+
[PSArgumentCompleter("V1", "V2")]
72+
public string HyperVGeneration { get; set; }
73+
6874
[Parameter(
6975
Mandatory = false,
7076
ValueFromPipelineByPropertyName = true)]
@@ -235,6 +241,7 @@ private void Run()
235241
var vSnapshot = new PSSnapshot
236242
{
237243
OsType = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
244+
HyperVGeneration = this.MyInvocation.BoundParameters.ContainsKey("HyperVGeneration") ? this.HyperVGeneration : null,
238245
DiskSizeGB = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
239246
Location = this.MyInvocation.BoundParameters.ContainsKey("Location") ? this.Location : null,
240247
Tags = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast<DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,

src/Compute/Compute/help/New-AzDisk.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,38 @@ The first command creates a local empty disk object with size 5GB in Standard_LR
3838
The second and third commands set the disk encryption key and key encryption key settings for the disk object.
3939
The last command takes the disk object and creates a disk with name 'Disk01' in resource group 'ResourceGroup01'.
4040

41+
### Example 2
42+
```
43+
PS C:\> $diskconfig = New-AzDiskConfig -Location 'Central US' -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
44+
PS C:\> $diskConfig.EncryptionSettingsCollection = New-Object Microsoft.Azure.Management.Compute.Models.EncryptionSettingsCollection
45+
46+
PS C:\> $encryptionSettingsElement1 = New-Object Microsoft.Azure.Management.Compute.Models.EncryptionSettingsElement
47+
PS C:\> $encryptionSettingsElement1.DiskEncryptionKey = New-Object Microsoft.Azure.Management.Compute.Models.KeyVaultAndSecretReference
48+
PS C:\> $encryptionSettingsElement1.DiskEncryptionKey.SourceVault = New-Object Microsoft.Azure.Management.Compute.Models.SourceVault
49+
PS C:\> $encryptionSettingsElement1.DiskEncryptionKey.SourceVault.Id = $disk_encryption_key_id_1
50+
PS C:\> $encryptionSettingsElement1.DiskEncryptionKey.SecretUrl = $disk_encryption_secret_url_1
51+
PS C:\> $encryptionSettingsElement1.KeyEncryptionKey = New-Object Microsoft.Azure.Management.Compute.Models.KeyVaultAndKeyReference
52+
PS C:\> $encryptionSettingsElement1.KeyEncryptionKey.SourceVault = New-Object Microsoft.Azure.Management.Compute.Models.SourceVault
53+
PS C:\> $encryptionSettingsElement1.KeyEncryptionKey.SourceVault.Id = $key_encryption_key_id_1
54+
PS C:\> $encryptionSettingsElement1.KeyEncryptionKey.KeyUrl = $key_encryption_key_url_1
55+
56+
PS C:\> $encryptionSettingsElement2 = New-Object Microsoft.Azure.Management.Compute.Models.EncryptionSettingsElement
57+
PS C:\> $encryptionSettingsElement2.DiskEncryptionKey = New-Object Microsoft.Azure.Management.Compute.Models.KeyVaultAndSecretReference
58+
PS C:\> $encryptionSettingsElement2.DiskEncryptionKey.SourceVault = New-Object Microsoft.Azure.Management.Compute.Models.SourceVault
59+
PS C:\> $encryptionSettingsElement2.DiskEncryptionKey.SourceVault.Id = $disk_encryption_key_id_2
60+
PS C:\> $encryptionSettingsElement2.DiskEncryptionKey.SecretUrl = $disk_encryption_secret_url_2
61+
PS C:\> $encryptionSettingsElement2.KeyEncryptionKey = New-Object Microsoft.Azure.Management.Compute.Models.KeyVaultAndKeyReference
62+
PS C:\> $encryptionSettingsElement2.KeyEncryptionKey.SourceVault = New-Object Microsoft.Azure.Management.Compute.Models.SourceVault
63+
PS C:\> $encryptionSettingsElement2.KeyEncryptionKey.SourceVault.Id = $key_encryption_key_id_2
64+
PS C:\> $encryptionSettingsElement2.KeyEncryptionKey.KeyUrl = $key_encryption_key_url_2
65+
66+
PS C:\> $diskConfig.EncryptionSettingsCollection.EncryptionSettings += $encryptionSettingsElement1
67+
PS C:\> $diskConfig.EncryptionSettingsCollection.EncryptionSettings += $encryptionSettingsElement2
68+
PS C:\> New-AzDisk -ResourceGroupName 'ResourceGroup01' -DiskName 'Disk01' -Disk $diskconfig;
69+
```
70+
71+
The above command creates a disk with two encryption settings.
72+
4173
## PARAMETERS
4274

4375
### -AsJob

src/Compute/Compute/help/New-AzDiskConfig.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.Compute.dll-Help.xml
33
Module Name: Az.Compute
44
online version: https://docs.microsoft.com/en-us/powershell/module/az.compute/new-azdiskconfig
@@ -14,8 +14,8 @@ Creates a configurable disk object.
1414

1515
```
1616
New-AzDiskConfig [[-SkuName] <String>] [[-OsType] <OperatingSystemTypes>] [[-DiskSizeGB] <Int32>]
17-
[[-Location] <String>] [-Zone <String[]>] [-DiskIOPSReadWrite <Int32>] [-DiskMBpsReadWrite <Int32>]
18-
[-Tag <Hashtable>] [-CreateOption <String>] [-StorageAccountId <String>]
17+
[[-Location] <String>] [-Zone <String[]>] [-HyperVGeneration <String>] [-DiskIOPSReadWrite <Int32>]
18+
[-DiskMBpsReadWrite <Int32>] [-Tag <Hashtable>] [-CreateOption <String>] [-StorageAccountId <String>]
1919
[-ImageReference <ImageDiskReference>] [-SourceUri <String>] [-SourceResourceId <String>]
2020
[-EncryptionSettingsEnabled <Boolean>] [-DiskEncryptionKey <KeyVaultAndSecretReference>]
2121
[-KeyEncryptionKey <KeyVaultAndKeyReference>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
@@ -29,7 +29,7 @@ The **New-AzDiskConfig** cmdlet creates a configurable disk object.
2929

3030
### Example 1
3131
```
32-
PS C:\> $diskconfig = New-AzDiskConfig -Location 'Central US' -DiskSizeGB 5 -AccountType StandardLRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
32+
PS C:\> $diskconfig = New-AzDiskConfig -Location 'Central US' -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
3333
PS C:\> $secretUrl = https://myvault.vault-int.azure-int.net/secrets/123/;
3434
PS C:\> $secretId = '/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/ResourceGroup01/providers/Microsoft.KeyVault/vaults/TestVault123';
3535
PS C:\> $keyUrl = https://myvault.vault-int.azure-int.net/keys/456;
@@ -44,6 +44,27 @@ type. It also sets Windows OS type and enables encryption settings. The second a
4444
set the disk encryption key and key encryption key settings for the disk object. The last command
4545
takes the disk object and creates a disk with name 'Disk01' in resource group 'ResourceGroup01'.
4646

47+
### Example 2
48+
```
49+
PS C:\> $diskconfig = New-AzDiskConfig -Location 'Central US' -DiskSizeGB 1023 -SkuName Standard_LRS -OsType Windows -CreateOption Upload -DiskIOPSReadWrite 500 -DiskMBpsReadWrite 8;
50+
PS C:\> New-AzDisk -ResourceGroupName 'ResourceGroup01' -DiskName 'Disk01' -Disk $diskconfig;
51+
PS C:\> $diskSas = Grant-AzDiskAccess -ResourceGroupName 'ResourceGroup01' -DiskName 'Disk01' -DurationInSecond 86400 -Access 'Write'
52+
PS C:\> $disk = Get-AzDisk -ResourceGroupName 'ResourceGroup01' -DiskName 'Disk01'
53+
# $disk.DiskState == 'ReadyToUpload'
54+
PS C:\> AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer1 /Dest:$diskSas
55+
PS C:\> $disk = Get-AzDisk -ResourceGroupName 'ResourceGroup01' -DiskName 'Disk01'
56+
# $disk.DiskState == 'ActiveUpload'
57+
PS C:\> Revoke-AzDiskAccess -ResourceGroupName 'ResourceGroup01' -DiskName 'Disk01'
58+
```
59+
60+
The first command creates a local disk object for Upload.
61+
The second command takes the disk object and creates a disk with name 'Disk01' in resource group 'ResourceGroup01'.
62+
The third command gets SAS Url for the disk.
63+
The fourth command gets the state of the disk.
64+
If the disk state is 'ReadyToUpload', a user can upload a disk from blob storage to the disk SAS Url using AzCopy.
65+
During uploading, the disk state is changed to 'ActiveUpload'.
66+
The last command revokes the disk access for the SAS Url.
67+
4768
## PARAMETERS
4869

4970
### -CreateOption
@@ -152,6 +173,21 @@ Accept pipeline input: True (ByPropertyName)
152173
Accept wildcard characters: False
153174
```
154175
176+
### -HyperVGeneration
177+
The hypervisor generation of the Virtual Machine. Applicable to OS disks only. Allowed values are V1 and V2.
178+
179+
```yaml
180+
Type: System.String
181+
Parameter Sets: (All)
182+
Aliases:
183+
184+
Required: False
185+
Position: Named
186+
Default value: None
187+
Accept pipeline input: True (ByPropertyName)
188+
Accept wildcard characters: False
189+
```
190+
155191
### -ImageReference
156192
Specifies the image reference on a disk.
157193

src/Compute/Compute/help/New-AzSnapshotConfig.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.Compute.dll-Help.xml
33
Module Name: Az.Compute
44
online version: https://docs.microsoft.com/en-us/powershell/module/az.compute/new-azsnapshotconfig
@@ -14,11 +14,11 @@ Creates a configurable snapshot object.
1414

1515
```
1616
New-AzSnapshotConfig [[-SkuName] <String>] [[-OsType] <OperatingSystemTypes>] [[-DiskSizeGB] <Int32>]
17-
[[-Location] <String>] [-Tag <Hashtable>] [-CreateOption <String>] [-StorageAccountId <String>]
18-
[-ImageReference <ImageDiskReference>] [-SourceUri <String>] [-SourceResourceId <String>]
19-
[-EncryptionSettingsEnabled <Boolean>] [-DiskEncryptionKey <KeyVaultAndSecretReference>]
20-
[-KeyEncryptionKey <KeyVaultAndKeyReference>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
21-
[<CommonParameters>]
17+
[[-Location] <String>] [-HyperVGeneration <String>] [-Tag <Hashtable>] [-CreateOption <String>]
18+
[-StorageAccountId <String>] [-ImageReference <ImageDiskReference>] [-SourceUri <String>]
19+
[-SourceResourceId <String>] [-EncryptionSettingsEnabled <Boolean>]
20+
[-DiskEncryptionKey <KeyVaultAndSecretReference>] [-KeyEncryptionKey <KeyVaultAndKeyReference>]
21+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2222
```
2323

2424
## DESCRIPTION
@@ -119,6 +119,21 @@ Accept pipeline input: True (ByPropertyName)
119119
Accept wildcard characters: False
120120
```
121121
122+
### -HyperVGeneration
123+
The hypervisor generation of the Virtual Machine. Applicable to OS disks only. Allowed values are V1 and V2.
124+
125+
```yaml
126+
Type: System.String
127+
Parameter Sets: (All)
128+
Aliases:
129+
130+
Required: False
131+
Position: Named
132+
Default value: None
133+
Accept pipeline input: True (ByPropertyName)
134+
Accept wildcard characters: False
135+
```
136+
122137
### -ImageReference
123138
Specifies the image reference on a snapshot.
124139

0 commit comments

Comments
 (0)