validation - ARM 模板无法设置 $connections
问题描述
我在 Visual Studio 项目中创建了一个与 slack 连接的 ARM 模板。当我连接到 Azure 门户中的 slack 时 - 一切都很好。我的 slack API 连接已获得授权并且可以正常工作。我的问题是部署和设置$connections
。
这是我的模板
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
<template-params>
},
"variables": {
"slack": "[concat(parameters('appPrefix'), '-slack-', parameters('environment'))]"
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"name": "[variables('slack')]",
"properties": {
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/slack')]"
},
"displayName": "Slack",
"parameterValues": {}
}
},
{
"name": "[parameters('logicAppName')]",
"type": "Microsoft.Logic/workflows",
"location": "[parameters('logicAppLocation')]",
"tags": {
"displayName": "LogicApp"
},
"apiVersion": "2016-06-01",
"properties": {
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Collecting_went_wrong": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['slack']['connectionId']"
}
},
"method": "post",
"path": "/chat.postMessage",
"queries": {
"channel": "<channel>",
"text": "<message>",
"username": "<user>"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"parameters": {
"$connections": {
"type": "object",
"defaultValue": {
}
}
},
"triggers": {
<trigger>
}
},
"parameters": {
"$connections": {
"value": {
"slack": {
"id": "[resourceId('Microsoft.Web/connections', variables('slack'))]",
"connectionId": "[resourceId('Microsoft.Web/connections', variables('slack'))]",
"connectionName": "slack"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', variables('slack'))]"
]
}
],
"outputs": {}
}
“有趣”的部分是在部署期间验证模板:
New-AzureRmResourceGroupDeployment : 17:08:51 - Resource Microsoft.Logic/workflows 'reporting-reminder-logic-app-dev'
failed with message '{
"error": {
"code": "ConnectionsParameterInvalid",
"message": "The provided API connection parameter 'slack' is missing the required property 'id'."
}
}'
我在这里真的很困惑。
我尝试将其部署为connection
并添加$connection
参数定义,部署通过了。然而,当我更改connection
为$connections
in 模板参数时,Azure 门户向我抛出了同样的验证错误。
知道我在这里做错了什么吗?
谢谢
解决方案
问题在于资源中的不同 ID -> Microsoft/Web.connections -> 属性 -> id 和 slack -> 连接。一旦此连接 ID 相同,验证通过。
所以它只是令人困惑的验证消息。
推荐阅读
- r - 安装 rgdal MacOS 时出错 - 仍然
- python - Django:表单不会添加到数据库
- wordpress - Webm 文件不被 wordpress 识别为视频文件(openlitespeed)
- c# - 从控制器排队的作业中将 Hangfire 日志记录到 Application Insights
- javascript - 在Draft.js装饰器中选择文本点击装饰器实现拖拽
- python - 计算矩阵的列均值 - 如何优化?
- asp.net - 数据表中的样式失真
- python - 如何通过按键随时跳出循环
- python - 当我尝试使用 pytube 时,出现错误,但我下载了这个模块。(Python,Pytube)
- javascript - 检查字符串是否是有效的 CSS 颜色表达式?