This post was most recently updated on May 18th, 2021.4 min read.
This article explains a quick and dirty fix when you get an error somewhat like “ApiNotFound” when you’re deploying an Azure Logic app from a template. This seems to be a very typical hurdle to run into when you’re trying to deploy a PowerAutomate Flow you’ve exported. I guess despite being built on the same platform, Flow developers took some liberties and the migration is not quite as painless as one would hope… :)
Anyway – on to the topic of the day!
This one was kind of frustrating. Very few results on Google, the wording in the message doesn’t really match what’s expected, the error message doesn’t give you a way forward and, the weirdest thing is the same stuff worked in Power Automate, which is built on Logic Apps…
There are definitely different levels of unexpectedness when encountering unexpected errors. If you’re able to realize what went wrong or the error message guides you forward, you probably won’t hate your life and your tools quite as much as when the error is useless and the reason is unclear.
This particular time the issue popped up when I was trying to deploy a new Azure Logic App based on a template exported from Power Automate. Yes – another one of these.
When we navigate to our resource group and select “Deployments”, we can see our recent, failed deployment. Clicking it open, we can see what failed:
Okay – so these connectors are borked. Why?
Well, this time the error is convoluted, but at least the deployment job details and associated errors in Azure are decent and should actually reveal the reason for the issue. Let’s see.
ApiNotFound doesn’t help us that much. Let’s take a look into the template and see if the resources names – the connectors that failed to deploy due to a “NotFound” status – actually reveals anything.
Looking at the template (no worries, I’m explaining how to open it further down in the article) I can find a dozen or so references to each connector name. And some of them are actually pretty revealing:
I had a Flow originally configured with a Buffer connector, and it was working just fine. But somehow it ended up in the Logic App template as “buffer_2” – and if you look at the way $connections are defined in the template above, buffer_2 is used as a identifier for fetching a managed API, e.g. a Microsoft-provided connector (as opposed to a custom connector).
And of course Logic Apps do not have “flowpush” connector. Apparently, almost nobody has ever even heard about it if you google for it. It’s the built-in connector for Flow mobile app push notifications – something my Flow relied on heavily, but that’s not available on Azure Logic Apps as is.
But what do we do to fix this?
Let’s take a look, step by step, on how to fix the connectors in your template!
Time needed: 30 minutes.
How to clean up your connectors when importing a template to Azure Logic Apps?
- Make note of the connectors causing issues
This is what you see on the details view of the failed deployment.
- Judge the appropriate action for each
This one is difficult and there’s no silver bullet. You need to figure out whether the connector is something you can fix by adjusting the name, or if it’s something you need to remove completely.
In my case – buffer_2 was clearly just named wrong, but flowpush is something that doesn’t exist on Logic Apps.
- Open the template
Now you’ll need to get a hold of the template JSON itself – you can get it by clicking “Redeploy” in the ribbon and then clicking “Edit template”.
While you CAN edit the template in the browser, I strongly suggest you copy-paste it to an actual text editor for modification, as you’ll have Undo/redo available and just overall a much nicer experience.
- Replace your misnamed connectors
So this step is a very manual one. You have hopefully already decided earlier what you want to do with each connector – now you need to apply those changes to your template.
Below, I’m showing what this looks like in Visual Studio Code when I was going through the instances of buffer_2 in my template.
For renaming (like “buffer_2” to “buffer”), you can just search & replace the whole file.
- Remove your non-existing connectors
For removing, you need to search for your connector and determine the appropriate node in JSON to remove.
I’m trying to be an equal-opportunity-offender, so since the last screenshot was in dark mode, here’s one in burn-your-eyes-bright-mode:
Essentially, since that JSON is for looping through results from a previous step and creating an email for each, I figured flowpush isn’t actually used for anything there. Probably some weird value-sharing logic in Flow messing up the template… So I just removed the “connection”-part, and had to reauthenticate the email connector later in Logic Apps Designer.
I had to go through all instances of “flowpush” and figure out what to remove – it’s no rocket surgery, but will take a while.
Now you need to retry the deployment – with any luck, you should be good!
- Fire up your Logic App Designer and fix what’s broken
You’ll probably have a few unauthenticated connectors. Fixing them is usually just a matter of clicking around.
And there we go!
- HttpContext.WebSockets.IsWebSocketRequest always null in .NET Core? - July 27, 2021
- Docker-compose fails on Windows with “Error while fetching server API version: (2, ‘CreateFile’, ‘The system cannot find the file specified.’)” - July 20, 2021
- Azure DevOps suddenly 404s for your project? Easy fix! - July 13, 2021