jan*_*ikb 6 azure azure-logic-apps azure-rm-template
我正在尝试使用逻辑应用程序和(未经身份验证的)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": {
}
}
Run Code Online (Sandbox Code Playgroud)
执行ie运行时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": ""
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用以下资源来构建arm模板:
问题是逻辑应用程序内部的语法错误。以下是一个可行的解决方案。我还删除了 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.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": {
}
}
Run Code Online (Sandbox Code Playgroud)
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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
您需要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"
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2788 次 |
最近记录: |