Find out which On-premises Data Gateways are used by which API connection resources
Published Apr 14 2021 08:48 PM 3,215 Views

API connections resources work as the bridges for Logic App to communicate with other services. While most of them are used to connect to cloud resources, a few of them leverage On-premises Data Gateways to connect local data sources to Azure. However, we may find that it is not easy to check which On-premises Data Gateway (OPDG) is used by which API connection resource.



Find out which On-premises Data Gateways are used by which API connection resources.



The most known way to check OPDG used by a connector is by inspecting the Logic App designer.

  • When creating API connections with OPDG, we can find the OPDG used from the connection list in the Logic App designer.



However, this method seems unhandy as we need to go every Logic App’s designer mode and may cause unwanted change. My preferred way is to check the sourced OPDG from the JSON definition of an API connection resource.

  • From a Logic App, open the API connection blade, and choose the API connection which is using the OPDG.



  • From the API connection resource main page, click on “JSON View” on the far right.



  • In the JSON definition of the API connection, you will find the OPDG’s name, resource ID in the “properties” > “parameterValues” > “gateway”.





One more step:

As we have found out that OPDG information can be extracted from the JSON definition of an API connection resource. We can use a PowerShell script to find out all API connections which is using an OPDG.




Run the script:

  • After downloading the script into your machine, put in the name of your Azure subscription for the subscriptionName variable.



  • Then run the script and log into your Azure account in the pop-up window.




  • A CSV file named “output.csv” will be created in the same folder where the script resides.



  • The CSV file will contain all API connection resources along with the OPDGs they are using.



connectionName: name of the API connection resource

connectionId: resource ID of the API connection

gatewayName: name of the On-premises Data Gateway resource

gatewatyId: resource ID of the On-premises Data Gateway




  • If you encountered the "script not signed" error, you might try the below PowerShell command to bypass the security policy in the current session.
    Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass​


  • Alternative to run the script locally, you may choose to run this through Azure cloud shell. However, please remember the first command "Connect-AzAccount" as it will no longer be required.


Raw script:


# If you encountered "script is not signed error", please use below comand in the PowerShell first.
# Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

# Login to your Azure Account:

# Put in your own subscription name:
$subsctionName = ''

Set-AzContext -SubscriptionName $subsctionName

# Get all API connection resources 
$connectionList = Get-AzResource -ResourceType 'Microsoft.Web/connections'

# Loop through connection list
Write-Host '---------------------------------------'
Write-Host '  Start loop connections - Processing'
Write-Host '---------------------------------------'
$result = @()
foreach ($connection in $connectionList){
    $currentConnectionObj = Get-AzResource -ResourceId $connection.ResourceId
    $connectionName = $currentConnectionObj.Name
    $connectionId = $connection.ResourceId 
    Write-Host 'Processing connection:' $connectionName
    # Extract gateway information
    $opdgName = $
    $opdgId = $
    if (!($opdgId -eq $null)){
        Write-Host '------------------------------------------------'
        Write-Host 'OPDG found:'
        Write-Host 'Connection' $connectionName 'is using gateway' $opdgName
        Write-Host '------------------------------------------------'

        $new = [PSCustomObject]@{
            connectionName = $connectionName
            connectionId = $connectionId
            gatewayName = $opdgName
            gatewayId = $opdgId

        $result += $new

# Write collected information to output.csv file
$result | Export-Csv -Path .\output.csv -NoTypeInformation





1 Comment
Version history
Last update:
‎Apr 14 2021 02:54 AM
Updated by: