On-premise Data Gateway how can I track the amount of Logic Apps connected?

Mendieta Dour, Constanza 21 Reputation points
2020-06-30T22:14:10.113+00:00

We have several Logic Apps from different Azure subscriptions connected through 1 On-premise Data Gateway. Is there any way to keep track of the amount connections? We are currently using this On-premise Data Gateway only for Logic App.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,204 questions
0 comments No comments
{count} votes

Accepted answer
  1. Samara Soucy - MSFT 5,131 Reputation points
    2020-07-07T05:15:22.607+00:00

    There isn't a way to do this through the portal, but it can be done through either the Azure Management REST API or the CLI using the az rest command as long as you have sufficient permissions. Here's a CLI script that retrieves all the API connections using a gateway and the Logic Apps connected to them. You need to add the name of your gateway from your Azure account. If you want to pull the data from all subscriptions, uncomment the part that loops through your subs (lines 56-60) and comment out the lines that run just your default subscription (63-65).

    #az login
    
    $gatewayName = ""
    $connectionList = New-Object -TypeName "System.Collections.ArrayList"
    $appList = New-Object -TypeName "System.Collections.ArrayList"
    
    function Get-Apps {
        param( [object]$sub )
        "Getting Logic Apps"
        $logicAppUri = "/subscriptions/"+ $sub.id +"/providers/Microsoft.Logic/workflows?api-version=2019-05-01"
        $results = az rest --method get --uri $logicAppUri | convertfrom-json
        $apps = $results.value
        $apps.Count.ToString() + " logic apps found"
        $apps | ForEach-Object {
            $val = $_
            $val | Add-Member -MemberType NoteProperty -Name connectionIds -value (New-object System.Collections.Arraylist)
            $_.properties.parameters.'$connections'.value.PSObject.Properties | ForEach-Object {if($_.Value.connectionId -ne $null) {
                    $val.connectionIds.Add($_.Value.connectionId)
                }
        }}
    
        foreach($match in $connectionList) {
            "Checking connection " + $match.name
            $matches =  $apps | Where-Object { $_.connectionIds -eq $match.id}
            $matches
            if($matches -is [array]) {
                  $matches.Count.ToString() + " app matches found"
                  $appList.AddRange($matches)
              }
              elseif($matches -ne $null) {
                "1 app match found"
                $appList.Add($matches)
              }
        }
    }
    
    function Check-Connections {
     param( [object]$sub )
     "checking " + $sub.name
      $uri = "/subscriptions/" + $sub.id + "/providers/Microsoft.Web/connections?api-version=2018-07-01-preview"
      $connections = az rest --method get --uri $uri --only-show-errors | convertfrom-json
      $connections.value.Count.ToString() + " connections found"
    
      $matches = $connections.value | Where-Object { $_.properties.parameterValues.gateway.name -eq $gatewayName}
      if($matches -is [array]) {
          $matches.Count.ToString() + " connection matches found"
          $connectionList.AddRange($matches)
      }
      elseif($matches -ne $null) {
        "1 connection match found"
        $connectionList.Add($matches)
      }
    }
    
    ### Run all subs
    #$subscriptions = az account list | convertfrom-json
    #foreach ($sub in $subscriptions) {
    #   Check-Connections $sub
    #   Get-Apps $sub
    # }
    
    ###run single sub
    $sub = az account show | convertfrom-json
    Check-Connections $sub
    Get-Apps $sub
    
    "--------"
    "Results:"
    "--------"
    "Connections:"
    $connectionList | Select-Object -Property name
    "Apps:"
    $appList | Select-Object -Property name
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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