用于逻辑应用程序的 ARM 模板 Office 365 连接

ARM template Office 365 connection for logic apps

我有一个逻辑应用程序,我正在尝试通过 ARM 模板实现自动化。

逻辑应用需要连接到 Office 365。下面我有从 Azure 门户的自动化窗格生成的连接模板。

当我 运行 脚本失败时 - Azure 订阅和 Office 365 订阅之间存在身份验证问题。

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' ...

我无法创建此信任以自动进行配置,但我想将连接创建为占位符,以便可以部署逻辑应用程序并且我可以返回门户以授权连接。这可能吗?还有其他选择吗?

 {
      "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": []
    }

我发现三个 post 与同一问题相关:

  • Azure Logic Apps - ARM template to deploy filesystem API connection

所有 API 连接的问题都是一样的。 用于访问特定服务的连接参数存储在 Azure 上,当您尝试导出 ARM 模板时,没有任何关于这些特定参数的信息(这很有意义,因为 Azure 不会公开您的秘密、密码...)。

诀窍是查询 Azure 资源管理 API 以 return 逻辑应用程序中任何连接所需的参数。

只需按照本文中的说明操作即可:

使用下面的link安装有助于设计工作流的逻辑应用工具 https://marketplace.visualstudio.com/items?itemName=VinaySinghMSFT.AzureLogicAppsToolsforVisualStudio-18551

完成后,您可以创建 Office 365 连接器,当您打开 ARM 模板时,您可以在 ARM 模板中看到 o365 组件。 我的模板看起来像:-

{
  "type": "MICROSOFT.WEB/CONNECTIONS",
  "apiVersion": "2016-06-01",
  "name": "[parameters('office365_1_Connection_Name')]",
  "location": "[parameters('location')]",
  "properties": {
    "api": {
      "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('location'), '/managedApis/', 'office365')]"
    },
    "displayName": "[parameters('office36`enter code here`5_1_Connection_DisplayName')]"
  }
}

和内部工作流程

"triggers": {
            "When_a_new_event_is_created_(V2)": {
              "type": "ApiConnection",
              "inputs": {
                "host": {
                  "connection": {
                    "name": "@parameters('$connections')['office365']['connectionId']"
                  }
                },
                "method": "get",
                "path": "/datasets/calendars/v2/tables/@{encodeURIComponent(encodeURIComponent('AAMkNbPwESLK3F8s5n1Q3BwAhXXXXXXXXXXXXXXXXXXXXXXXXXXX'))}/onnewitems"
              },
              "recurrence": {
                "frequency": "Minute",
                "interval": 1
              },
              "splitOn": "@triggerBody()?['value']"
            }
          }

============================================= =================== 以及工作流的参数

"parameters": {
          "$connections": {
            "value": {
              "office365": {
                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('location'), '/managedApis/', 'office365')]",
                "connectionId": "[resourceId('Microsoft.Web/connections', parameters('office365_1_Connection_Name'))]",
                "connectionName": "[parameters('office365_1_Connection_Name')]"
              }

============================================= ===================