如何在 ARM 模板中使用 o365 连接器部署逻辑应用程序 [英] How to deploy Logic App with o365 Connector within ARM template
问题描述
我正在尝试使用逻辑应用程序和(未经身份验证的)o365 连接部署 ARM 模板.这是我的模板:
<代码>{"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion": "1.0.0.0",参数": {地点": {类型":字符串","defaultValue": "[resourceGroup().location]",元数据":{"description": "所有资源的位置."}}},变量":{"LogicAppName": "MyLogicApp"},资源": [{"type": "Microsoft.Logic/workflows","apiVersion": "2017-07-01","name": "[变量('LogicAppName')]","location": "[参数('location')]",身份": {类型":系统分配"},特性": {"state": "已启用",定义": {参数": {$ 连接":{默认值": {},类型":对象"}},"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#","contentVersion": "1.0.0.0",触发器":{手动的": {"type": "请求","种类": "Http",输入":{架构":{特性": {},类型":对象"}}}},行动":{发送_an_email_(V2)":{"type": "ApiConnection",输入":{输入":{主持人": {联系": {"name": "@parameters('$connections')['office365']['connectionId']"}},身体": {"正文": "<p>@{triggerBody()?['message']}</p>","主题": "@triggerBody()?['主题']","To": "@triggerBody()?['to']"},"方法": "发布","path": "/v2/Mail"}}}},输出":{}},参数": {$ 连接":{价值": {office365":{"connectionId": "[resourceId('Microsoft.Web/connections', 'office365')]","connectionName": "office365","id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"}}}}},取决于": ["[resourceId('Microsoft.Web/connections', 'office365')]"]},{"type": "Microsoft.Web/connections","apiVersion": "2016-06-01","location": "[resourceGroup().location]","name": "office365",特性": {API":{"id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"},"displayName": "office365",参数值":{}}}],输出":{}}
执行时,即运行 az deployment group create --resource-group my-rgroup --template-file .\arm-template.json
工作流和api连接已创建.在逻辑应用代码视图(左面板)中,逻辑应用和连接属性看起来不错:
但是,当我打开 designer 时,使用连接的步骤会给我一个找不到连接器"错误:
当我单击查看代码"(在设计器视图中)时,参数部分如下所示:
"参数": {$ 连接":{价值": {DCA9B054-C46B-4419-B0E9-FC142A864810":{"connectionId": "",连接名称":",ID": ""}}}}
我使用以下资源来构建 arm 模板:
Im trying to deploy an ARM template with a logic app and an (unauthenticated) o365 connection. This is my template:
{ "$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": { } }
When executing i.e. running
az deployment group create --resource-group my-rgroup --template-file .\arm-template.json
The workflow and api connection are created. In the Logic app code view (left panel) the logic app and connection properties look fine:
However when I open the designer the step using the connection gives me an "Connector not found" error:
And when I click "view code" (in the designer view) the parameters section looks like this:
"parameters": { "$connections": { "value": { "DCA9B054-C46B-4419-B0E9-FC142A864810": { "connectionId": "", "connectionName": "", "id": "" } } } }
I used following resources to build the arm template:
Solution
The problem was a wrong syntax inside the logic app. Following is a working solution. I also removed the parameterValues section of the o365 connection. In this way the arm template can be deployed repeatedly and authenticate the connection once with a user account.
{ "$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": { } }
解决方案There is an extra
inputs
in your "Send_an_email_(V2)" action."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" } } }
You need to remove one
inputs
from the code above."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" } }
After deploy it, we can get the result which expected.
这篇关于如何在 ARM 模板中使用 o365 连接器部署逻辑应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!