Resolving 401 “Forbidden” Error When Deploying Logic Apps ARM Template
Introduction
I would like to share an issue encountered during my recent deployment via Azure DevOps involving a Logic App that calls an Azure Function. During the deployment process, the Logic App consistently returned a “Forbidden” error message from the extensions API and how I went about resolving it.
2023–06–28T22:05:11.0787555Z ##[error]BadRequest: {"Code":"Unauthorized","Message":"Encountered an error (Forbidden) from extensions API.","Target":null,"Details":[{"Message":"Encountered an error (Forbidden) from extensions API."},{"Code":"Unauthorized"},{"ErrorEntity":{"Code":"Unauthorized","Message":"Encountered an error (Forbidden) from extensions API."}}],"Innererror":null}
Not very helpful, isn’t it? Additionally, the Azure Resource Group deployment logs presented the same error message as below:
The solution
After some Googling, I found out that the Logic App was calling a Function App that was currently stopped as we are currently running a Disaster Recovery (DR) test, so Function App is intentionally stopped to prevent unintended execution. Further research revealed that this behavior is by design, as outlined in a GitHub post (link: https://github.com/Azure/azure-functions-host/issues/5634).
The solution for this is to simply enable the Function App which the Logic App invokes, the deployment now went through successfully.
Hope this blog post sheds light on the perplexing error !