【发布时间】:2019-10-26 09:49:21
【问题描述】:
我有一个在 Azure 中使用的逻辑应用程序,我需要从 Http 触发器上的某个 JSON 访问某个嵌套值。
我需要访问阈值 (5) 和维度数组中第二项的值 (accountscontacts-account-deleted) 并通过逻辑应用编辑器中的表达式语法动态显示这些但无法弄清楚我的表达哪里出了问题。
我正在尝试使用此语法来访问阈值,
first('allOf')?['threshold']
我正在尝试使用此表达式来访问第二维值,
last(first('allOf')?['dimensions'])?['value']
这些似乎都不起作用,我无法弄清楚我的表达式语法哪里出错了。当我尝试评估维度值逻辑时,它会引发此错误(阈值逻辑也因类似错误而失败)
无效的模板。无法在“1”行和“1660”列的操作“Post_message”输入中处理模板语言表达式:“模板语言表达式“last(first('allOf')?['dimensions'])?['value'] ' 无法评估,因为无法选择属性 'dimensions'。 “字符串”类型的值不支持属性选择。请参阅https://aka.ms/logicexpressions 了解使用详情。'。
JSON 负载
{
"schemaId": "AzureMonitorMetricAlert",
"data": {
"version": "2.0",
"properties": null,
"status": "Deactivated",
"context": {
"timestamp": "2019-06-11T21:26:20.5035755Z",
"id": "/URLTEXT/",
"name": "FBIS Event Bus DLQ Threshold Notifier",
"description": "",
"conditionType": "SingleResourceMultipleMetricCriteria",
"severity": "3",
"condition": {
"windowSize": "PT5M",
"allOf": [
{
"metricName": "DeadletteredMessages",
"metricNamespace": "Microsoft.ServiceBus/namespaces",
"operator": "GreaterThan",
"threshold": "5",
"timeAggregation": "Average",
"dimensions": [
{
"name": "ResourceId",
"value": "123456:fbis-event-bus"
},
{
"name": "EntityName",
"value": "accountscontacts-account-deleted"
}
],
"metricValue": 4
}
]
},
"subscriptionId": "1234",
"resourceGroupName": "SharedResources",
"resourceName": "FBIS-Event-Bus",
"resourceType": "Microsoft.ServiceBus/namespaces",
"resourceId": "/URLTEXT/",
"portalLink": "PORTALLINK"
}
}
}
这是一个带有表达式块的逻辑应用程序的快照(我想我也不确定我是否也在此处正确访问属性),
知道如何使用表达式语法正确地动态访问这些属性吗?
【问题讨论】:
标签: json azure triggers azure-logic-apps