Skip to content

Commit 32d4d91

Browse files
authored
[PSCmdAssistant] Grant-AzDiskAccess new parameter SecureVMGuestStateSAS (Azure#24635)
* initial gen code * fixes and tests and changelog and help doc * add private * remove private to see what happens * cleanup * Update Grant-AzDiskAccess.md
1 parent e087a54 commit 32d4d91

File tree

7 files changed

+2607
-1
lines changed

7 files changed

+2607
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,12 @@ public void TestSnapshotConfigTierOptionEnhancedSpeed()
192192
TestRunner.RunTestScript("Test-SnapshotConfigTierOptionEnhancedSpeed");
193193
}
194194

195+
[Fact]
196+
[Trait(Category.AcceptanceType, Category.LiveOnly)]
197+
public void TestDiskGrantAccessGetSASWithTL()
198+
{
199+
TestRunner.RunTestScript("Test-DiskGrantAccessGetSASWithTL");
200+
}
201+
195202
}
196203
}

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,4 +1825,42 @@ function Test-SnapshotConfigTierOptionEnhancedSpeed
18251825
# Cleanup
18261826
Clean-ResourceGroup $rgname
18271827
}
1828+
}
1829+
1830+
<#
1831+
.SYNOPSIS
1832+
Using a TL disk, use the SecureVmGuestStateSas parameter to get the securityDataAccessSAS value.
1833+
#>
1834+
function Test-DiskGrantAccessGetSASWithTL
1835+
{
1836+
$rgname = Get-ComputeTestResourceName;
1837+
$loc = Get-ComputeVMLocation;
1838+
1839+
try
1840+
{
1841+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
1842+
1843+
$diskname = "d" + $rgname;
1844+
1845+
$image = Get-AzVMImage -Skus 2022-datacenter-azure-edition -Offer WindowsServer -PublisherName MicrosoftWindowsServer -Location $loc -Version latest;
1846+
$diskconfig = New-AzDiskConfig -DiskSizeGB 127 -AccountType Premium_LRS -OsType Windows -CreateOption FromImage -Location $loc;
1847+
1848+
$diskconfig = Set-AzDiskImageReference -Disk $diskconfig -Id $image.Id;
1849+
1850+
$disk = New-AzDisk -ResourceGroupName $rgname -DiskName $diskname -Disk $diskconfig;
1851+
1852+
$grantAccess = Grant-AzDiskAccess -ResourceGroupName $rgname -DiskName $diskname -Access 'Read' -DurationInSecond 60 -SecureVMGuestStateSAS;
1853+
Assert-NotNull $grantAccess.securityDataAccessSAS;
1854+
Assert-NotNull $grantAccess.AccessSAS;
1855+
1856+
$grantAccess = Grant-AzDiskAccess -ResourceGroupName $rgname -DiskName $diskname -Access 'Read' -DurationInSecond 60;
1857+
Assert-NotNull $grantAccess.AccessSAS;
1858+
Assert-Null $grantAccess.securityDataAccessSAS;
1859+
1860+
}
1861+
finally
1862+
{
1863+
# Cleanup
1864+
Clean-ResourceGroup $rgname;
1865+
}
18281866
}

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

Lines changed: 2535 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
@@ -22,6 +22,7 @@
2222
## Upcoming Release
2323
* Added cmdlet `Invoke-AzSpotPlacementRecommender`.
2424
* Fixed `Update-AzCapacityReservationGroup` to remove Subscriptions from SharingProfile.
25+
* Added new optional parameter `SecureVMGuestStateSAS` to cmdlet `Grant-AzDiskAccess`.
2526

2627
## Version 7.2.0
2728
* Added parameters `-scriptUriManagedIdentity`, `-outputBlobManagedIdentity`, `-errorBlobMangedIdentity`, and `-TreatFailureAsDeploymentFailure` to cmdlets `Set-AzVmRunCommand` and `Set-AzVmssRunCommand`.

src/Compute/Compute/Generated/Disk/DiskGrantAccessMethod.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public override void ExecuteCmdlet()
4848
var grantAccessData = new GrantAccessData();
4949
grantAccessData.Access = this.Access;
5050
grantAccessData.DurationInSeconds = this.DurationInSecond;
51+
grantAccessData.GetSecureVMGuestStateSAS = this.SecureVMGuestStateSAS;
5152

5253
var result = DisksClient.GrantAccess(resourceGroupName, diskName, grantAccessData);
5354
var psObject = new PSAccessUri();
@@ -88,5 +89,12 @@ public override void ExecuteCmdlet()
8889

8990
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
9091
public SwitchParameter AsJob { get; set; }
92+
93+
[Parameter(
94+
ParameterSetName = "DefaultParameter",
95+
HelpMessage = "Set this flag to true to get additional SAS for VM guest state.",
96+
Mandatory = false,
97+
ValueFromPipelineByPropertyName = true)]
98+
public SwitchParameter SecureVMGuestStateSAS { get; set; }
9199
}
92100
}

src/Compute/Compute/Generated/Models/PSAccessUri.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ public partial class PSAccessUri
2929
{
3030
public string AccessSAS { get; set; }
3131

32+
public string SecurityDataAccessSAS { get; set; }
33+
3234
}
3335
}

src/Compute/Compute/help/Grant-AzDiskAccess.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Grants an access to a disk.
1414

1515
```
1616
Grant-AzDiskAccess [-ResourceGroupName] <String> [-DiskName] <String> [-Access] <String>
17-
[[-DurationInSecond] <Int32>] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
17+
[[-DurationInSecond] <Int32>] [-AsJob] [-SecureVMGuestStateSAS] [-DefaultProfile <IAzureContextContainer>]
1818
[-WhatIf] [-Confirm] [<CommonParameters>]
1919
```
2020

@@ -122,6 +122,21 @@ Accept pipeline input: True (ByPropertyName)
122122
Accept wildcard characters: False
123123
```
124124
125+
### -SecureVMGuestStateSAS
126+
Set this flag to true to get additional SAS for VM guest state.
127+
128+
```yaml
129+
Type: System.Management.Automation.SwitchParameter
130+
Parameter Sets: (All)
131+
Aliases:
132+
133+
Required: False
134+
Position: Named
135+
Default value: None
136+
Accept pipeline input: True (ByPropertyName)
137+
Accept wildcard characters: False
138+
```
139+
125140
### -Confirm
126141
Prompts you for confirmation before running the cmdlet.
127142

0 commit comments

Comments
 (0)