What's the solution for deploying an Azure Logic App with Gmail API integration using ARM templates?

I’m trying to set up a Logic App in Azure that connects to Gmail. I’ve got an ARM template, but when I try to deploy it, I keep getting an error. The message says something about the Gmail connector not being valid and needing to be re-authorized.

Here’s a simplified version of what I’m working with:

{
  "resources": [
    {
      "type": "Microsoft.Logic/workflows",
      "name": "email-sender",
      "properties": {
        "definition": {
          "actions": {
            "SendEmail": {
              "type": "ApiConnection",
              "inputs": {
                "host": {
                  "connection": {
                    "name": "@parameters('$connections')['gmail']['connectionId']"
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "type": "Microsoft.Web/connections",
      "name": "gmail-connection",
      "properties": {
        "api": {
          "id": "[variables('gmailApiId')]"
        }
      }
    }
  ]
}

I’m deploying this using a PowerShell script. Any ideas on how to fix the authorization issue? Thanks!

hey, i’ve had this prob before. deploy the logic app first iter without the gmail connection, then auth the connector in azure portal. update your arm template and redeploy. it works, though it can be a pain.

I’ve encountered similar issues when deploying Logic Apps with API connections via ARM templates. The problem you’re facing is likely due to the OAuth nature of the Gmail API connection.

Here’s what worked for me:

  1. Deploy the ARM template without the Gmail connection first.
  2. Manually authorize the Gmail connector in the Azure portal.
  3. Use Azure PowerShell to retrieve the connection details.
  4. Update your ARM template with the connection information.
  5. Redeploy the template with the updated connection.

The key is to separate the initial deployment from the connection authorization. Once you’ve manually authorized the connection, you can retrieve its details and incorporate them into your template for future deployments.

This approach has been reliable for me across various OAuth-based connectors, not just Gmail. It adds an extra step to the process, but it ensures that your Logic App deploys successfully with a valid, authorized connection.

I’ve dealt with this issue before. The problem lies in the OAuth process for the Gmail API. ARM templates can’t handle the interactive authentication required.

Here’s a workaround that’s worked for me:

First, deploy your Logic App without the Gmail connection. Then, go to the Azure portal and manually set up the Gmail connector. Once that’s done, you can use Azure CLI or PowerShell to fetch the connection details.

With those details in hand, update your ARM template to include the authorized connection. Then you can redeploy, and it should work smoothly.

It’s not ideal, but it gets the job done. Microsoft really needs to improve this process for OAuth-based connectors in ARM deployments.