Skip to content

Commit add755e

Browse files
wdehrichWill Ehrich
andauthored
Add PrivateEndpointVNetPolicies parameter (#26091)
* Add PrivateEndpointVNetPolicies parameter * Update format.ps1xml * Some boilerplate code * Some more boilerplate code * Test * Fix * Parameter PrivateEndpointVNetPolicies of cmdlet New-AzVirtualNetwork does not follow the enforced naming convention of using a singular noun for a parameter name. * Update ChangeLog * Fix parameter name * Fix change log * Able to run test now * Creating a virtual network * Looks like default behavior is working * Fix comments * Setting PrivateEndpointVNetPolicies to Basic works * Enabling for PL64K is working * Disabling for PL64K is working * Testing is working * Update help file New-AzVirtualNetwork.md * Fix NrpTeamAlias --------- Co-authored-by: Will Ehrich <wehrich@microsoft.com>
1 parent 193cb84 commit add755e

File tree

8 files changed

+3170
-2
lines changed

8 files changed

+3170
-2
lines changed

src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,13 @@ public void TestVirtualNetworkEncryption()
209209
{
210210
TestRunner.RunTestScript("Test-VirtualNetworkEncryption");
211211
}
212+
213+
[Fact]
214+
[Trait(Category.AcceptanceType, Category.CheckIn)]
215+
[Trait(Category.Owner, NrpTeamAlias.plcpdev)]
216+
public void TestVirtualNetworkPrivateEndpointVNetPolicies()
217+
{
218+
TestRunner.RunTestScript("Test-VirtualNetworkPrivateEndpointVNetPolicies");
219+
}
212220
}
213221
}

src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,4 +1816,61 @@ function Test-VirtualNetworkEncryption
18161816
# Cleanup
18171817
Clean-ResourceGroup $rgname
18181818
}
1819+
}
1820+
1821+
<#
1822+
.SYNOPSIS
1823+
Tests creating, updating, and deleting virtual networks with the PrivateEndpointVNetPolicies property
1824+
.DESCRIPTION
1825+
#>
1826+
function Test-VirtualNetworkPrivateEndpointVNetPolicies
1827+
{
1828+
# Setup
1829+
$rgname = Get-ResourceGroupName
1830+
$vnet1Name = Get-ResourceName
1831+
$vnet2Name = Get-ResourceName
1832+
$vnet3Name = Get-ResourceName
1833+
$rglocation = Get-ProviderLocation ResourceManagement
1834+
$resourceTypeParent = "Microsoft.Network/virtualNetworks"
1835+
$location = Get-ProviderLocation $resourceTypeParent "eastus2euap"
1836+
1837+
try
1838+
{
1839+
# Create the resource group
1840+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
1841+
1842+
# Create virtual network without specifying PrivateEndpointVNetPolicies
1843+
New-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname -Location $location -AddressPrefix 10.1.0.0/16
1844+
1845+
# Verify that PrivateEndpointVNetPolicies is "Disabled" by default
1846+
$vnet1 = Get-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname
1847+
Assert-AreEqual "Disabled" $vnet1.PrivateEndpointVNetPolicies
1848+
1849+
# Create virtual network with PrivateEndpointVNetPolicies specified as "Disabled"
1850+
New-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname -Location $location -AddressPrefix 10.2.0.0/16 -PrivateEndpointVNetPoliciesValue "Disabled"
1851+
$vnet2 = Get-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname
1852+
Assert-AreEqual "Disabled" $vnet2.PrivateEndpointVNetPolicies
1853+
1854+
# Validate that the virtual network can be updated to set PrivateEndpointVNetPolicies to "Basic"
1855+
$vnet2.PrivateEndpointVNetPolicies = "Basic"
1856+
$vnet2 | Set-AzVirtualNetwork
1857+
$vnet2 = Get-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname
1858+
Assert-AreEqual "Basic" $vnet2.PrivateEndpointVNetPolicies
1859+
1860+
# Create virtual network with PrivateEndpointVNetPolicies specified as "Basic"
1861+
New-AzVirtualNetwork -Name $vnet3Name -ResourceGroupName $rgname -Location $location -AddressPrefix 10.3.0.0/16 -PrivateEndpointVNetPoliciesValue "Basic"
1862+
$vnet3 = Get-AzVirtualNetwork -Name $vnet3Name -ResourceGroupName $rgname
1863+
Assert-AreEqual "Basic" $vnet3.PrivateEndpointVNetPolicies
1864+
1865+
# Validate that the virtual network can be updated to set PrivateEndpointVNetPolicies to "Disabled"
1866+
$vnet3.PrivateEndpointVNetPolicies = "Disabled"
1867+
$vnet3 | Set-AzVirtualNetwork
1868+
$vnet3 = Get-AzVirtualNetwork -Name $vnet3Name -ResourceGroupName $rgname
1869+
Assert-AreEqual "Disabled" $vnet3.PrivateEndpointVNetPolicies
1870+
}
1871+
finally
1872+
{
1873+
# Cleanup
1874+
Clean-ResourceGroup $rgname
1875+
}
18191876
}

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.VirtualNetworkTests/TestVirtualNetworkPrivateEndpointVNetPolicies.json

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

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* Added support of `DestinationIPAddress` property in `New-AzPrivateLinkService` command
4848
- `LoadBalancerFrontendIpConfiguration` is not a mandatory parameter anymore.
4949
- The user can provide either `LoadBalancerFrontendIpConfiguration` or `DestinationIPAddress`.
50+
* Added support for `PrivateEndpointVNetPolicies` property in `New-AzVirtualNetwork`
5051

5152
## Version 7.8.1
5253
* Fixed secrets exposure in example documentation.

src/Network/Network/Models/PSVirtualNetwork.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class PSVirtualNetwork : PSTopLevelResource, IResourceReference, IVirtual
4949

5050
public PSExtendedLocation ExtendedLocation { get; set; }
5151

52+
[Ps1Xml(Target = ViewControl.Table)]
53+
public string PrivateEndpointVNetPolicies { get; set; }
54+
5255
[JsonIgnore]
5356
public string AddressSpaceText
5457
{

src/Network/Network/Network.format.ps1xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
<Label>ExtendedLocation</Label>
153153
<PropertyName>ExtendedLocationText</PropertyName>
154154
</ListItem>
155+
<ListItem>
156+
<Label>PrivateEndpointVNetPolicies</Label>
157+
<PropertyName>PrivateEndpointVNetPolicies</PropertyName>
158+
</ListItem>
155159
</ListItems>
156160
</ListEntry>
157161
</ListEntries>

src/Network/Network/VirtualNetwork/NewAzureVirtualNetworkCommand.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public class NewAzureVirtualNetworkCommand : VirtualNetworkBaseCmdlet
125125
HelpMessage = "The edge zone of the virtual network.")]
126126
public string EdgeZone { get; set; }
127127

128+
[Parameter(
129+
Mandatory = false,
130+
ValueFromPipelineByPropertyName = true,
131+
HelpMessage = "The PrivateEndpointVNetPolicies of the virtual network")]
132+
public string PrivateEndpointVNetPoliciesValue { get; set; }
133+
128134
[Parameter(
129135
Mandatory = false,
130136
HelpMessage = "Do not ask for confirmation if you want to override a resource")]
@@ -193,6 +199,11 @@ private PSVirtualNetwork CreateVirtualNetwork()
193199
vnet.ExtendedLocation = new PSExtendedLocation(this.EdgeZone);
194200
}
195201

202+
if(!string.IsNullOrEmpty(this.PrivateEndpointVNetPoliciesValue))
203+
{
204+
vnet.PrivateEndpointVNetPolicies = this.PrivateEndpointVNetPoliciesValue;
205+
}
206+
196207
// Map to the sdk object
197208
var vnetModel = NetworkResourceManagerProfile.Mapper.Map<MNM.VirtualNetwork>(vnet);
198209
vnetModel.Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

src/Network/Network/help/New-AzVirtualNetwork.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ New-AzVirtualNetwork -Name <String> -ResourceGroupName <String> -Location <Strin
1818
[-DnsServer <String[]>] [-FlowTimeout <Int32>] [-Subnet <PSSubnet[]>] [-BgpCommunity <String>]
1919
[-EnableEncryption <String>] [-EncryptionEnforcementPolicy <String>] [-Tag <Hashtable>]
2020
[-EnableDdosProtection] [-DdosProtectionPlanId <String>] [-IpAllocation <PSIpAllocation[]>]
21-
[-EdgeZone <String>] [-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
22-
[<CommonParameters>]
21+
[-EdgeZone <String>] [-PrivateEndpointVNetPoliciesValue <String>] [-Force] [-AsJob]
22+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2323
```
2424

2525
## DESCRIPTION
@@ -300,6 +300,21 @@ Accept pipeline input: True (ByPropertyName)
300300
Accept wildcard characters: False
301301
```
302302
303+
### -PrivateEndpointVNetPoliciesValue
304+
The PrivateEndpointVNetPolicies of the virtual network
305+
306+
```yaml
307+
Type: System.String
308+
Parameter Sets: (All)
309+
Aliases:
310+
311+
Required: False
312+
Position: Named
313+
Default value: None
314+
Accept pipeline input: True (ByPropertyName)
315+
Accept wildcard characters: False
316+
```
317+
303318
### -ResourceGroupName
304319
Specifies the name of a resource group to contain the virtual network.
305320

0 commit comments

Comments
 (0)