Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New disk config #12665

Merged
merged 3 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,12 @@ public void TestDiskAccessObject()
{
TestRunner.RunTestScript("Test-DiskAccessObject");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDiskConfigDiskAccessNetworkAccess()
{
TestRunner.RunTestScript("Test-DiskConfigDiskAccessNetworkAccess");
}

}
}
43 changes: 42 additions & 1 deletion src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -944,4 +944,45 @@ function Test-DiskAccessObject
# Cleanup
Clean-ResourceGroup $rgname
}
}
}

<#
.SYNOPSIS
Testing disk upload
#>
function Test-DiskConfigDiskAccessNetworkAccess
{
# Setup
$rgname = Get-ComputeTestResourceName;
$diskname0 = 'disk0' + $rgname;

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzResourceGroup -Name $rgname -Location $loc -Force;

#Testing disk access
$diskAccess = New-AzDiskAccess -ResourceGroupName $rgname -Name "diskaccessname" -location $loc
$diskconfig = New-AzDiskConfig -Location $loc -SkuName 'Standard_LRS' -OsType 'Windows' `
-UploadSizeInBytes 35183298347520 -CreateOption 'Upload' -DiskAccessId $diskAccess.Id;
New-AzDisk -ResourceGroupName $rgname -DiskName $diskname0 -Disk $diskconfig;
$disk = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname0;

Assert-AreEqual $diskAccess.Id $disk.DiskAccessId;

Remove-AzDisk -ResourceGroupName $rgname -DiskName $diskname0 -Force;

$diskconfig2 = New-AzDiskConfig -Location $loc -SkuName 'Standard_LRS' -OsType 'Windows' `
-UploadSizeInBytes 35183298347520 -CreateOption 'Upload' -NetworkAccessPolicy "AllowAll";
New-AzDisk -ResourceGroupName $rgname -DiskName $diskname0 -Disk $diskconfig2;
$disk2 = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname0;
Assert-AreEqual "AllowAll" $disk2.NetworkAccessPolicy;

}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ public partial class NewAzureRmDiskConfigCommand : Microsoft.Azure.Commands.Reso
[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("Disk", "New"))
Expand Down Expand Up @@ -343,6 +353,8 @@ private void Run()
CreationData = vCreationData,
EncryptionSettingsCollection = vEncryptionSettingsCollection,
Encryption = vEncryption,
NetworkAccessPolicy = NetworkAccessPolicy,
DiskAccessId = DiskAccessId
};

WriteObject(vDisk);
Expand Down
4 changes: 4 additions & 0 deletions src/Compute/Compute/Generated/Models/PSDisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ public string ResourceGroupName
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; }

}
}
34 changes: 33 additions & 1 deletion src/Compute/Compute/help/New-AzDiskConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ New-AzDiskConfig [[-SkuName] <String>] [[-OsType] <OperatingSystemTypes>] [[-Dis
[-ImageReference <ImageDiskReference>] [-GalleryImageReference <ImageDiskReference>] [-SourceUri <String>]
[-SourceResourceId <String>] [-UploadSizeInBytes <Int64>] [-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 @@ -229,6 +230,37 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -DiskAccessId
Id of DiskAccess.

```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
```

### -EncryptionType
The type of key used to encrypt the data of the disk. Available values are: 'EncryptionAtRestWithPlatformKey', 'EncryptionAtRestWithCustomerKey'

Expand Down