'Azure Storage Table complex query
I am trying to query Azure Table which has column property such as Azure Resource Name
, Blackoutperiodstartdate
, Blackoutperiodenddate
having Partition Key set to resourceId of the respective Azure Resource Name, however I am getting the following error:
azure.TableQuery.CombineFilters is not a constructor
while executing the below code using Azure Functions(HttptriggerJavascript)
var pkFilter = new azure.TableQuery().where('PartitionKey eq ?', 'coewebapptestid');
var resourceFilter = new azure.TableQuery().where('resourcename eq ?', 'coewebapptest');
var combinedFilter = new azure.TableQuery.CombineFilters(pkFilter, TableOperators.And, resourceFilter);
var tablequery = new azure.TableQuery().where(combinedFilter);
tableService.queryEntities('blackoutperiodtable', tablequery, null, function(error, result){
if(!error){
// Entity available in serverEntity variable
}
I am looking out to use multiple 'where' or 'combine filter' to basically query the Partition key and then find the associated resource name property value along with start date & end date values from the Azure Table as an output of my table query.
Solution 1:[1]
If you look at the documentation for combineFilters
, you will notice that it is a static
method thus you can't really create an instance of this.
Try something like this:
var combinedFilter = azure.TableQuery.CombineFilters(pkFilter, TableOperators.And, resourceFilter);
Solution 2:[2]
There is a simple workaround to your query. I recently took advantage of Cerebrata where we can select the specific Azure Storage attribute to create a query, define the operator (=, >, <, not equal), specify the name & value based on attribute name & value (To define and query the partition key), segment the attribute type (String or Date/Time) followed by logical connectors (And/Or).
Also, the tools help us to choose from a set of predefined dates including Start Date and End Date, and the tool will output the value from the Azure table in a properly formatted way.
Disclaimer: It’s purely based on my experience
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gaurav Mantri |
Solution 2 | Balasubramaniam |