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