在我的档案中
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 的“声明”。
在里面
“参数”: {}
区域(下面的第 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'."
}
}
当我检查门户时,会生成以下错误:
无效的模板。无法在“1”行和“1232”列的“Read_And_Use_Parameter_Value_Simple_Response”输入操作中处理模板语言表达式:“找不到工作流参数“MyFirstNewParameter”。
做什么?
如何在 Logic App 中“读取”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/
文章的第一段如下,以防网址将来停止工作(如果它被移动,可能是互联网搜索)
逻辑应用程序参数与 ARM 参数我得到了一个问题,即 ARM 模板参数和逻辑应用程序参数之间有什么区别,以及何时应该使用这些参数,所以这就是我将在这篇文章中尝试解释的内容。第一个 ARM 模板参数与 ARM 模板一起使用,并且在将基于 ARM 的资源部署到 Azure 时使用 ARM 模板,而逻辑应用程序是通过 ARM 模板部署的资源。Logic App 背后的工作流定义语言与 ARM 模板非常相似,因此一开始很难看出差异。
作者:马蒂亚斯·洛格德伯格