在我的文件中
LogicApp.parameters.json
我已经声明了名为 MyFirstNewParameter 的额外参数
完整的文件内容如下
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"value": "MyFirstLogicAppOne"
},
"servicebus_1_connectionString": {
"value": "Endpoint=sb://notForYouToSee"
},
"MyFirstNewParameter": {
"value": "abc123"
}
}
}
在我的 LogicApp.json 文件中,我添加了 MyFirstNewParameter 的“声明”。
在
"parameters": {}
区域(下面的第 4 行是该部分开始的地方)
我还添加了一个简单的响应,尝试读取参数值并将其发送回响应。 (名为“Read_And_Use_Parameter_Value_Simple_Response”的所有事物)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"type": "string",
"minLength": 1,
"maxLength": 80,
"metadata": {
"description": "Name of the Logic App."
}
},
"logicAppLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"allowedValues": [
"eastasia",
"southeastasia",
"centralus",
"eastus",
"eastus2",
"westus",
"northcentralus",
"southcentralus",
"northeurope",
"westeurope",
"japanwest",
"japaneast",
"brazilsouth",
"australiaeast",
"australiasoutheast",
"southindia",
"centralindia",
"westindia",
"canadacentral",
"canadaeast",
"uksouth",
"ukwest",
"westcentralus",
"westus2",
"[resourceGroup().location]"
],
"metadata": {
"description": "Location of the Logic App."
}
},
"MyFirstNewParameter": {
"type": "string",
"metadata": {
"description": "Name of the MyFirstNewParameter."
},
"defaultValue": "My1NewParameterDefaultValue"
}
},
"variables": {},
"resources": [
{
"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": {
"Read_And_Use_Parameter_Value_Simple_Response": {
"type": "Response",
"inputs": {
"statusCode": 200,
"body": "The parameter value is ***@{parameters('MyFirstNewParameter')}***"
},
"runAfter": {}
}
},
"parameters": {},
"triggers": {
"manual": {
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {}
}
}
},
"contentVersion": "1.0.0.0",
"outputs": {}
},
"parameters": {}
}
}
],
"outputs": {}
}
当我发送请求时,我在客户端收到以下内容:
{
"error": {
"code": "NoResponse",
"message": "The server did not received a response from an upstream server. Request tracking id '000000000000000000000'."
}
}
当我检查门户时,会生成以下错误:
无效模板。无法在“Read_And_Use_Parameter_Value_Simple_Response”输入中处理模板语言表达式,位于“1”行和“1232”列:“未找到工作流参数“MyFirstNewParameter”。”。
做什么?
如何“读取”逻辑应用程序中 LogicApp.parameters.json 中定义的参数?
感兴趣的网址
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#parameters
附加工作正确代码
接受的答案表明参数集存在歧义。
这是具有明确名称的更正工作答案。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"value": "MylogicAppName"
},
"MyFirstNewArmParameter": {
"value": "ValueIWantToSeeShowUp"
}
}
}
和
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"type": "string",
"minLength": 1,
"maxLength": 80,
"metadata": {
"description": "Name of the Logic App."
}
},
"logicAppLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"allowedValues": [
"eastasia",
"southeastasia",
"centralus",
"eastus",
"eastus2",
"westus",
"northcentralus",
"southcentralus",
"northeurope",
"westeurope",
"japanwest",
"japaneast",
"brazilsouth",
"australiaeast",
"australiasoutheast",
"southindia",
"centralindia",
"westindia",
"canadacentral",
"canadaeast",
"uksouth",
"ukwest",
"westcentralus",
"westus2",
"[resourceGroup().location]"
],
"metadata": {
"description": "Location of the Logic App."
}
},
"MyFirstNewArmParameter": {
"type": "string",
"metadata": {
"description": "Name of the MyFirstNewArmParameter."
},
"defaultValue": "My1NewArmParameterDefaultValue"
}
},
"variables": {
},
"resources": [{
"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": {
"Read_And_Use_Parameter_Value_Simple_Response": {
"type": "Response",
"inputs": {
"statusCode": 200,
"body": "The parameter value is ***@{parameters('MyFirstNewLogicAppParameter')}***"
},
"runAfter": {
}
}
},
"parameters": {
"MyFirstNewLogicAppParameter": {
"type": "string",
"defaultValue": "MyFirstNewLogicAppParameterDefaultValue"
}
},
"triggers": {
"manual": {
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {
}
}
}
},
"contentVersion": "1.0.0.0",
"outputs": {
}
},
"parameters": {
"MyFirstNewLogicAppParameter": {
"value": "[parameters('MyFirstNewArmParameter')]"
}
}
}
}],
"outputs": {
}
}
客户现在收到预期值
**参数值为 ***ValueIWantToSeeShowUp*****
我还找到了这篇文章:
http://blog.ibiz-solutions.se/integration/logic-apps-parameters-vs-arm-parameters/
文章的第一段如下,以防 url 将来停止工作(如果它被移动,可能会进行互联网搜索)
逻辑应用参数与 ARM 参数
我有一个问题,即 ARM 模板参数和逻辑应用程序参数之间有什么区别,以及何时应该使用它们,这就是我将在这篇文章中尝试解释的内容。
第一个 ARM 模板参数与 ARM 模板一起使用,ARM 模板用于将基于 ARM 的资源部署到 Azure 和逻辑应用程序是通过 ARM 模板部署的资源。 Logic App 背后的工作流定义语言与 ARM 模板非常相似,因此一开始很难看出区别。
添加一名作者
最佳答案
我知道这很困惑,但是有ARM模板参数和LogicApp参数。您刚刚声明了 ARM 参数,但错过了 LogicApp 参数。然后就可以将ARM参数传递给LogicApp参数。
试试这个:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"type": "string",
"minLength": 1,
"maxLength": 80,
"metadata": {
"description": "Name of the Logic App."
}
},
"logicAppLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"allowedValues": ["eastasia",
"southeastasia",
"centralus",
"eastus",
"eastus2",
"westus",
"northcentralus",
"southcentralus",
"northeurope",
"westeurope",
"japanwest",
"japaneast",
"brazilsouth",
"australiaeast",
"australiasoutheast",
"southindia",
"centralindia",
"westindia",
"canadacentral",
"canadaeast",
"uksouth",
"ukwest",
"westcentralus",
"westus2",
"[resourceGroup().location]"],
"metadata": {
"description": "Location of the Logic App."
}
},
"MyFirstNewParameter": {
"type": "string",
"metadata": {
"description": "Name of the MyFirstNewParameter."
},
"defaultValue": "My1NewParameterDefaultValue"
}
},
"variables": {
},
"resources": [{
"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": {
"Read_And_Use_Parameter_Value_Simple_Response": {
"type": "Response",
"inputs": {
"statusCode": 200,
"body": "The parameter value is ***@{parameters('MyFirstNewParameter')}***"
},
"runAfter": {
}
}
},
"parameters": {
"MyFirstNewParameter": {
"type": "string"
}
},
"triggers": {
"manual": {
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {
}
}
}
},
"contentVersion": "1.0.0.0",
"outputs": {
}
},
"parameters": {
"MyFirstNewParameter": {
"value": "[parameters('MyFirstNewParameter')]"
}
}
}
}],
"outputs": {
}
}
有关如何使用此链接中的 ARM 模板和参数为 CI/CD 准备逻辑应用程序的一些提示和技巧:https://platform.deloitte.com.au/articles/preparing-azure-logic-apps-for-cicd
HTH
关于metadata - 在逻辑应用程序中声明和使用 "parameter",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46082529/