Below you will find pages that utilize the taxonomy term “Azurestorage”
January 9, 2020
Filtering Azure Table Data directly in the Azure Function Binding
Instead of filtering values from an Azure Storage Table, you can do it directly in the bindings. It might not be a solution for everything, but in the right place, it is fantastic. I was very surprised to see how little code was needed after this binding change:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function(context, req) { | |
context.res = { | |
body: context.bindings.inputTable | |
}; | |
}; |
For that to work, define the filter attribute in the bindings: “filter”: “(PartitionKey eq ‘{package}’)”
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"bindings": [ | |
{ | |
"authLevel": "anonymous", | |
"type": "httpTrigger", | |
"direction": "in", | |
"name": "req", | |
"methods": ["options", "get"] | |
}, | |
{ | |
"type": "http", | |
"direction": "out", | |
"name": "res" | |
}, | |
{ | |
"type": "table", | |
"name": "inputTable", | |
"tableName": "metadata", | |
"connection": "AzureWebJobsStorage", | |
"direction": "in", | |
"filter": "(PartitionKey eq '{package}')" | |
} | |
] | |
} |
To try it out, add a new row in a table defined in the bindings (“metadata” in my case):