Skip to content

Commit acae733

Browse files
Vishakha-GitVishN4
andauthored
Enable ARM to the Private Link connection Cmdlets (#18358)
* enable Private link support * both set to true * Add testcase * Add recording Co-authored-by: Vishakha Narvekar <[email protected]>
1 parent cdeb8f0 commit acae733

File tree

4 files changed

+2040
-1
lines changed

4 files changed

+2040
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,13 @@ public void TestStoragePrivateEndpoint()
5656
{
5757
TestRunner.RunTestScript("Test-StoragePrivateEndpoint");
5858
}
59+
60+
[Fact]
61+
[Trait(Category.AcceptanceType, Category.CheckIn)]
62+
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
63+
public void TestResourceManagerPrivateEndpoint()
64+
{
65+
TestRunner.RunTestScript("Test-ResourceManagerPrivateEndpoint");
66+
}
5967
}
6068
}

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,61 @@ function Test-PrivateLinkServiceInEdgeZone
320320
# Cleanup
321321
Clean-ResourceGroup $rgname
322322
}
323+
}
324+
325+
<#
326+
.SYNOPSIS
327+
Test operation for ResourceManagerPrivateEndpoint.
328+
#>
329+
function Test-ResourceManagerPrivateEndpoint
330+
{
331+
# Setup
332+
$rgname = "testPS"
333+
$rmplname = "RMPL"
334+
$location = "eastus"
335+
$sub = getSubscription
336+
# Dependency parameters
337+
$IpConfigurationName = "IpConfigurationName"
338+
$vnetName = Get-ResourceName
339+
$plsConnectionName = Get-ResourceName
340+
$endpointName = Get-ResourceName
341+
342+
try
343+
{
344+
New-AzResourceGroup -Name $rgname -Location $location
345+
346+
#Create ResourceManagementPrivateLink
347+
#$rmpl = New-AzResourceManagementPrivateLink -ResourceGroupName $rgName -Name $rmplname -Location $location
348+
349+
$rmplid = "/subscriptions/$sub/resourceGroups/$rgname/providers/Microsoft.Authorization/resourceManagementPrivateLinks/$rmplname"
350+
$PrivateLinkResource = Get-AzPrivateLinkResource -PrivateLinkResourceId $rmplid
351+
352+
#Vnet Configuration
353+
$SubnetConfig = New-AzVirtualNetworkSubnetConfig -Name "Subnet" -AddressPrefix "11.0.1.0/24" -PrivateEndpointNetworkPolicies "Disabled"
354+
$VNet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "11.0.0.0/16" -Subnet $SubnetConfig
355+
356+
# Create Private Endpoint
357+
$PLSConnection = New-AzPrivateLinkServiceConnection -Name $plsConnectionName -PrivateLinkServiceId $rmplid -GroupId "ResourceManagement"
358+
$privateEndpoint = New-AzPrivateEndpoint -ResourceGroupName $rgName -Name $endpointName -Location $location -Subnet $VNet.subnets[0] -PrivateLinkServiceConnection $PLSConnection -ByManualRequest
359+
360+
$pecGet = Get-AzPrivateEndpointConnection -PrivateLinkResourceId $rmplid
361+
Assert-NotNull $pecGet;
362+
Assert-AreEqual "Pending" $pecGet.PrivateLinkServiceConnectionState.Status
363+
364+
# Approve Private Endpoint Connection
365+
$pecApprove = Approve-AzPrivateEndpointConnection -ResourceId $pecGet.Id
366+
Assert-NotNull $pecApprove;
367+
Start-TestSleep 15000
368+
$pecApprove = Get-AzPrivateEndpointConnection -ResourceId $pecGet.Id
369+
Assert-AreEqual "Approved" $pecApprove.PrivateLinkServiceConnectionState.Status
370+
371+
# Remove Private Endpoint Connection
372+
$pecRemove = Remove-AzPrivateEndpointConnection -ResourceId $pecGet.Id -PassThru -Force
373+
Assert-AreEqual true $pecRemove
374+
}
375+
finally
376+
{
377+
#Cleanup
378+
Clean-ResourceGroup $rgname;
379+
}
323380
}

0 commit comments

Comments
 (0)