Skip to content

Commit bd74a9a

Browse files
haaghaHaider AghaVeryEarly
authored
[Compute] Add instant access snapshot functionality and tests (#28547)
Co-authored-by: Haider Agha <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent 8e96a77 commit bd74a9a

File tree

8 files changed

+5789
-2
lines changed

8 files changed

+5789
-2
lines changed

src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,12 @@ public void TestDiskCreateImportSecure()
206206
TestRunner.RunTestScript("Test-ConfVMImportSecure");
207207
}
208208

209+
[Fact]
210+
[Trait(Category.AcceptanceType, Category.LiveOnly)]
211+
public void TestDiskSnapshotInstantAccess()
212+
{
213+
TestRunner.RunTestScript("Test-DiskSnapshotInstantAccess");
214+
}
215+
209216
}
210217
}

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,3 +1905,49 @@ function Test-ConfVMImportSecure
19051905
Clean-ResourceGroup $rgname;
19061906
}
19071907
}
1908+
1909+
1910+
<#
1911+
.SYNOPSIS
1912+
Test confidential vm securityMetadataUri during confidential VM OS disk creation from an unmanaged storage account.
1913+
#>
1914+
function Test-DiskSnapshotInstantAccess
1915+
{
1916+
# Setup
1917+
$rgname = Get-ComputeTestResourceName;
1918+
$location = "eastus2euap";
1919+
1920+
try
1921+
{
1922+
$diskName = "haagha-premiumv2test"
1923+
$snapshotName = "snapshotTest"
1924+
1925+
New-AzResourceGroup -Name $rgname -Location $location -Force;
1926+
1927+
$diskConfig = New-AzDiskConfig `
1928+
-Location $location `
1929+
-DiskSizeGB 1024 `
1930+
-DiskIOPSReadWrite 10000 `
1931+
-DiskMBpsReadWrite 500 `
1932+
-AccountType PremiumV2_LRS `
1933+
-CreateOption Empty `
1934+
-Zone $zone
1935+
1936+
New-AzDisk -ResourceGroupName $rgname -DiskName $diskName -Disk $diskConfig
1937+
1938+
$disk = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskName
1939+
$snapshotConfig = New-AzSnapshotConfig -SourceUri $disk.Id -Location $location -CreateOption Copy -InstantAccessDurationMinutes 300 -Incremental Premium_LRS
1940+
1941+
New-AzSnapshot -Snapshot $snapshotConfig -SnapshotName $snapshotName -ResourceGroupName $rgname
1942+
1943+
$snapshotGet = Get-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotName
1944+
1945+
Asset-NotNull = $snapshotGet.CreationData.InstantAccessDurationMinutes
1946+
Asset-NotNull = $snapshotGet.SnapshotAccessState
1947+
}
1948+
finally
1949+
{
1950+
# Cleanup
1951+
Clean-ResourceGroup $rgname;
1952+
}
1953+
}

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

Lines changed: 5694 additions & 0 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
@@ -20,6 +20,7 @@
2020
2121
-->
2222
## Upcoming Release
23+
* Added `-InstantAccessDurationMinutes` parameter to New-AzSnapshotConfig.
2324
* Added `SecureVMGuestStateSAS` parameter to `Grant-AzSnapshotAccess`.
2425

2526
## Version 10.3.0

src/Compute/Compute/Generated/Models/PSSnapshot.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,13 @@ public string ResourceGroupName
8282
// via the CopyStart operation.
8383
public double? CompletionPercent { get; set; }
8484
public string DataAccessAuthMode { get; set; }
85+
86+
/// <summary>
87+
/// Gets the state of snapshot which determines the access availability
88+
/// of the snapshot. Possible values include: 'Unknown', 'Pending',
89+
/// 'Available', 'InstantAccess', 'AvailableWithInstantAccess'
90+
/// </summary>
91+
public string SnapshotAccessState { get; private set; }
92+
8593
}
8694
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ public partial class NewAzureRmSnapshotConfigCommand : Microsoft.Azure.Commands.
199199
[PSArgumentCompleter("Enhanced", "None")]
200200
public string TierOption { get; set; }
201201

202+
[Parameter(
203+
Mandatory = false,
204+
ValueFromPipelineByPropertyName = true,
205+
HelpMessage = "For snapshots created from Premium SSD v2 or Ultra disk, this property determines the time in minutes the snapshot is retained for instant access to enable faster restore.")]
206+
public int InstantAccessDurationMinutes { get; set; }
207+
202208
protected override void ProcessRecord()
203209
{
204210
if (ShouldProcess("Snapshot", "New"))
@@ -299,6 +305,15 @@ private void Run()
299305
vCreationData.ProvisionedBandwidthCopySpeed = this.TierOption;
300306
}
301307

308+
if (this.IsParameterBound(c => c.InstantAccessDurationMinutes))
309+
{
310+
if (vCreationData == null)
311+
{
312+
vCreationData = new CreationData();
313+
}
314+
vCreationData.InstantAccessDurationMinutes = this.InstantAccessDurationMinutes;
315+
}
316+
302317
if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
303318
{
304319
if (vEncryptionSettingsCollection == null)

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ New-AzSnapshotConfig [[-SkuName] <String>] [[-OsType] <OperatingSystemTypes>] [[
2222
[-DiskEncryptionSetId <String>] [-EncryptionType <String>] [-DiskAccessId <String>]
2323
[-NetworkAccessPolicy <String>] [-PublicNetworkAccess <String>] [-AcceleratedNetwork <Boolean>]
2424
[-DataAccessAuthMode <String>] [-Architecture <String>] [-ElasticSanResourceId <String>]
25-
[-TierOption <String>] [-DefaultProfile <IAzureContextContainer>]
26-
[-WhatIf] [-Confirm] [<CommonParameters>]
25+
[-TierOption <String>] [-InstantAccessDurationMinutes <Int32>] [-DefaultProfile <IAzureContextContainer>]
26+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2727
```
2828

2929
## DESCRIPTION
@@ -310,6 +310,21 @@ Accept pipeline input: True (ByPropertyName)
310310
Accept wildcard characters: False
311311
```
312312
313+
### -InstantAccessDurationMinutes
314+
For snapshots created from Premium SSD v2 or Ultra disk, this property determines the time in minutes the snapshot is retained for instant access to enable faster restore.
315+
316+
```yaml
317+
Type: System.Int32
318+
Parameter Sets: (All)
319+
Aliases:
320+
321+
Required: False
322+
Position: Named
323+
Default value: None
324+
Accept pipeline input: True (ByPropertyName)
325+
Accept wildcard characters: False
326+
```
327+
313328
### -KeyEncryptionKey
314329
Specifies the Key encryption key on a snapshot.
315330

tools/StaticAnalysis/Exceptions/Az.Compute/SignatureIssues.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,5 @@
168168
"Az.Compute","Microsoft.Azure.Commands.Compute.Automation.NewAzureRmGalleryInVMAccessControlProfileVersionConfig","New-AzGalleryInVMAccessControlProfileVersionConfig","1","8100","New-AzGalleryInVMAccessControlProfileVersionConfig Does not support ShouldProcess but the cmdlet verb New indicates that it should.","Determine if the cmdlet should implement ShouldProcess and if so determine if it should implement Force / ShouldContinue"
169169
"Az.Compute","Microsoft.Azure.Commands.Compute.SetAzureVMProxySetting","Set-AzVMProxyAgentSetting","1","8100","Set-AzVMProxyAgentSetting Does not support ShouldProcess but the cmdlet verb Set indicates that it should.","Determine if the cmdlet should implement ShouldProcess and if so determine if it should implement Force / ShouldContinue"
170170
"Az.Compute","Microsoft.Azure.Commands.Compute.SetAzureVmssProxySetting","Set-AzVmssProxyAgentSetting","1","8100","Set-AzVmssProxyAgentSetting Does not support ShouldProcess but the cmdlet verb Set indicates that it should.","Determine if the cmdlet should implement ShouldProcess and if so determine if it should implement Force / ShouldContinue"
171+
"Az.Compute","Microsoft.Azure.Commands.Compute.Automation.NewAzureRmSnapshotConfigCommand","New-AzSnapshotConfig","1","8410","Parameter InstantAccessDurationMinutes of cmdlet New-AzSnapshotConfig does not follow the enforced naming convention of using a singular noun for a parameter name.","Consider using a singular noun for the parameter name."
171172

0 commit comments

Comments
 (0)