azure - 如何在 ARM 模板中使用 o365 连接器部署逻辑应用程序
问题描述
我正在尝试使用逻辑应用程序和(未经身份验证的)o365 连接部署 ARM 模板。这是我的模板:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"LogicAppName": "MyLogicApp"
},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[variables('LogicAppName')]",
"location": "[parameters('location')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"state": "Enabled",
"definition": {
"parameters": {
"$connections": {
"defaultValue": {
},
"type": "Object"
}
},
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"triggers": {
"manual": {
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {
"properties": {
},
"type": "object"
}
}
}
},
"actions": {
"Send_an_email_(V2)": {
"type": "ApiConnection",
"inputs": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"body": {
"Body": "<p>@{triggerBody()?['message']}</p>",
"Subject": "@triggerBody()?['subject']",
"To": "@triggerBody()?['to']"
},
"method": "post",
"path": "/v2/Mail"
}
}
}
},
"outputs": {
}
},
"parameters": {
"$connections": {
"value": {
"office365": {
"connectionId": "[resourceId('Microsoft.Web/connections', 'office365')]",
"connectionName": "office365",
"id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', 'office365')]"
]
},
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"name": "office365",
"properties": {
"api": {
"id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
},
"displayName": "office365",
"parameterValues": {
}
}
}
],
"outputs": {
}
}
执行即运行时az deployment group create --resource-group my-rgroup --template-file .\arm-template.json
工作流和 api 连接已创建。在逻辑应用代码视图(左面板)中,逻辑应用和连接属性看起来不错:
但是,当我打开设计器时,使用连接的步骤会给我一个“找不到连接器”错误:
当我单击“查看代码”(在设计器视图中)时,参数部分如下所示:
"parameters": {
"$connections": {
"value": {
"DCA9B054-C46B-4419-B0E9-FC142A864810": {
"connectionId": "",
"connectionName": "",
"id": ""
}
}
}
}
我使用以下资源来构建 arm 模板:
解决方案
问题是逻辑应用程序中的语法错误。以下是一个可行的解决方案。我还删除了 o365 连接的 parameterValues 部分。通过这种方式,可以重复部署 arm 模板,并使用用户帐户对连接进行一次身份验证。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"LogicAppName": "MyLogicApp"
},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[variables('LogicAppName')]",
"location": "[parameters('location')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"state": "Enabled",
"definition": {
"parameters": {
"$connections": {
"defaultValue": {
},
"type": "Object"
}
},
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.1.0.0",
"triggers": {
"manual": {
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {
"properties": {
},
"type": "object"
}
}
}
},
"actions": {
"Send_an_email_(V2)": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"body": {
"Body": "<p>hello world</p>",
"Subject": "test",
"To": "example@email.com"
},
"method": "post",
"path": "/v2/Mail"
}
}
},
"outputs": {
}
},
"parameters": {
"$connections": {
"value": {
"office365": {
"connectionId": "[resourceId('Microsoft.Web/connections', 'office365')]",
"connectionName": "office365",
"id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', 'office365')]"
]
},
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"name": "office365",
"properties": {
"api": {
"id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
},
"displayName": "office365"
}
}
],
"outputs": {
}
}
解决方案
inputs
您的“Send_an_email_(V2)”操作中有一个额外的内容。
"Send_an_email_(V2)": {
"type": "ApiConnection",
"inputs": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"body": {
"Body": "<p>@{triggerBody()?['message']}</p>",
"Subject": "@triggerBody()?['subject']",
"To": "@triggerBody()?['to']"
},
"method": "post",
"path": "/v2/Mail"
}
}
}
您需要inputs
从上面的代码中删除一个。
"Send_an_email_(V2)": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"body": {
"Body": "<p>@{triggerBody()?['message']}</p>",
"Subject": "@triggerBody()?['subject']",
"To": "@triggerBody()?['to']"
},
"method": "post",
"path": "/v2/Mail"
}
}
推荐阅读
- reactjs - 如何在 React useState 中访问元素的名称
- discord.js - Discord.js - 你如何获得频道的 ID?
- python - 来自 python 的 12 个月移动平均线
- python - 查找熊猫数据框中列之间的父子关系
- python - 如何将函数的字符串输出转换为输入或可运行的 shell 命令?
- javascript - 悬停效果仅在悬停在卡片上半部分时触发
- javascript - 想从关系树中删除关系,但我不知道我错在哪里
- android - 为什么flutter release apk会崩溃?
- r - cor.test 的奇怪问题——去掉结果中的 [[1]]、[[2]] 等
- vhdl - 为什么 vhdl 不能识别这个端口?