Testing if my Connector is connected
  • 31 May 2020
  • 1 Minute to read
  • Contributors
  • Comment
  • Dark
    Light
  • PDF

Testing if my Connector is connected

  • Comment
  • Dark
    Light
  • PDF

Article Summary

Big thanks to my friend John Paddington for this idea, when I was showing him some of the Pester stuff I had been working on he said "Wouldnt it be cool if you could test the status of a Logic App connector". Well it turned out to be pretty straightforward!

In a previous article I talked about how I could test if my API Connectors for Logic Apps were pointing at the right SAP instance in this article.

https://www.integration-playbook.io/docs/testing-sap-connector-info

I now want to extend the tests and also include a test to see if my Connector is "Connected". The problem here is that sometimes your connectors become in an errored state, for example if your Office 365 connector is no longer Authorized or other problems and you dont always know if they are connected.

I added a new pester test to my bank of governance tests to check the state of the connector. From the existing test I have already got the json for the connector using the snipped below from the previous article.

    #Get the connector json
    $connectorUrl = $apiConnection.ResourceId + '?api-version=2018-07-01-preview'        
    $connectorJson = az rest --method get --uri $connectorUrl
    $connectorJsonText = $connectorJson | ConvertFrom-Json

I can now extend the script and add another test which allows me to check the status of the connector. It is very simple just by adding the below test.

It "$($apiConnection.Name) should be enabled" { 
        
            
                #Write-Host ($connectorJson | Format-List | Out-String)           
                $properties = $connectorJsonText.properties

                $statuses = $properties.statuses
                $currentStatus = $statuses[0]
                $status = $currentStatus.status

                $status.ToLower() | Should Be 'connected'
            }

Its that simple and now when my script runs and checks all of the connectors I get a test for each connector which allows me to see if they are all connected and a failed test if any are in an error state.


Was this article helpful?