This post was most recently updated on September 12th, 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!
Problem
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?
Reason
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 names of the resources – 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:
A-ha!
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 an 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 a “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?
Solution
Let’s take a look, step by step, at 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 detailed 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 not rocket surgery, but will take a while. - Redeploy
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!
References
- “Performing cleanup” – Excel is stuck with an old, conflicted file and will never recover. - November 12, 2024
- How to add multiple app URIs for your Entra app registration? - November 5, 2024
- How to access Environment Secrets with GitHub Actions? - October 29, 2024