Skip to content

Commit 802364c

Browse files
wdehrichWill Ehrich
andauthored
Add edge zone parameter to private link service cmdlet (#15282)
* Add edge zone parameter to private link service * UT boilerplate code * Update change log * UT is passing * Refactor UT * Update test and add session record Co-authored-by: Will Ehrich <[email protected]>
1 parent 5e753d6 commit 802364c

File tree

8 files changed

+2107
-21
lines changed

8 files changed

+2107
-21
lines changed

src/Network/Network.Test/ScenarioTests/PrivateLinkServiceTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public void TestPrivateLinkServiceCRUD()
3333
TestRunner.RunTestScript("Test-PrivateLinkServiceCRUD");
3434
}
3535

36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
39+
public void TestPrivateLinkServiceInEdgeZone()
40+
{
41+
TestRunner.RunTestScript("Test-PrivateLinkServiceInEdgeZone");
42+
}
43+
3644
[Fact]
3745
[Trait(Category.AcceptanceType, Category.CheckIn)]
3846
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]

src/Network/Network.Test/ScenarioTests/PrivateLinkServiceTests.ps1

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,64 @@ function Test-StoragePrivateEndpoint
260260
Clean-ResourceGroup $rgname;
261261
}
262262
}
263+
264+
<#
265+
.SYNOPSIS
266+
Test creating a private link service in an edge zone. Subscriptions need to be explicitly whitelisted for access to edge zones.
267+
#>
268+
function Test-PrivateLinkServiceInEdgeZone
269+
{
270+
# Setup
271+
$rgname = Get-ResourceGroupName
272+
$rname = Get-ResourceName
273+
$location = "westus"
274+
# Dependency parameters
275+
$IpConfigurationName = "IpConfigurationName"
276+
$vnetName = Get-ResourceName
277+
$ilbFrontName = "LB-Frontend"
278+
$ilbBackendName = "LB-Backend"
279+
$ilbName = Get-ResourceName
280+
$edgeZone = "microsoftlosangeles1"
281+
282+
try
283+
{
284+
New-AzResourceGroup -Name $rgname -Location $location
285+
286+
# Create Virtual networks
287+
$frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name "frontendSubnet" -AddressPrefix "10.0.1.0/24"
288+
$backendSubnet = New-AzVirtualNetworkSubnetConfig -Name "backendSubnet" -AddressPrefix "10.0.2.0/24"
289+
$otherSubnet = New-AzVirtualNetworkSubnetConfig -Name "otherSubnet" -AddressPrefix "10.0.3.0/24" -PrivateLinkServiceNetworkPoliciesFlag "Disabled"
290+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet,$backendSubnet,$otherSubnet -EdgeZone $edgeZone
291+
292+
# Create LoadBalancer
293+
$frontendIP = New-AzLoadBalancerFrontendIpConfig -Name $ilbFrontName -PrivateIpAddress "10.0.1.5" -SubnetId $vnet.subnets[0].Id
294+
$beaddresspool= New-AzLoadBalancerBackendAddressPoolConfig -Name $ilbBackendName
295+
$ilbcreate = New-AzLoadBalancer -ResourceGroupName $rgname -Name $ilbName -Location $location -FrontendIpConfiguration $frontendIP -BackendAddressPool $beaddresspool -Sku "Standard" -EdgeZone $edgeZone
296+
297+
# Verfify if load balancer is created successfully
298+
Assert-NotNull $ilbcreate
299+
Assert-AreEqual $ilbName $ilbcreate.Name
300+
Assert-AreEqual (Normalize-Location $location) $ilbcreate.Location
301+
Assert-AreEqual "Succeeded" $ilbcreate.ProvisioningState
302+
303+
# Create required dependencies
304+
$IpConfiguration = New-AzPrivateLinkServiceIpConfig -Name $IpConfigurationName -PrivateIpAddress 10.0.3.5 -Subnet $vnet.subnets[2]
305+
$LoadBalancerFrontendIpConfiguration = Get-AzLoadBalancer -Name $ilbName | Get-AzLoadBalancerFrontendIpConfig
306+
307+
# Create PrivateLinkService
308+
New-AzPrivateLinkService -ResourceGroupName $rgName -Name $rname -Location $location -IpConfiguration $IpConfiguration -LoadBalancerFrontendIpConfiguration $LoadBalancerFrontendIpConfiguration -EdgeZone $edgeZone
309+
$vPrivateLinkService = Get-AzPrivateLinkService -Name $rname -ResourceGroupName $rgName
310+
311+
Assert-AreEqual $vPrivateLinkService.ExtendedLocation.Name $edgeZone
312+
Assert-AreEqual $vPrivateLinkService.ExtendedLocation.Type "EdgeZone"
313+
}
314+
catch [Microsoft.Azure.Commands.Network.Common.NetworkCloudException]
315+
{
316+
Assert-NotNull { $_.Exception.Message -match 'Resource type .* does not support edge zone .* in location .* The supported edge zones are .*' }
317+
}
318+
finally
319+
{
320+
# Cleanup
321+
Clean-ResourceGroup $rgname
322+
}
323+
}

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.PrivateLinkServiceTests/TestPrivateLinkServiceInEdgeZone.json

Lines changed: 1990 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
@@ -22,6 +22,7 @@
2222
* Updated cmdlets to enable specification of edge zone
2323
- `New-AzPublicIpPrefix`
2424
- `New-AzLoadBalancer`
25+
- `New-AzPrivateLinkService`
2526
* Added support for viewing extended location of virtual network in the console
2627
- `New-AzVirtualNetwork`
2728
- `Get-AzVirtualNetwork`

src/Network/Network/Models/PSPrivateLinkService.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
1-
// <auto-generated>
2-
// Copyright (c) Microsoft and contributors. All rights reserved.
3-
//
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
98
// Unless required by applicable law or agreed to in writing, software
109
// distributed under the License is distributed on an "AS IS" BASIS,
1110
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
//
1311
// See the License for the specific language governing permissions and
1412
// limitations under the License.
15-
//
16-
//
17-
// Warning: This code was generated by a tool.
18-
//
19-
// Changes to this file may cause incorrect behavior and will be lost if the
20-
// code is regenerated.
21-
//
22-
// For documentation on code generator please visit
23-
// https://aka.ms/nrp-code-generation
24-
// Please contact [email protected] if you need to make changes to this file.
25-
// </auto-generated>
13+
// ----------------------------------------------------------------------------------
2614

2715
using Microsoft.Azure.Management.Network.Models;
2816
using Newtonsoft.Json;
@@ -49,6 +37,8 @@ public partial class PSPrivateLinkService : PSTopLevelResource
4937

5038
public bool? EnableProxyProtocol { get; set; }
5139

40+
public PSExtendedLocation ExtendedLocation { get; set; }
41+
5242
[JsonIgnore]
5343
public string LoadBalancerFrontendIpConfigurationsText
5444
{
@@ -84,5 +74,11 @@ public string AutoApprovalText
8474
{
8575
get { return JsonConvert.SerializeObject(AutoApproval, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
8676
}
77+
78+
[JsonIgnore]
79+
public string ExtendedLocationText
80+
{
81+
get { return JsonConvert.SerializeObject(ExtendedLocation, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
82+
}
8783
}
8884
}

src/Network/Network/Network.format.ps1xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,6 +5317,10 @@
53175317
<Label>NetworkInterfaces</Label>
53185318
<PropertyName>NetworkInterfacesText</PropertyName>
53195319
</ListItem>
5320+
<ListItem>
5321+
<Label>ExtendedLocation</Label>
5322+
<PropertyName>ExtendedLocationText</PropertyName>
5323+
</ListItem>
53205324
</ListItems>
53215325
</ListEntry>
53225326
</ListEntries>

src/Network/Network/PrivateLinkService/NewAzurePrivateLinkServiceCommand.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ public class NewAzurePrivateLinkService : PrivateLinkServiceBaseCmdlet
8282
HelpMessage = "Whether to enable proxy protocol or not")]
8383
public SwitchParameter EnableProxyProtocol { get; set; }
8484

85+
[Parameter(
86+
Mandatory = false,
87+
ValueFromPipelineByPropertyName = true,
88+
HelpMessage = "The edge zone of the private link service")]
89+
public string EdgeZone { get; set; }
90+
8591
[Parameter(
8692
Mandatory = false,
8793
ValueFromPipelineByPropertyName = true,
@@ -124,6 +130,11 @@ private PSPrivateLinkService CreatePSPrivateLinkService()
124130

125131
psPrivateLinkService.EnableProxyProtocol = this.EnableProxyProtocol.IsPresent;
126132

133+
if (!string.IsNullOrEmpty(this.EdgeZone))
134+
{
135+
psPrivateLinkService.ExtendedLocation = new PSExtendedLocation(this.EdgeZone);
136+
}
137+
127138
var plsModel = NetworkResourceManagerProfile.Mapper.Map<MNM.PrivateLinkService>(psPrivateLinkService);
128139
plsModel.Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);
129140

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Creates a private link service
1515
```
1616
New-AzPrivateLinkService -Name <String> -ResourceGroupName <String> -Location <String>
1717
-LoadBalancerFrontendIpConfiguration <PSFrontendIPConfiguration[]>
18-
-IpConfiguration <PSPrivateLinkServiceIpConfiguration[]> [-Visibility <String[]>] [-AutoApproval <String[]>] [-EnableProxyProtocol]
19-
[-Tag <Hashtable>] [-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
20-
[<CommonParameters>]
18+
-IpConfiguration <PSPrivateLinkServiceIpConfiguration[]> [-Visibility <String[]>] [-AutoApproval <String[]>]
19+
[-EnableProxyProtocol] [-EdgeZone <String>] [-Tag <Hashtable>] [-Force] [-AsJob]
20+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2121
```
2222

2323
## DESCRIPTION
@@ -87,6 +87,21 @@ Accept pipeline input: False
8787
Accept wildcard characters: False
8888
```
8989
90+
### -EdgeZone
91+
The edge zone of the private link service
92+
93+
```yaml
94+
Type: System.String
95+
Parameter Sets: (All)
96+
Aliases:
97+
98+
Required: False
99+
Position: Named
100+
Default value: None
101+
Accept pipeline input: True (ByPropertyName)
102+
Accept wildcard characters: False
103+
```
104+
90105
### -EnableProxyProtocol
91106
Enable proxy protocol for the private link service.
92107
@@ -98,7 +113,7 @@ Aliases:
98113
Required: False
99114
Position: Named
100115
Default value: None
101-
Accept pipeline input: False
116+
Accept pipeline input: True (ByPropertyName)
102117
Accept wildcard characters: False
103118
```
104119

0 commit comments

Comments
 (0)