在我的档案中
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'."
}
}
检查门户网站时,会生成以下错误:
InvalidTemplate。无法在第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模板参数和Logic App参数之间的差异以及何时应该使用这些参数,这就是我将在本文中尝试解释的内容。 ARM模板的第一个参数与ARM模板一起使用,在将基于ARM的资源部署到Azure时使用ARM模板,而Logic App是通过ARM模板部署的资源。 Logic App的工作流定义语言与ARM模板非常相似,因此在开始时看到差异可能很棘手。
作者:MattiasLögdberg
答案 0 :(得分:10)
我知道这很令人困惑,但有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准备Logic Apps的一些提示和技巧:https://blog.mexia.com.au/preparing-azure-logic-apps-for-cicd
HTH