ARM template Office 365 connection for logic apps

2019-02-19 07:30发布

问题:

I have a logic app that I am trying to automate through an ARM Template.

The logic app requires a connection to Office 365. Below I have the template for the connection generated from the automation pane of the Azure Portal.

When I run the script it fails - there is an authentication issue between the Azure subscription and the Office 365 subscription.

LinkedAuthorizationFailed

The client has permission to perform action 'Microsoft.Web/locations/managedApis/join/action' on scope ... however the current tenant 'curr-tenant-guid' is not authorized to access linked subscription 'linked-sub-guid' ...

I wont be able to create this trust to automate the provisioning, but I would like to create the connection as placeholder so that the logic app can be deployed and I can go back to the portal to authorise the connection. Is this possible? Are there any other alternatives?

 {
      "comments": "Office 365 user for file monitoring",
      "type": "Microsoft.Web/connections",
      "name": "MyOffice365User",
      "apiVersion": "2016-06-01",
      "location": "northeurope",
      "scale": null,
      "properties": {
        "displayName": "readuser@example.com",
        "customParameterValues": {},
        "api": {
          "id": "[concat('/subscriptions/a6720ff8-f7cb-4bc8-a542-e7868767686/providers/Microsoft.Web/locations/northeurope/managedApis/', 'MyOffice365User')]"
        }
      },
      "dependsOn": []
    }

回答1:

I found three post related to the same problem:

  • Deploying a logic app using ARM templates/powershell
  • Azure Logic Apps - ARM template to deploy filesystem API connection
  • How to set the connection string for a Service Bus Logic App action in an ARM template?

The problem is the same for all API Connection. Connection parameters to access the specific service are stored on Azure and when you try to export the ARM Template there is nothing regarding these specific parameters (which make sens as Azure will not expose your secret, password...).

The trick is to query Azure Resource Management API to return the parameters needed for any connection in a Logic App.

Just follow the instructions on this article:

  • Deploying in the Logic Apps Preview Refresh