我正在尝试根据workflow.json中的环境读取变量值。我在标准逻辑应用程序的应用程序设置中配置了一个值,即 env,并且该变量将具有基于环境的值 dev、stag 或 prod。我需要根据环境读取以下变量值,现在我正在使用
@{variables('_Uri')[@appsettings('env')]['G1']}
来执行此操作。由于某种原因,这不起作用。我是逻辑应用程序的新手,正在尝试学习,需要这方面的帮助。谢谢!
"inputs": {
"variables": [
{
"name": "_Uri",
"type": "object",
"value": {
"dev": {
"G1": "https://google.com",
"G2": "https://google1.com",
"G3": "https://google2.com",
"G4": "https://google3.com",
"G5": "https://google4.com",
"G6": "https://google5.com",
"G7": "https://google6.com",
"G8": "https://google7.com"
},
"stag": {
"G1": "https://google.com",
"G2": "https://google1.com",
"G3": "https://google2.com",
"G4": "https://google3.com",
"G5": "https://google4.com",
"G6": "https://google5.com",
"G7": "https://google6.com",
"G8": "https://google7.com"
},
"prod": {
"G1": "https://google.com",
"G2": "https://google1.com",
"G3": "https://google2.com",
"G4": "https://google3.com",
"G5": "https://google4.com",
"G6": "https://google5.com",
"G7": "https://google6.com",
"G8": "https://google7.com"
},
}
}
]
}
}```
我可以使用以下工作流程从标准逻辑应用程序中的应用程序设置中获取值。
使用
@{variables('_Uri')[appsetting('env')]['G1']}
表达。
代码 -
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@variables('_Uri')[appsetting('env')]['G1']",
"runAfter": {
"Set_variable": [
"SUCCEEDED"
]
},
"type": "Compose"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "_Uri",
"type": "object"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Set_variable": {
"inputs": {
"name": "_Uri",
"value": {
"dev": {
"G1": "https://google.com",
"G2": "https://google1.com",
"G3": "https://google2.com",
"G4": "https://google3.com",
"G5": "https://google4.com",
"G6": "https://google5.com",
"G7": "https://google6.com",
"G8": "https://google7.com"
},
"prod": {
"G1": "https://google.com",
"G2": "https://google1.com",
"G3": "https://google2.com",
"G4": "https://google3.com",
"G5": "https://google4.com",
"G6": "https://google5.com",
"G7": "https://google6.com",
"G8": "https://google7.com"
},
"stag": {
"G1": "https://google.com",
"G2": "https://google1.com",
"G3": "https://google2.com",
"G4": "https://google3.com",
"G5": "https://google4.com",
"G6": "https://google5.com",
"G7": "https://google6.com",
"G8": "https://google7.com"
}
}
},
"runAfter": {
"Initialize_variable": [
"SUCCEEDED"
]
},
"type": "SetVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"When_a_HTTP_request_is_received": {
"kind": "Http",
"type": "Request"
}
}
},
"kind": "Stateful"
}
输出 -