Get a value from Azure Table Storage with Logic App

Viewed 4608

I am new to Logic Apps so bear with me. I am just trying to perform a simple lookup in an Azure Table Storage and get a value that I can store in a variable in a Logic App. Here is what my Table Storage looks like:

enter image description here

My RowKey is unique and will be my lookup value. So based on a RowKey value, I want to get the UTCOffset value and store it in a variable.

This is what I have tried so far:

enter image description here

I want to get the value returned "13.00" and just store it in a variable for further processing. Pretty simple I know, but I just can't get my head around it.

enter image description here

2 Answers

You just need to use the expression as below in your "Initialize variable" action: enter image description here The whole expression is:

body('Get_entities')?['value'][0]?['UTCOFFSET']

Please pay attention to the case UTCOFFSET, in your logic you may need to use UTCoffset.

And it seems you changed the name of "Get entities" action from "Get entities" to "Get entities-UTC", so you also need to modify its name in the expression, shown as below:

body('Get_entities-UTC')?['value'][0]?['UTCoffset']

Hope it helps~

Slightly late, but if you're only trying to find a single entity, you could use the "Get Entity" step, which will only return a single entity, reducing the need for array manipulation.

Note that in Table Storage, your unique id is the combination of the Partition and Row keys - in your example above: New Zealand and 01. You'll get better performance if you're able to pass the partition key in as well.

You can then use the "Parse JSON" step to define the schema of your records, and have the different fields available in subsequent steps without having to resort to a function:

Get Entity followed by Parse JSON

You can either use the "Use sample payload" link to generate the schema automatically, or use something like:

{
    "properties": {
        "PartitionKey": {
            "type": "string"
        },
        "RowKey": {
            "type": "string"
        },
        "Timestamp": {
            "type": "string"
        },
        "UTCOffset": {
            "type": "string" // or number
        },
        "odata.etag": {
            "type": "string"
        },
        "odata.metadata": {
            "type": "string"
        }
    },
    "type": "object"
}

Alternatively you can use the Parse JSON step to handle the array returned by the Get Entities step and have a strongly typed set of objects that Logic Apps will let you loop through.

Related