Book a Demo Free Trial

Managing Azure Cosmos DB and Storage Table Queries

Arvind Narendrakumar

Jul 16, 2021

Category: Azure Cosmos DB, Azure Storage

In this post, we will talk about how Cerebrata can be used for efficiently querying Azure Cosmos DB Containers and Storage Account Tables. Querying is a great way to access desired data efficiently and Cerebrata provides certain features that makes querying your Cosmos DB and Storage Table resources easier.

Creating Query in Cerebrata 

Cerebrata provides different methods and functionalities to create a query. For Azure Storage Tables you can write your own query to fetch the documents if you are familiar with the ODATA querying syntax. You can write your own query by specifying the query in the textbox that appears inside the application when the storage account table is opened.

Graphical user interface, application

Description automatically generated

There is another option to create a new query by navigating to manage queries option and selecting new query option.

Graphical user interface, text, application

Description automatically generated

Query Builder 

The Query Builder is a very powerful functionality in the application. Using this functionality, you can create queries using an easy-to-use user interface. This becomes really useful if you are not familiar with ODATA querying syntax supported by Azure Storage Tables. Cerebrata provides all the necessary options to create a query, you can find the attribute names, the available data types, Comparison operators and the operators for join queries will be available in a dropdown box where you can simply choose the operations and specify the value for the attributes to fetch the documents. You can create it by selecting query builder option > New Condition >Specify the query attributes > Save the query.

Graphical user interface, application

Description automatically generated

Save Query 

Assuming you have a query that you use on a regular basis. Writing this query everytime you need to execute it is quite unproductive. Cerebrata allows you to save your queries inside the application so that they are available to you when you need them. To save a query, you can simply write the query and click save option and give a friendly name for easy identification and save the query.

Graphical user interface, text

Description automatically generated

If you want to make a copy of an existing query, you can use “Save As” option to modify and create a copy.

A screenshot of a computer

Description automatically generated

Default Query

From your saved queries, let’s assume that there’s a query that you always execute. You can mark that query as “Default Query”. What this will do is whenever you open up the table or container, the default query specified for that table or container will be pre-selected and all you have to do is execute that query. A simple yet elegant way to get to the desired data even faster. 

You can mark a query as “Default Query” either when saving the query or through “Manage Queries” functionality. 

Shared Queries 

So far, the queries we have talked about are only available in the containers or tables where they are created. What if you have to share that query across many containers and tables respectively. That’s where “Shared Queries” come into play. When you mark a query as a shared query, it will be available in all containers and/or tables. 

Creating a shared query is same as creating any other query. All you need to do is mark that query as a shared query when you’re saving that query. The shared queries functionality is currently supported only for the following Azure resources: 

  • Cosmos DB SQL API 
  • Storage Account Tables 

When you see the queries listed in the application, all shared queries will be prefixed with “[shared]” so that you can easily identify if a query is a shared query or is a local query.

Graphical user interface, application

Description automatically generated
A picture containing text, screenshot, indoor

Description automatically generated

Manage Queries 

As the name suggests, this functionality provides a convenient way for you to manage the queries you have created in the application. This functionality provides options for creating a new query and updating the existing query and also for deleting the queries and the important feature of importing and exporting the queries is possible with this option.

A picture containing text, screenshot, indoor

Description automatically generated

Export and Import Queries 

The created queries will be saved locally so if the same queries are required to be used in another storage tables then you need to repeatedly specify the same query manually in other tables. To make this process easier, Cerebrata provides the import and export queries functionality where the saved queries in one storage table can be exported in a JSON file to your local file explorer. You can do this operation by opening the manage queries option > select export queries option > choose the local file location to export the queries.

Graphical user interface, application

Description automatically generated
Graphical user interface, application

Description automatically generated

You can import the exported query file to any other storage tables irrespective of their residing subscriptions. To import the queries, you have to open the storage account table where the queries need to be imported and select manage queries option and select import queries option where Cerebrata opens your local file explorer so that you can select the saved query file and select open option. You can see the queries automatically gets imported into the storage account table. You can save the queries and can start querying the documents.

Graphical user interface, application, Word

Description automatically generated
Graphical user interface, application

Description automatically generated

Summary

In this blog, we saw how easy it is to manage your Azure Cosmos DB and Storage Table Queries using Cerebrata.

Cerebrata Cerulean enables you to manage your Azure Cosmos DB accounts (SQL API, Gremlin API and Table API), Service Bus Namespaces, Cognitive Search Service accounts, Redis Cache accounts, and much more. It is also cross-platform so that you can manage your Azure resources from a platform of your choice – Windows, Mac, or Linux.

Please visit https://www.cerebrata.com to learn more.