Mastering Azure Cosmos Data Explorer for Efficient Data Handling

Author

Reads 723

Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.
Credit: pexels.com, Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.

Azure Cosmos Data Explorer is a powerful tool that allows you to query and analyze large amounts of data in real-time. It's designed to handle high-velocity data streams and provides a scalable and flexible way to manage data.

One of the key benefits of Azure Cosmos Data Explorer is its ability to handle high-throughput data streams, with some queries able to process over 100,000 documents per second. This makes it an ideal choice for applications that require real-time data analysis.

To get the most out of Azure Cosmos Data Explorer, it's essential to understand how to structure your data effectively. This includes using a consistent schema and taking advantage of indexing to improve query performance.

Getting Started

You can access the Data Explorer directly using your Azure subscription by navigating to https://cosmos.azure.com and signing in with your existing credentials.

To sign in, select Sign In and choose your Azure subscription and target account from the Select a Database Account menu.

Credit: youtube.com, Azure Cosmos DB Tutorial | Globally distributed NoSQL database

Once you're signed in, you can apply a saved filter to your data. To do this, open the collection you want to query, select Items, click Edit Filter, and apply a filter as you normally would.

If you're already comfortable with the Azure portal, you can navigate directly from the in-portal Data Explorer to the standalone Data Explorer.

To do this, sign in to the Azure portal, navigate to your existing Azure Cosmos DB account, and in the resource menu, select Data Explorer. Then, select the Open Full Screen menu option and choose Open in the Open Full Screen dialog.

Here's a step-by-step guide to accessing the Data Explorer from the Azure portal:

  1. Sign in to Azure portal.
  2. Navigate to your existing Azure Cosmos DB account.
  3. In the resource menu, select Data Explorer.
  4. Next, select the Open Full Screen menu option.
  5. In the Open Full Screen dialog, select Open.

Data Management

Data Management is a crucial aspect of working with Azure Cosmos DB.

With Azure Cosmos DB, you can store and manage large amounts of data across multiple regions. This allows for faster data access and reduced latency for users worldwide.

Credit: youtube.com, Azure Cosmos DB TV - What's New in Data Explorer: A Comprehensive Guide - Ep. 101

Data is automatically replicated across these regions, ensuring high availability and durability.

Azure Cosmos DB's data management capabilities also include automatic indexing, which ensures that your data is always queryable, even as it grows.

This means you can focus on building your application, without worrying about the underlying data management infrastructure.

Additionally, Azure Cosmos DB provides features like data partitioning, which allows you to scale your database horizontally, and data caching, which can improve query performance.

Provisioning Capacity

Provisioning capacity is a crucial aspect of Azure Cosmos DB. You can define capacity on both database and container levels, with the database level capacity applying to all containers within that database.

Capacity is measured in Request Units (RU) per second, where one RU doesn't represent a single request, but rather a calculation of the load a certain request will put on the database. For example, a read-by-id operation is less expensive than a document update.

Credit: youtube.com, What is a Request Unit? | Azure Cosmos DB Essentials Season 2

You can use the Azure portal's Data Explorer tool to see how many RU a certain request consumes. The 'Query Stats' section shows you the consumed RU and other query-related details.

To estimate the number of RU you need, you can use the RU calculator, which gives a good insight into what you can expect. However, a better way to determine your provisioned capacity is to execute a representative load test on your Cosmos DB instance.

You have two options for scaling: manual or auto scaling. Manual scaling gives you a fixed and predictable capacity and pricing, but you won't be prepared for unforeseen load. The minimum number of RU you need to specify is 400, but you can increase that value later on.

Auto scaling is a great feature that allows you to define a bandwidth of the necessary capacity. As long as the number of RU you ask from Cosmos DB is within that bandwidth, you'll pay for the consumed amount, not the reserved max capacity. There is a factor of 10 between the lower and upper bounds, with a minimum of 400 RU/s, so the minimum max RU to define for auto scaling is 4000 per second.

Here's a summary of the capacity limits:

  • Max 10k RU/s capacity per physical partition
  • Max 20 Gb data per physical partition

Query and Performance

Credit: youtube.com, Azure Cosmos DB Query Engine Performance Improvements​ - Episode 52

A point read in Azure Cosmos DB is about 8 times more efficient than a query, which means you can do with 8 times less capacity if you're able to use point reads instead of queries.

This can result in a serious cost reduction, as capacity is expensive. In fact, the price you pay for Cosmos DB is based on the storage and RU capacity you need.

To take advantage of point reads, make sure to choose a document ID that's easy to reconstruct when you need to access a document. This can be a unique value related to the data you store, such as a Customer Id or Order Id.

If you don't have such a key, you can use synthetic values to create a unique document ID. For example, you can use a string like customerid_orderid_country.

Here are some event types you can use to query and explore your data:

  • Account: AzureCosmosDbAccountSample, AzureCosmosDbAccount
  • Database: AzureCosmosDbDatabaseSample, AzureCosmosDbDatabase
  • Collection: AzureCosmosDbCollectionSample, AzureCosmosDbCollection

Access the Explorer

Credit: youtube.com, SQL Query Optimization - Tips for More Efficient Queries

You can access the Data Explorer directly using your Azure subscription, or from the Azure portal.

To access the Data Explorer directly, navigate to https://cosmos.azure.com and sign in with your existing credentials that have access to the Azure Cosmos DB account.

Select your Azure subscription and target account from the Select a Database Account menu.

Alternatively, you can access the Data Explorer from the Azure portal by signing in, navigating to your existing Azure Cosmos DB account, and selecting Data Explorer in the resource menu.

Once in the Data Explorer, you can open the collection you want to query and select Items to apply a saved filter.

Query vs Point Reads

Every document in Cosmos Db needs a unique document ID to be accessed efficiently. This document ID, along with the partition key, should be chosen in a way that makes it easy to reconstruct to retrieve a certain document.

A point read retrieves a document based on its document ID or partition key, which is a highly efficient operation. In fact, a point read is about 8 times more efficient than a query.

Credit: youtube.com, Point Reads vs. Queries in Azure Cosmos DB: Microsoft Exam DP-420

If you don't have a natural document ID, you can use synthetic values to create a unique string that can be reconstructed when needed. For example, customerid_orderid_country can be a unique document ID.

Using point reads instead of queries can lead to significant cost savings, as you can do with 8 times less capacity. This is especially important because capacity is expensive in Cosmos Db.

In the end, it all comes down to the number of RU you need, and using point reads can help you stay within your budget. RU = money, after all.

Change Query View

Changing your query view in Azure Cosmos DB Data Explorer is a breeze. You can toggle between horizontal and vertical views for the query and results panel by selecting the "Views" option in the command bar menu.

To save your preferences, click the gear icon in the top right corner of Data Explorer to access settings. From there, select "Default Query Results View" from the dropdown menu and choose either horizontal or vertical as your default view.

Here's a quick summary of the steps:

  1. Save your Query Window view preferences
  2. Select either horizontal or vertical as your default view
  3. Click Save to apply your settings

By following these simple steps, you can customize your query view to suit your needs and make your analysis more efficient.

Considerations

Credit: youtube.com, Tune Problematic SQL Queries To Improve Database Performance

When polling the change feed API, you may miss some intermediate document changes if the frequency of document changes is higher than the API polling frequency.

The change feed API only exposes the latest update of a document, which can lead to missed events if a document changes multiple times between API calls.

You can use a soft marker to mark a Cosmos DB document as deleted, but this requires adding a property to update events that indicate whether a document has been deleted.

If you need to know about deleted documents, you can configure your feed to use a soft marker and then filter them out in your queries using the where operator.

Here are some key considerations to keep in mind:

  • The change feed doesn't expose deletion events.
  • The change feed only exposes the latest update of a document.
  • Deleting and recreating a Cosmos DB container isn't supported.

If a document changes multiple times between API calls, the data connector may miss some intermediate document changes, but the latest state of each document is captured.

Monitoring and Security

Monitoring and Security is a crucial aspect of Azure Cosmos Data Explorer.

Credit: youtube.com, Azure Cosmos DB: autoscale, session state, monitoring, and more | Azure Friday

You can use Azure Monitor to track metrics such as the number of requests, data size, and capacity consumption.

This will give you a good overview of your Cosmos DB instances, but for more detailed information about the operations used by your code, you need to go to the metrics section and select "Total Requests" and split by "Operation".

This will show you exactly what kind of operations are executed against your Cosmos DB instance, helping you measure the impact of changes in your code.

Monitoring

Monitoring is essential to measure the effectiveness of your code changes. You can use Azure Monitor to track the number of requests, data size, and capacity consumption of your Cosmos Db instance.

Azure Monitor provides a nice overview of your Cosmos Db instances, but you may want to see more details about the operations used by your code. To do this, you need to go to the metrics section and select "Total Requests" and split by "Operation" to show exactly what kind of operations are executed against your Cosmos Db instance.

This will help you measure whether a change in your code leads to less queries and more point reads. It's also interesting to see how many requests are done by the feed read, which is an Azure Function with a Cosmos Db binding, handling the change feed.

Microsoft Entra Authentication

Credit: youtube.com, Microsoft Entra ID Beginner's Tutorial (Azure Active Directory)

Microsoft Entra Authentication is a powerful feature that enables role-based access control (RBAC) within the Azure Cosmos DB Data Explorer. This means you can control who can access and manage your data with precision.

You can enable Microsoft Entra-based authentication by following a few simple steps. Start in the Data Explorer for the target Azure Cosmos DB account, then select the Settings menu option. From there, configure whether you want to Enable Entra ID (RBAC) using one of three possible values.

Here are the three options you have:

Changing this setting to an option that uses key-based authentication could trigger a request to retrieve the primary key on behalf of the identity that is signed in. So, it's essential to choose the right option for your needs.

Customization and Configuration

You can customize your data views in Azure Cosmos DB Data Explorer by selecting specific columns that are most relevant to your analysis. This feature allows you to create additional columns to easily view your data.

Credit: youtube.com, Cosmos DB Private Endpoint Data Connection

To customize your data views, sign in to the Azure portal, navigate to your existing Azure Cosmos DB account, and select Data Explorer. From there, you can select the columns you want to display and save your settings.

The Custom Column Selector in Azure Cosmos DB Data Explorer allows you to easily view your data by selecting one or many properties from your document. You can also remove a custom column by clicking on the ellipsis menu on the top right of any Column and selecting Remove Column.

You can also sort your Column View ascending or descending, and reset your Column View by selecting Reset to return to the default view. Or you can Clear your Filter History, Columns, and Viewport settings by selecting the gear icon in the top right Data Explorer Global menu and selecting Clear History.

The default polling information for the Cosmos DB integration is a polling interval of 5 minutes, with a resolution of 1 minute or 5 minutes, which varies by metric.

Customize Your Views

Credit: youtube.com, Configuration vs Customization

You can customize your data views in Azure Cosmos DB Data Explorer to focus on relevant data. The Custom Column Selector allows you to select specific columns that are most relevant to your analysis.

To use the Custom Column Selector, you need to sign in to the Azure portal, navigate to your existing Azure Cosmos DB account, and select Data Explorer. From there, you can open the collection you want to query and select Items.

To add a custom column, click on the ellipsis menu on the top right of any Column, select Edit Column, and select the columns you want to display. You can also remove a custom column by clicking on the ellipsis menu and selecting Remove Column.

You can sort your column view by clicking on the column header and selecting ascending or descending. To reset your column view, click on the ellipsis menu and select Edit Column, then select Reset.

Credit: youtube.com, Customizing your Object Types ⚙️

Here's a quick rundown of the steps:

  • Sign in to Azure portal
  • Navigate to your Azure Cosmos DB account
  • Select Data Explorer
  • Open the collection you want to query
  • Select Items
  • Click on the ellipsis menu
  • Select Edit Column or Remove Column as needed

By customizing your data views, you can focus on the data that matters most to your analysis.

Configuration and Polling

When customizing your experience, you can change the polling frequency and filter data using configuration options.

The default polling information for the Cosmos DB integration is quite specific.

The polling interval is set to 5 minutes, which is a good balance between getting timely updates and not overwhelming your system.

For resolution, you can choose between 1 minute or 5 minutes, but it varies by metric.

To find out the resolution information for a specific metric, you can check Microsoft Azure's documentation about support metrics.

Here's a quick rundown of the default polling options:

  • Polling interval: 5 minutes
  • Resolution: 1 minute or 5 minutes, varies by metric

Troubleshooting and Help

If you're experiencing issues with Azure Cosmos DB, the troubleshooting process starts with checking the account status, which can be found in the Azure portal under the "Account" section. Make sure to verify that the account is enabled and the status is "Online".

Credit: youtube.com, How to troubleshoot key issues with your Azure Cosmos DB Resources | Azure Cosmos DB Conf 2023

Azure Cosmos DB provides a rich set of tools for debugging and troubleshooting, including the Azure Cosmos DB emulator, which allows you to test and debug your application locally. This emulator is available for download from the Microsoft website.

For more complex issues, you can use the Azure Cosmos DB support team, which offers 24/7 support for critical issues.

Known Issues

Browsing items that contain a UUID isn't supported in Data Explorer, which means you can't view individual items or queries that include these items. This limitation only affects viewing, not loading containers.

To view and manage items with UUIDs, you should stick with the tooling or SDKs you originally used to create them. This is because those tools are designed to handle these specific items.

If you're getting HTTP 401 errors, it's likely due to insufficient role-based access control permissions for your Microsoft Entra ID account. This can happen if your account has a custom role without the necessary permissions.

Custom roles must have the Microsoft.DocumentDB/databaseAccounts/listKeys/* action included to use the Data Explorer. Without this action, you won't be able to access the Data Explorer.

Important

Credit: youtube.com, The Most Important Thing about Troubleshooting

When using Azure Cosmos DB, it's essential to be aware of deprecated features.

Be sure to check the Azure Cosmos DB integration (deprecated) for information on deprecated events or metrics.

You should strongly consider migrating to the supported events and metrics in the official documentation.

To view metrics reported by the Cosmos DB integration, query the Entities below.

The metadata associated with each metric can be used to filter and facet the data being reported.

For detailed metric information, see the Azure supported metrics documentation.

Frequently Asked Questions

What is Azure Cosmos DB Explorer?

Azure Cosmos DB Explorer is a web-based interface for viewing and managing data in Azure Cosmos DB. It's a convenient tool for data management and exploration.

What is Azure Data Explorer?

Azure Data Explorer is a fast and fully managed data analytics service for real-time analysis on large volumes of data. It's ideal for applications, websites, IoT devices, and more that generate high volumes of streaming data.

Katrina Sanford

Writer

Katrina Sanford is a seasoned writer with a knack for crafting compelling content on a wide range of topics. Her expertise spans the realm of important issues, where she delves into thought-provoking subjects that resonate with readers. Her ability to distill complex concepts into engaging narratives has earned her a reputation as a versatile and reliable writer.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.