I've got a Logic App I am working with in Azure where I need to access a certain nested value from some JSON on an Http Trigger.
I need to access the threshold value (5) and the value of the second item in the dimensions array (accountscontacts-account-deleted) and display these dynamically through the Expression syntax in the Logic App editor but can't figure out where I am going wrong with my expression.
I'm trying to use this syntax to access the threshold value,
first('allOf')?['threshold']
and I'm attempting to use this expression to access the second dimension value,
last(first('allOf')?['dimensions'])?['value']
Neither of these seem to be working and I can't quite figure out where my Expression syntax is going wrong. It throws this error when I try to evaluate that the dimensions value logic (The threshold logic also fails with a similar error)
InvalidTemplate. Unable to process template language expressions in action 'Post_message' inputs at line '1' and column '1660': 'The template language expression 'last(first('allOf')?['dimensions'])?['value']' cannot be evaluated because property 'dimensions' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.
JSON Payload
{
"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"
}
}
}
Here is a snapshot of what the logic app looks like with the expression block (I guess I am also unsure if I am accessing the properties correctly here too),
Any idea how I can correctly access these properties dynamically using the expression syntax?