Skip to content

Commit

Permalink
Merge branch 'DiskAccess' of https://github.com/Azure/azure-powershell
Browse files Browse the repository at this point in the history
…into DiskAccess
  • Loading branch information
grizzlytheodore committed Aug 17, 2020
2 parents 17994f6 + 017559c commit dc37ba3
Show file tree
Hide file tree
Showing 9 changed files with 1,669 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ public void TestDiskAccessObject()
{
TestRunner.RunTestScript("Test-DiskAccessObject");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDiskConfigDiskAccessNetworkAccess()
{
TestRunner.RunTestScript("Test-DiskConfigDiskAccessNetworkAccess");
}


[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSnapshotConfigDiskAccessNetworkPolicy()
{
TestRunner.RunTestScript("Test-SnapshotConfigDiskAccessNetworkPolicy");
}

}
}
47 changes: 47 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,50 @@ function Test-DiskConfigDiskAccessNetworkAccess
Clean-ResourceGroup $rgname
}
}

function Test-SnapshotConfigDiskAccessNetworkPolicy
{
# Setup
$rgname = Get-ComputeTestResourceName;
$snapshotname = 'snapshot' + $rgname;

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzResourceGroup -Name $rgname -Location $loc -Force;
$subId = Get-SubscriptionIdFromResourceGroup $rgname;
$mocksourcevault = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.KeyVault/vaults/TestVault123';
$mockkey = 'https://myvault.vault-int.azure-int.net/keys/mockkey/00000000000000000000000000000000';
$mocksecret = 'https://myvault.vault-int.azure-int.net/secrets/mocksecret/00000000000000000000000000000000';
$access = 'Read';

# Config and create test
$diskAccess = New-AzDiskAccess -ResourceGroupName $rgname -Name "diskaccessname" -location $loc

$snapshotconfig = New-AzSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty `
-EncryptionSettingsEnabled $true -HyperVGeneration "V2" -DiskAccessId $diskAccess.Id;

$snapshotconfig.EncryptionSettingsCollection.Enabled = $false;
$snapshotconfig.EncryptionSettingsCollection.EncryptionSettings = $null;
$snapshotconfig.CreationData.ImageReference = $null;
$job = New-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Snapshot $snapshotconfig -AsJob;
$result = $job | Wait-Job;
Assert-AreEqual "Completed" $result.State;

$snapshot = Get-AzSnapshot -ResourceGroupName $rgname
Assert-AreEqual $diskAccess.Id $snapshot.DiskAccessId

# Remove test
$job = Remove-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Force -AsJob;
$result = $job | Wait-Job;
Assert-AreEqual "Completed" $result.State;
$st = $job | Receive-Job;
Verify-PSOperationStatusResponse $st;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ private void Run()
CreationData = vCreationData,
EncryptionSettingsCollection = vEncryptionSettingsCollection,
Encryption = vEncryption,
NetworkAccessPolicy = NetworkAccessPolicy,
DiskAccessId = DiskAccessId
NetworkAccessPolicy = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy : null,
DiskAccessId = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId : null
};

WriteObject(vDisk);
Expand Down
1 change: 0 additions & 1 deletion src/Compute/Compute/Generated/Models/PSDisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public string ResourceGroupName
public string Type { get; set; }
public string Location { get; set; }
public IDictionary<string, string> Tags { get; set; }

// Gets or sets possible values include: 'AllowAll', 'AllowPrivate', 'DenyAll'
public string NetworkAccessPolicy { get; set; }
public string DiskAccessId { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions src/Compute/Compute/Generated/Models/PSSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public string ResourceGroupName
public string Type { get; set; }
public string Location { get; set; }
public IDictionary<string, string> Tags { get; set; }
// Gets or sets possible values include: 'AllowAll', 'AllowPrivate', 'DenyAll'
public string NetworkAccessPolicy { get; set; }
public string DiskAccessId { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ public partial class NewAzureRmSnapshotConfigCommand : Microsoft.Azure.Commands.
[PSArgumentCompleter("EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey")]
public string EncryptionType { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
public string DiskAccessId { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
public string NetworkAccessPolicy { get; set; }

protected override void ProcessRecord()
{
if (ShouldProcess("Snapshot", "New"))
Expand Down Expand Up @@ -284,6 +294,8 @@ private void Run()
CreationData = vCreationData,
EncryptionSettingsCollection = vEncryptionSettingsCollection,
Encryption = vEncryption,
NetworkAccessPolicy = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy : null,
DiskAccessId = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId : null
};

WriteObject(vSnapshot);
Expand Down
3 changes: 2 additions & 1 deletion src/Compute/Compute/help/New-AzDiskConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ Accept wildcard characters: False
```
### -DiskAccessId
Id of DiskAccess.
Gets or sets ARM id of the DiskAccess resource for using private endpoints on.
```yaml
Type: System.String
Expand Down
34 changes: 33 additions & 1 deletion src/Compute/Compute/help/New-AzSnapshotConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ New-AzSnapshotConfig [[-SkuName] <String>] [[-OsType] <OperatingSystemTypes>] [[
[-StorageAccountId <String>] [-ImageReference <ImageDiskReference>] [-SourceUri <String>]
[-SourceResourceId <String>] [-EncryptionSettingsEnabled <Boolean>]
[-DiskEncryptionKey <KeyVaultAndSecretReference>] [-KeyEncryptionKey <KeyVaultAndKeyReference>]
[-DiskEncryptionSetId <String>] [-EncryptionType <String>] [-DefaultProfile <IAzureContextContainer>]
[-DiskEncryptionSetId <String>] [-EncryptionType <String>] [DiskAccessId <String>]
[-NetworkAccessPolicy <String>] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```

Expand Down Expand Up @@ -158,6 +159,37 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -DiskAccessId
Gets or sets ARM id of the DiskAccess resource for using private endpoints on.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -NetworkAccessPolicy
Network access policy defines the network access policy.
Possible values include: 'AllowAll', 'AllowPrivate', 'DenyAll'
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -HyperVGeneration
The hypervisor generation of the Virtual Machine. Applicable to OS disks only. Allowed values are V1 and V2.
Expand Down

0 comments on commit dc37ba3

Please sign in to comment.