Share via

Create Managed Private end points for function App in Datafatory using RestAPI or Powershell

LnT 0 Reputation points
2023-09-21T14:24:24.4966667+00:00

Dear Team,

0.14.11 is the Terraform version being used to create Datafactory and also created Managed private end points for SQLdb and storageAccount in Datafatory .

& unable to create Managed private end points for Sites(FunctionApps) in Datafatory .

Could you provide a work around to create Managed private end points for sites (FunctionApps) in Datafatory either using Azure PowerShell module or Rest API?

Fyi - Vnet is default.

Sample code snippet of powershell is highly appreciated. ThanksUser's image

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.


1 answer

Sort by: Most helpful
  1. Anonymous
    2023-09-22T05:26:41.13+00:00

    It has been done in two steps.

    1. one powershell script creates MPE in ADF (Using Rest API)
    # Variables
    $gcc="xxx"
    $resourceGroupName = "resourceGroupName"
    $dataFactoryName = "dataFactoryName-$gcc-05"
    $functionAppName = "functionAppName-$gcc-05"
    $privateEndpointName = "pe_linked_service_fun_$gcc"
    $location = "West Europe"
    $subscriptionId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
    $privateLinkResourceId="/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.Web/sites/$functionAppName"
    
    # Authenticate and get access token
    
    #Connect-AzAccount 
    $context = Set-AzContext -SubscriptionId  $subscriptionId 
    $context.Subscription.Name 
    $ADFazProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile;
    $ADFprofileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($ADFazProfile);
    $ADFtoken = $ADFprofileClient.AcquireAccessToken($context.Subscription.TenantId);
    $ADFauthHeader = @{
        'Content-Type'='application/json'
        'Authorization'='Bearer ' + $ADFtoken.AccessToken
    };
    
    
    # Create a Managed Private Endpoint for ADF
    $privateEndpointUri = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.DataFactory/factories/$dataFactoryName/managedVirtualNetworks/default/managedPrivateEndpoints/$privateEndpointName"
    
    $apiVersion="?api-version=2018-06-01"
    
    $body = @{
      "name" = "$privateEndpointName"
      "properties" = @{
          "privateLinkResourceId" = "$privateLinkResourceId"
          "groupId" = "sites"
          "fqdns" = @(
              "$functionAppName.azurewebsites.net",
              "$functionAppName.scm.azurewebsites.net"
          )
      }
    }
    
    # Convert the body to JSON
    $jsonBody = $body | ConvertTo-Json
    
    
    $response = Invoke-RestMethod -Uri $privateEndpointUri$apiVersion -Method PUT -Headers $ADFauthHeader -Body $jsonBody
    $response
    
    1. One PowerShell script approve MPE in ADF (Using Azure PowerShell module)

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.