Public/Approve-ManagedPrivateEndpoint.ps1
<#
.SYNOPSIS Approves managed private endpoints for Azure Data Factory, Synapse, or Fabric. .DESCRIPTION The Fun1 function finds and approves all managed private endpoints in an Azure Data Factory, Synapse, or Fabric workspace that are not in the "Succeeded" state. The function locates private endpoint connections, approves them if necessary, and waits until they're in the "Succeeded" state. .PARAMETER factoryName The name of the Azure Data Factory. Used with the AzureDataFactory parameter set. .PARAMETER synapseName The name of the Azure Synapse workspace. Used with the AzureSynapse parameter set. .PARAMETER fabricName The name of the Azure Fabric workspace. Used with the AzureFabric parameter set. .PARAMETER resourceGroupName The Azure resource group containing the resource. .PARAMETER subscriptionId The Azure subscription ID. If not provided, the current subscription will be used. .PARAMETER apiVersion The API version to use when making requests. Defaults to "2018-06-01". .EXAMPLE Fun1 -factoryName "myDataFactory" -resourceGroupName "myResourceGroup" Approves all managed private endpoints in the specified Azure Data Factory. .EXAMPLE Fun1 -synapseName "mySynapseWorkspace" -resourceGroupName "myResourceGroup" -subscriptionId "00000000-0000-0000-0000-000000000000" Approves all managed private endpoints in the specified Azure Synapse workspace with a specific subscription ID. .NOTES This function requires appropriate permissions to approve private endpoint connections. It relies on several helper functions: Get-SubscriptionId, List-ManagedPrivateEndpoint, Get-ManagedPrivateEndpoint, and Write-Log. .LINK Get-AzPrivateEndpointConnection Approve-AzPrivateEndpointConnection #> Function Approve-ManagedPrivateEndpoint { [CmdletBinding()] param ( [Parameter(Mandatory = $true, ParameterSetName = 'AzureDataFactory')] [string]$factoryName, [Parameter(Mandatory = $true, ParameterSetName = 'AzureSynapse')] [string]$synapseName, [Parameter(Mandatory = $true, ParameterSetName = 'AzureFabric')] [string]$fabricName, [Parameter(Mandatory = $true, ParameterSetName = 'AzureDataFactory')] [Parameter(Mandatory = $true, ParameterSetName = 'AzureSynapse')] [Parameter(Mandatory = $true, ParameterSetName = 'AzureFabric')] [string]$resourceGroupName, [string]$subscriptionId = $null, [string]$apiVersion = "2018-06-01" ) $subscriptionId = (Get-CurrentSubscriptionId -subscriptionId $subscriptionId)[1] if ($factoryName) { #collect all managed private endpoints $listManagedPrivateEndpoints = List-ManagedPrivateEndpoint -factoryName $factoryName -resourceGroupName $resourceGroupName -subscriptionId $subscriptionId -apiVersion $apiVersion Write-InformationColored -ForegroundColor Green -MessageData "List of managed private endpoints in $factoryName : $($($listManagedPrivateEndpoints | Select-Object -Property name, @{Name='ProvisioningState'; Expression={$_.properties.ProvisioningState}},@{Name='FQDN'; Expression={$_.properties.fqdns}} ) | ConvertTo-Json -Depth 10)" #iterate through all managed private endpoints Approve-ManagedPrivateEndpointDataFactory -factoryName $factoryName -resourceGroupName $resourceGroupName -listManagedPrivateEndpoints $listManagedPrivateEndpoints -subscriptionId $subscriptionId -apiVersion $apiVersion } } |