API Connection returns 400 "Bad Request" when Logic App and Connection was created in VS Code
See original GitHub issueDear all,
I was trying to create a Logic App (Standard) that simply sends an email via SMTP API Connection when the Logic App is called via Http webhook.
Since the scenario we are working in demands the use of Terraform IaC deployment, I created and Deployed my Logic App in a Terraform configuration. Afterwards, I created a Logic App (Standard) project in Visual Studio code and created a workflow, including the API Connection to my smtp test server. After deploying the project to my Logic App (Standard) resource via VSCode, I triggered the workflow and got a 400 “Bad request” when the SMTP Send Email action tried to call the API Connection.
{ "status": 400, "source": "https://logic-germanywestcentral-001.token.azure-apihub.net:443/tokens/logic-apis-germanywestcentral/8af2fb4fc6724ebc/smtp/a09a483c3c************************/exchange", "message": "Error from token exchange: Invalid Authorization header. Authorization header is expected in the form 'Bearer token' or 'Key token'." }
When I created the Logic App (Standard) in the Azure Portal (same subscription, same storage account, same App Service Plan), the connection works just fine.
An ARM template export shows a difference between the resource deployed by Terraform and Logic App project in VS Code (Left side of the images) and the resource I created in the Azure Portal (right side), although the portal view shows no difference.
Is there any special way of handling the workflows/connections if they are deployed with VS Code?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12
Top GitHub Comments
Thanks @jjdeventer ! yesterday also had the same issue with service bus and now this helped.
Hi guys,
I had the same problem. What i did was the following:
First from Visual Studio add the Action and go through the Authorization flow (in my case i am using the Outlook - Send E-mail from shared mailbox action). Result of this step is the API connection being created in the resource group you selected when adding an Azure action. Under the hood, also two files are being modified: connections.json and local.settings Important part here is the parameter, that is pointing to @appsetting office365-connectionKey. That key is actually added to another file: the local.settings file This is the key that is needed during runtime.
When you now deploy the Logic App to your app service plan, that value is not being added to your configuration. You have to do this manually in the Configuration section of the Logic App (in this example in the Azure Portal UI). Add a new Application Setting and name it exactly the same as the @appsetting, in my case office365-connectionKey. The value is the key from the local.settings file mentioned earlier. Don’t forget to save! This should do the trick. Now during runtime, the Logic App will fetch the key from the configuration and pass it to the API connection. Hope this helps!
Kind regards,
Jeroen