Skip to content

Add edge zone parameter to private endpoint cmdlet #15287

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

Merged
merged 9 commits into from
Jun 17, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public void TestPrivateEndpointCRUD()
TestRunner.RunTestScript("Test-PrivateEndpointCRUD");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
public void TestPrivateEndpointInEdgeZone()
{
TestRunner.RunTestScript("Test-PrivateEndpointInEdgeZone");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.azdevxps)]
Expand Down
79 changes: 79 additions & 0 deletions src/Network/Network.Test/ScenarioTests/PrivateEndpointTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,83 @@ function Test-PrivateDnsZoneGroupCRUD
# Cleanup
Clean-ResourceGroup $rgname;
}
}

<#
.SYNOPSIS
Test creating a private endpoint in an edge zone. Subscriptions need to be explicitly whitelisted for access to edge zones.
#>
function Test-PrivateEndpointInEdgeZone
{
# Setup
$rgname = Get-ResourceGroupName
$rname = Get-ResourceName
$location = "westus"
# Dependency parameters
$vnetName = Get-ResourceName
$ilbFrontName = "LB-Frontend"
$ilbBackendName = "LB-Backend"
$ilbName = Get-ResourceName
$PrivateLinkServiceConnectionName = "PrivateLinkServiceConnectionName"
$IpConfigurationName = "IpConfigurationName"
$PrivateLinkServiceName = "PrivateLinkServiceName"
$vnetPEName = "VNetPE"
$edgeZone = "microsoftlosangeles1"

try
{
New-AzResourceGroup -Name $rgname -Location $location

# Create Virtual networks
$frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name "frontendSubnet" -AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzVirtualNetworkSubnetConfig -Name "backendSubnet" -AddressPrefix "10.0.2.0/24"
$otherSubnet = New-AzVirtualNetworkSubnetConfig -Name "otherSubnet" -AddressPrefix "10.0.3.0/24" -PrivateLinkServiceNetworkPoliciesFlag "Disabled"
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet,$backendSubnet,$otherSubnet -EdgeZone $edgeZone

# Create LoadBalancer
$frontendIP = New-AzLoadBalancerFrontendIpConfig -Name $ilbFrontName -PrivateIpAddress "10.0.1.5" -SubnetId $vnet.subnets[0].Id
$beaddresspool= New-AzLoadBalancerBackendAddressPoolConfig -Name $ilbBackendName
$ilbcreate = New-AzLoadBalancer -ResourceGroupName $rgname -Name $ilbName -Location $location -FrontendIpConfiguration $frontendIP -BackendAddressPool $beaddresspool -Sku "Standard" -EdgeZone $edgeZone

# Verfify if load balancer is created successfully
Assert-NotNull $ilbcreate
Assert-AreEqual $ilbName $ilbcreate.Name
Assert-AreEqual $location $ilbcreate.Location
Assert-AreEqual "Succeeded" $ilbcreate.ProvisioningState

# Create PrivateLinkService
$IpConfiguration = New-AzPrivateLinkServiceIpConfig -Name $IpConfigurationName -PrivateIpAddress 10.0.3.5 -Subnet $vnet.subnets[2]
$LoadBalancerFrontendIpConfiguration = Get-AzLoadBalancer -Name $ilbName | Get-AzLoadBalancerFrontendIpConfig

$vPrivateLinkService = New-AzPrivateLinkService -ResourceGroupName $rgname -Name $PrivateLinkServiceName -Location $location -IpConfiguration $IpConfiguration -LoadBalancerFrontendIpConfiguration $LoadBalancerFrontendIpConfiguration -EdgeZone $edgeZone

# Verfify if private link service is created successfully
Assert-NotNull $vPrivateLinkService
Assert-AreEqual $PrivateLinkServiceName $vPrivateLinkService.Name
Assert-NotNull $vPrivateLinkService.IpConfigurations;
Assert-True { $vPrivateLinkService.IpConfigurations.Length -gt 0 }
Assert-AreEqual "Succeeded" $vPrivateLinkService.ProvisioningState

# Create virtual network for private endpoint
$peSubnet = New-AzVirtualNetworkSubnetConfig -Name "peSubnet" -AddressPrefix "11.0.1.0/24" -PrivateEndpointNetworkPoliciesFlag "Disabled"
$vnetPE = New-AzVirtualNetwork -Name $vnetPEName -ResourceGroupName $rgName -Location $location -AddressPrefix "11.0.0.0/16" -Subnet $peSubnet -EdgeZone $edgeZone

# Create PrivateEndpoint
$PrivateLinkServiceConnection = New-AzPrivateLinkServiceConnection -Name $PrivateLinkServiceConnectionName -PrivateLinkServiceId $vPrivateLinkService.Id
New-AzPrivateEndpoint -ResourceGroupName $rgname -Name $rname -Location $location -Subnet $vnetPE.subnets[0] -PrivateLinkServiceConnection $PrivateLinkServiceConnection -EdgeZone $edgeZone

$vPrivateEndpoint = Get-AzPrivateEndpoint -Name $rname -ResourceGroupName $rgname

Assert-AreEqual $vPrivateEndpoint.ExtendedLocation.Name $edgeZone
Assert-AreEqual $vPrivateEndpoint.ExtendedLocation.Type "EdgeZone"
}
catch [Microsoft.Azure.Commands.Network.Common.NetworkCloudException]
{
Assert-NotNull { $_.Exception.Message -match 'Resource type .* does not support edge zone .* in location .* The supported edge zones are .*' }
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- `New-AzPublicIpPrefix`
- `New-AzLoadBalancer`
- `New-AzPrivateLinkService`
- `New-AzPrivateEndpoint`
* Added support for viewing extended location of virtual network in the console
- `New-AzVirtualNetwork`
- `Get-AzVirtualNetwork`
Expand Down
28 changes: 11 additions & 17 deletions src/Network/Network/Models/PSPrivateEndpoint.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
// <auto-generated>
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.
//
// For documentation on code generator please visit
// https://aka.ms/nrp-code-generation
// Please contact [email protected] if you need to make changes to this file.
// </auto-generated>
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.Network.Models;
using Microsoft.WindowsAzure.Commands.Common.Attributes;
Expand All @@ -41,6 +29,7 @@ public partial class PSPrivateEndpoint : PSTopLevelResource
public List<PSPrivateLinkServiceConnection> PrivateLinkServiceConnections { get; set; }
public List<PSPrivateLinkServiceConnection> ManualPrivateLinkServiceConnections { get; set; }
public List<PSPrivateEndpointCustomDnsConfig> CustomDnsConfigs { get; set; }
public PSExtendedLocation ExtendedLocation { get; set; }

[JsonIgnore]
public string SubnetText
Expand Down Expand Up @@ -72,6 +61,11 @@ public string CustomDnsConfigsText
get { return JsonConvert.SerializeObject(CustomDnsConfigs, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string ExtendedLocationText
{
get { return JsonConvert.SerializeObject(ExtendedLocation, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

public bool ShouldSerializeNetworkInterfaces()
{
Expand Down
4 changes: 4 additions & 0 deletions src/Network/Network/Network.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -5129,6 +5129,10 @@
<Label>CustomDnsConfigs</Label>
<PropertyName>CustomDnsConfigsText</PropertyName>
</ListItem>
<ListItem>
<Label>ExtendedLocation</Label>
<PropertyName>ExtendedLocationText</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public class NewAzurePrivateEndpoint : PrivateEndpointBaseCmdlet
HelpMessage = "Using manual request.")]
public SwitchParameter ByManualRequest { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The edge zone of the private endpoint")]
public string EdgeZone { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
Expand Down Expand Up @@ -103,7 +109,12 @@ private PSPrivateEndpoint CreatePSPrivateEndpoint()
{
psPrivateEndpoint.PrivateLinkServiceConnections = this.PrivateLinkServiceConnection.ToList();
}


if (!string.IsNullOrEmpty(this.EdgeZone))
{
psPrivateEndpoint.ExtendedLocation = new PSExtendedLocation(this.EdgeZone);
}

var peModel = NetworkResourceManagerProfile.Mapper.Map<MNM.PrivateEndpoint>(psPrivateEndpoint);
peModel.Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

Expand Down
28 changes: 19 additions & 9 deletions src/Network/Network/help/New-AzPrivateEndpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ Creates a private endpoint.

## SYNTAX

### All

```
New-AzPrivateEndpoint -Name <String> -ResourceGroupName <String> -Location <String> -Subnet <PSSubnet>
-PrivateLinkServiceConnection <PSPrivateLinkServiceConnection[]> [-ByManualRequest] [-Tag <Hashtable>]
[-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
-PrivateLinkServiceConnection <PSPrivateLinkServiceConnection[]> [-ByManualRequest] [-EdgeZone <String>]
[-Tag <Hashtable>] [-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -88,6 +87,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -EdgeZone
The edge zone of the private endpoint

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Force

Do not ask for confirmation to overwrite a resource.
Expand Down Expand Up @@ -236,11 +250,7 @@ Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](/powershell/module/microsoft.powershell.core/about/about_commonparameters).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down