Welcome again to another Logic Apps Best Practices, Tips, and Tricks. In my previous blog posts, I talked about some of the essential best practices you should have while working with Azure Logic Apps. Check out these Logic App tips and tricks!
Today I’m going to speak about another critical Best practice, Tips, and Tricks that you need to implement while administrating your cloud integration resources: Control your connectors (API connections).
#9 Control your connectors (API connections)
Developing solutions on Azure is sometimes an effortless operation. However, administrating all your Azure resources may be a different story. Have you ever stopped to think about who or what is using what on your vast list of Logic Apps and API Connectors? Something that should be basic questions, like:
- Who is using this API Connection?
- Do I have duplicate connections?
- Do I have unused connections?
And probably many more. Again, these are three basic questions that are not easy to answer and that, in a traditional way, using the Azure Portal, are thankless and quite costly tasks.
In p
In fact, two of the painful processes, not only when we are developing our Logic App, but mainly when we are administrating them, is
- Finding what API Connections are no longer being used by your Logic Apps. What we call Orphaned API Connections.
- Get a clear picture of what API Connections are being used by which Logic Apps. Or this API Connection is mapped or being used by what Logic Apps.
In a practical and logical way (at least on paper or in my head) if I want to find where a specific API Connection is being used I will go to my API Connection list or my resource group and select my connector or API connection. Let’s take as example the servicebus connector:
So, if I select my servicebus connector I can try to go thru the list of options on the API connection even in the export template that you will not find any information regarding who is consuming the API Connection!
And this will apply to all the connectors, not only the Service Bus connector.
A tip or trick here is in some cases to add a tag on this resource specifying what Logic Apps are consuming it.
However this approach has or may have several problems:
- It requires a lot of discipline!
- Because it can easily become deprecated and even validating that information is a costly task once again.
- Sometimes, several Logic Apps use the API Connection and defining all of them can be translated to a big string. The problem is that the tag name is limited to 512 characters (which is not a problem). Still, the tag value is limited to 256 characters (for storage accounts, the tag name is limited to 128 characters, and the tag value is limited to 256 characters). This can be a problem – of course, you can always create subsets of that Tag.
The only available option using the Azure Portal is to go to each Logic App, select the option API connections and from there you will see the list of all API connections associated with that specific Logic App:
Another example:
Well, here, at least in this last picture, we have only two Logic Apps, so luckily, that would be a simple task, annoying but simple. But now, imagine that you have 1000 Logic Apps? I don’t want to be on that position! I pity the person responsible for this task.
And again, if we want to find orphaned API Connections the process is the same, go to each Logic App to see if the API connection is not present… now imagine that we have 100 API conections! The same headaches! And these tasks must be carried out periodically so that our platform be clean of trash and unnecessary resources.
PowerShell scripts to the help
To solve these needs and questions in a simple, quick and reliable way the only option you have is to use PowerShell scripts that you can use on demand from your machine or put it running periodically on an Automation account or Azure Function.
Taking for example the question: Do I have unused connections? or How to find Orphaned Azure API Connections?
In the past, I develop a PowerShell script based on a sample created by Mike Stephenson, that looks at all of the API Connections in your resource group, or in all your resource groups, and then inspect every Logic App in your resource group to check if the API Connections are being used or not. This script will help you to identify orphaned API Connections quickly. As a result it will automatically add a Deprecated tag on all the API Connectors with the value True or False. The script will:
- List all the available API Connections and which Resource Group it belongs.
- List all the Logic Apps, which Resource Group it belongs and all the API Connections association.
- At the end will present a list of all Orphaned API Connections and which Resource Group it belongs.
You can find and download the PowerShell script Find Orphaned API Connectors in all Resource Groups from GitHub here: