Microsoft Azure Cosmos DB (DP-420) Interview Questions

  1. Home
  2. Microsoft Azure Cosmos DB (DP-420) Interview Questions

Candidates for Microsoft Azure Cosmos DB (DP-420) test should have extensive expertise designing apps for Azure and working with the Azure Cosmos DB database. They should be able to create server-side objects with JavaScript using the Core (SQL) API and SDKs, write efficient queries and create appropriate index policies, provision and manage Azure resources, and write efficient queries and create appropriate index policies. They should be able to decode JSON, read C# or Java code, and execute PowerShell commands.

Advanced Interview Questions

How does Azure Cosmos DB differ from traditional relational databases?

Azure Cosmos DB is a globally distributed, multi-model, NoSQL database service, while traditional relational databases, like MySQL, SQL Server, and Oracle, are based on the relational model and use SQL as their query language.

Here are some key differences between Azure Cosmos DB and traditional relational databases:

  • Data Model: Cosmos DB supports multiple data models, including document, key-value, graph, and column-family, while traditional relational databases are based on the relational model. This allows Cosmos DB to be used for a wide variety of use cases, whereas relational databases are typically used for structured data and transactional workloads.
  • Scale and Performance: Cosmos DB is designed to be highly available and globally distributed, which allows for low-latency access to data no matter where users are located. Traditional relational databases can be scaled vertically by adding more resources to a single node, but it is harder to scale horizontally.
  • Consistency: Cosmos DB offers a variety of consistency levels that can be selected based on the needs of the application. Traditional relational databases have a single consistency model, which can make it more difficult to handle distributed data.
  • Indexing: Cosmos DB automatically indexes all data, regardless of the data model, which makes it easy to perform complex queries. Traditional relational databases require manual indexing and may not support all data models.
  • Query Language: Cosmos DB supports SQL, MongoDB, Gremlin and Cassandra API, while traditional relational databases support SQL as their query language.
  • Pricing: Cosmos DB charges by the hour and by the amount of throughput provisioned, while traditional relational databases charge based on the amount of storage and compute resources used.
  • Security: Cosmos DB has built-in security features such as encryption at rest, role-based access control, and network isolation, while traditional relational databases rely on external security solutions to protect the data.

Overall, Cosmos DB is a more flexible and scalable option for modern, cloud-based applications that require low-latency, globally distributed data.

What are the different consistency levels offered by Azure Cosmos DB?

Azure Cosmos DB offers several consistency levels that can be selected based on the needs of the application. The consistency level determines how up-to-date and accurate the data is across all replicas of a Cosmos DB container. The consistency levels offered by Cosmos DB are:

  1. Strong Consistency: This is the highest level of consistency, all read and write operations are guaranteed to return the most recent version of the data. This is the most restrictive consistency level, but it ensures that all reads will always return the most recent data, making it suitable for critical systems that require the most up-to-date information.
  2. Bounded Staleness: This consistency level allows for some data staleness, but guarantees that all reads will be no more than a certain number of operations (or time duration) behind the most recent version of the data. This is a good option for systems that require a balance between consistency and performance.
  3. Session: This consistency level guarantees that all read and write operations within a session will be consistent, but different sessions may see different versions of the data. This is a good option for systems that require consistency within a specific context or user session.
  4. Consistent Prefix: This consistency level guarantees that all read operations will return the most recent version of the data, but there may be some stale data. This is a good option for systems that require high availability and can tolerate some data staleness.
  5. Eventual: This is the lowest level of consistency, it guarantees that all read and write operations will eventually converge to a consistent state, but there is no guarantee of when that will happen. This is the most permissive consistency level, making it suitable for systems that can tolerate some data staleness in exchange for higher availability and lower latency.

Consistency level can be configured at the account, database or container level, and once set, it cannot be changed. It’s important to note that the consistency level affects the performance of the database, and it’s important to choose the right consistency level based on the specific needs of your application.

How can you achieve global distribution with Azure Cosmos DB?

Azure Cosmos DB allows you to globally distribute your data across multiple regions for low-latency, highly available access to your data. Here are the steps to achieve global distribution with Azure Cosmos DB:

  1. Create an Azure Cosmos DB account: To start using Azure Cosmos DB, you first need to create an account in the Azure portal.
  2. Choose a data model: Cosmos DB supports multiple data models, including document, key-value, graph, and column-family. Choose the data model that best fits your use case.
  3. Configure global distribution: Once you have created your Cosmos DB account, you can configure global distribution by selecting the “Enable Multiple Write Locations” option. You can then select the regions where you want your data to be replicated.
  4. Provision throughput: Cosmos DB uses a provisioned throughput model, where you specify the amount of throughput that you want to provision for your container. This can be done at the database or container level.
  5. Configure consistency level: Cosmos DB offers several consistency levels that can be selected based on the needs of the application. The consistency level determines how up-to-date and accurate the data is across all replicas of a Cosmos DB container.
  6. Use the Azure Cosmos DB SDKs: You can use the Azure Cosmos DB SDKs to interact with your data and take advantage of the global distribution feature. The SDKs are available for multiple programming languages, including .NET, Java, Python, and Node.js.
  7. Monitor and optimize: Use Azure Monitor to monitor the performance of your Cosmos DB account and optimize your configuration as needed.

With these steps, your data will be replicated to the chosen regions, providing low-latency access to your data and high availability. Your application can then use the SDKs to interact with the data, and the SDK will automatically route the requests to the nearest replica.

What are the different data models supported by Azure Cosmos DB?

Azure Cosmos DB supports several data models, including:

  1. Document: This is the most common data model used in Cosmos DB. It uses a schema-free JSON format, which makes it easy to store and query semi-structured and unstructured data. This data model is supported by the SQL API, MongoDB API, and Cassandra API.
  2. Key-Value: This data model is based on a key-value store, where each item is uniquely identified by a key and stored as a value. It is supported by the Table API.
  3. Graph: This data model is used to store and query graph data, such as social networks, recommendation systems, and hierarchical data. It is supported by the Gremlin API.
  4. Column-family: This data model is used to store and query wide-column data, such as time-series data and IoT data. It is supported by the Cassandra API.

Each data model has its own unique features and benefits, and the choice of data model depends on the specific needs of the application. Document data model is the most common, as it supports multiple APIs and is easy to work with. The key-value data model is useful for storing large amounts of data, the graph data model is used for storing and querying graph data, and the column-family data model is used for storing wide-column data.

How can you provision and scale throughput in Azure Cosmos DB?

The process to provision and scale throughput in Azure Cosmos DB involves the following steps:

  1. Create a Cosmos DB account in the Azure portal if you don’t already have one.
  2. Create a new container or database within the Cosmos DB account.
  3. Set the desired amount of request units (RUs) per second for the container or database. This can be done using the Azure Portal, Azure CLI, or Azure Cosmos DB SDKs.
  4. Monitor the usage of the container or database to ensure that it is performing well and that the provisioned throughput is sufficient.
  5. If necessary, scale up or down the throughput by increasing or decreasing the number of RUs per second. This can also be done using the Azure Portal, Azure CLI, or Azure Cosmos DB SDKs.
  6. Azure Cosmos DB also offers the automatic throughput provisioning feature that allows you to automatically adjust the throughput of your container or database based on usage patterns. This feature can be enabled or disabled for individual containers or databases.
  7. Repeat the monitoring process to ensure that the new provisioned throughput is sufficient.
  8. Repeat step 5 and 6 as necessary to ensure that the throughput is always sufficient to meet the needs of your application.

How does Azure Cosmos DB handle data indexing and querying?

Azure Cosmos DB is a globally distributed, multi-model database service that supports document, key-value, graph, and column-family data models. It automatically indexes all data without requiring any schema or index management. It uses a variety of indexing policies, such as range index, hash index, and spatial index, to support rich and efficient querying of the data. Additionally, it supports SQL (for document data model), Gremlin (for graph data model), and MongoDB (for document data model) as query languages.

Azure Cosmos DB uses a variety of indexing policies to support rich and efficient querying of data. The process is as follows:

  1. When data is inserted or updated in a Cosmos DB container, it is automatically indexed based on the specified indexing policy. This indexing policy can be customized to include or exclude specific properties of the data.
  2. The indexed data is then split and distributed across multiple partitions within the container. Each partition has a set of replicas for high availability and fault tolerance.
  3. When a query is made against the data, the query is first evaluated against the local index of the partition where the data resides. This is done to minimize the amount of data that needs to be scanned and reduce query latency.
  4. If the query cannot be fully satisfied by the local index, the query is then evaluated against the replica of the partition in a different region.
  5. The results of the query are then returned to the client.

Additionally, Azure Cosmos DB supports SQL, Gremlin, and MongoDB as query languages, and it also allows you to use the Azure Cosmos DB SDKs or the Azure Cosmos DB REST API to perform queries.

Can you explain the concept of partitioning in Azure Cosmos DB?

In Azure Cosmos DB, partitioning is the process of horizontally splitting a container’s data across multiple physical partitions. Each partition can have one or more replicas for high availability and fault tolerance.

When data is inserted into a container in Cosmos DB, a partition key is specified. The partition key is used to determine which partition the data should be stored in. All data with the same partition key will be stored in the same partition.

The partition key is chosen based on the access pattern of the data. It should be chosen such that it distributes the data evenly across partitions, to ensure good performance and scalability. A good partition key is one that has a high number of unique values and a well-distributed distribution of data.

Each partition has a maximum size and a maximum throughput. Once a partition reaches its maximum size or throughput, a new partition is created to store additional data. As data grows, the number of partitions in a container will also grow.

The partitioning strategy used by Cosmos DB ensures that the data is distributed evenly across partitions, which allows for efficient querying and good performance. Additionally, it allows Cosmos DB to scale horizontally, by adding or removing partitions as needed to meet the performance needs of the application.

How does Azure Cosmos DB handle data consistency and availability?

Azure Cosmos DB provides several options for data consistency and availability, which allows developers to choose the level that best meets the needs of their application.

  1. Consistency levels: Cosmos DB supports five different consistency levels: Strong, Bounded-Staleness, Session, Consistent Prefix, and Eventual. Each level provides a different trade-off between consistency and availability. The Strong consistency level provides the highest level of consistency, but the lowest level of availability. The Eventual consistency level provides the lowest level of consistency, but the highest level of availability.
  2. Replication: Cosmos DB automatically replicates data across multiple regions for high availability and fault tolerance. The number of replicas and the regions they are located in can be configured to meet the needs of the application.
  3. Automatic failover: In the event of a failure, Cosmos DB automatically fails over to a replica in a different region to ensure that the data remains available.
  4. Global distribution: Cosmos DB allows data to be globally distributed, which allows for low-latency access to data from anywhere in the world.
  5. Multi-homing: Cosmos DB supports multi-homing of the client requests to the Cosmos DB service endpoint, this feature allows the client to reach the nearest endpoint of the Cosmos DB service, reducing the latency.

By providing these options, Azure Cosmos DB allows developers to choose the level of consistency and availability that best meets the needs of their application, while also providing automatic replication and failover to ensure that the data remains available in the event of a failure.

What are some of the use cases of Azure Cosmos DB?

Azure Cosmos DB is a highly scalable and globally distributed database service that can be used for a variety of use cases, including:

  1. Mobile apps: Cosmos DB can be used to store and retrieve data for mobile apps, allowing for low-latency access to data from anywhere in the world.
  2. Internet of Things (IoT): Cosmos DB can be used to store and analyze large amounts of data from IoT devices, allowing for real-time insights and decision-making.
  3. Gaming: Cosmos DB can be used to store and retrieve data for online gaming, allowing for low-latency access to data and high-performance gaming.
  4. e-commerce: Cosmos DB can be used to store and retrieve data for e-commerce applications, allowing for low-latency access to data and high-performance shopping experiences.
  5. Social media: Cosmos DB can be used to store and retrieve data for social media applications, allowing for low-latency access to data and high-performance social experiences.
  6. Big Data: Cosmos DB can be used to store and analyze large amounts of data, allowing for real-time insights and decision-making.
  7. Real-time analytics: Cosmos DB can be used to store and analyze large amounts of data in real-time, allowing for real-time insights and decision-making.
  8. Document Management: Cosmos DB can be used as a document management system, allows you to store, search and retrieve large collections of documents.
  9. Content Management: Cosmos DB can be used to store, search and retrieve large collections of media, such as images, videos, and audio, allows you to manage and distribute them.

These are just a few examples of the many use cases that Cosmos DB can be used for. Its ability to store and retrieve large amounts of data quickly, its global distribution and low-latency access make it a great choice for many different types of applications and use cases.

How does Azure Cosmos DB handle and manage data backups?

Azure Cosmos DB automatically handles data backups, so you do not need to manually create and manage them. The service continuously takes snapshots of your data and stores them in Azure’s globally distributed data centers. These snapshots can be used to restore your data in case of accidental deletion or other issues. Additionally, you can configure the service to automatically create point-in-time backups, which allow you to restore your data to a specific point in time. You can also manually trigger a backup of your data at any time.

Azure Cosmos DB handles data backups through a process that involves the following steps:

  1. Continuous data snapshots: Cosmos DB automatically takes snapshots of your data at regular intervals and stores them in Azure’s globally distributed data centers. These snapshots can be used to restore your data in case of accidental deletion or other issues.
  2. Point-in-time backups: You can configure the service to automatically create point-in-time backups, which allow you to restore your data to a specific point in time.
  3. Manual backups: You can also manually trigger a backup of your data at any time by using the Azure Cosmos DB portal, Azure CLI, or Azure PowerShell.
  4. Data replication: Cosmos DB uses a multi-master replication model, which means that your data is replicated across multiple regions. This ensures that your data is highly available and can be quickly restored in case of an outage or other issue.
  5. Data retention: You can configure the retention period of your backups, which determines how long backups are kept before they are automatically deleted.
  6. Backup and restore: To restore your data from a backup, you can use the Azure Cosmos DB portal, Azure CLI, or Azure PowerShell. The process typically takes a few minutes to complete.
  7. Monitoring: Azure Cosmos DB provides monitoring and alerting capabilities, which enable you to keep track of your backups and quickly identify and resolve any issues.

How can you monitor and troubleshoot performance issues in Azure Cosmos DB?

There are several ways to monitor and troubleshoot performance issues in Azure Cosmos DB:

  1. Azure Monitor: Azure Cosmos DB integrates with Azure Monitor, which allows you to view and analyze metrics, such as request units (RUs) consumed, data size, and number of requests. You can also set up alerts to notify you of any performance issues.
  2. Azure Cosmos DB Metrics: You can also view and analyze metrics directly from the Azure Cosmos DB portal. This includes real-time metrics, such as request rate and storage size, as well as historical metrics, such as RU consumption and availability.
  3. Azure Cosmos DB Diagnostics: The service allows you to enable diagnostics logging, which captures detailed information about requests, including resource usage, response time, and errors. You can view and analyze these logs to understand performance issues and identify any bottlenecks.
  4. Azure Log Analytics: You can use Azure Log Analytics to analyze your Azure Cosmos DB logs, which enables you to troubleshoot performance issues and identify patterns that may indicate a problem.
  5. Azure Cosmos DB Analytics: You can use Azure Cosmos DB Analytics to query your data and run performance analysis on your data. This allows you to identify any slow running queries and optimize them.
  6. Azure Cosmos DB Performance tuning: Azure Cosmos DB also provides performance tuning options like indexing policy and partitioning to improve performance.
  7. Azure Cosmos DB Support: Azure Cosmos DB also provides options for support, you can raise a ticket for support from Azure portal if you are experiencing any performance issues, that you are unable to troubleshoot.

By using these tools and techniques, you can gain a deeper understanding of your performance issues and take the necessary steps to resolve them.

How can you integrate Azure Cosmos DB with other Azure services?

Azure Cosmos DB can be integrated with several other Azure services to create powerful and scalable solutions. Some examples of how you can integrate Azure Cosmos DB with other Azure services include:

  1. Azure Functions: You can use Azure Functions to perform serverless operations on data stored in Azure Cosmos DB. For example, you can create a function that is triggered by a change in your Cosmos DB data and performs an action such as sending an email or updating another system.
  2. Azure Stream Analytics: You can use Azure Stream Analytics to analyze streaming data from Azure Cosmos DB in real-time. This allows you to perform complex data processing and analytics on your Cosmos DB data as it is being added to the database.
  3. Azure Logic Apps: You can use Azure Logic Apps to create workflows that interact with data stored in Azure Cosmos DB. For example, you can create a logic app that retrieves data from Cosmos DB, processes it, and then stores it in another system.
  4. Azure Event Grid: You can use Azure Event Grid to trigger events in response to changes in your Azure Cosmos DB data. This allows you to create highly scalable and event-driven systems that respond to changes in your data in real-time.
  5. Azure Blob Storage: You can use Azure Blob storage to store and retrieve large files, such as images and videos, in conjunction with Azure Cosmos DB.
  6. Azure Data Factory: You can use Azure Data Factory to move and transform data between Cosmos DB and other Azure services. This allows you to create a pipeline for data integration and migration.
  7. Azure Databricks: You can use Azure Databricks to perform big data processing and analytics on data stored in Azure Cosmos DB.

These are just a few examples of how you can integrate Azure Cosmos DB with other Azure services. By combining the power of Cosmos DB with other Azure services, you can create highly scalable and resilient solutions that can handle large amounts of data and perform complex operations.

How does Azure Cosmos DB handle data security and compliance?

Azure Cosmos DB handles data security and compliance through a combination of features and services:

  1. Network isolation: Cosmos DB provides network isolation, so that your data is only accessible over a private network connection. This ensures that your data is not exposed to the public internet and can only be accessed by authorized users.
  2. Authentication and Authorization: Cosmos DB supports Azure Active Directory (AAD) authentication and Role-Based Access Control (RBAC) to control access to the data. This allows you to restrict access to your data to specific users and groups, and audit access to your data.
  3. Encryption: Cosmos DB supports encryption at rest and in transit to protect your data. Data at rest is encrypted using Azure Storage Service Encryption (SSE) and data in transit is encrypted using HTTPS.
  4. Compliance: Cosmos DB is compliant with a wide range of industry and government standards, including SOC 2, SOC 3, ISO 27001, HIPAA, and PCI-DSS.
  5. Auditing: Cosmos DB provides auditing capabilities that allow you to track and review user activity, such as who accessed your data and when, and what changes were made. This can help you comply with regulatory requirements and identify any security breaches.
  6. Backup and disaster recovery: Cosmos DB provides automatic backup and disaster recovery to ensure that your data is always available. Backups are regularly taken and stored in multiple regions, so that in case of a disaster, you can restore your data quickly.
  7. Azure Security Center: Azure Cosmos DB is integrated with Azure Security Center, which provides additional security features such as advanced threat protection, security assessments and recommendations, and security automation.

By using these features and services, Azure Cosmos DB helps you to secure your data and meet compliance requirements, allowing you to focus on your application and business.

Can you walk me through a sample application that uses Azure Cosmos DB?

An example of a simple application that uses Azure Cosmos DB:

  1. The application is a web-based to-do list app that allows users to create and manage their tasks.
  2. The application is built using a popular web development framework such as Ruby on Rails or Node.js.
  3. The application uses Azure Cosmos DB as the database to store and retrieve tasks.
  4. When a user creates a new task, the application sends a request to Azure Cosmos DB to create a new document in the tasks collection. The document contains the task title, description, and completion status.
  5. When a user retrieves their tasks, the application sends a request to Azure Cosmos DB to retrieve all the documents in the tasks collection that belong to that user.
  6. When a user updates or deletes a task, the application sends a request to Azure Cosmos DB to update or delete the corresponding document in the tasks collection.
  7. The application also uses Azure Cosmos DB’s built-in indexing and querying capabilities to allow users to filter and sort their tasks by various criteria.
  8. Finally, the application uses Azure Cosmos DB’s global distribution feature to ensure that the data is always available and responsive, even in the event of an outage.

This is just a high-level example, so you may need to add more details and functionality based on your requirements.

Basic Interview Questions

1.) What is Azure Cosmos DB?

  • Azure Cosmos DB is a high-performance NoSQL database solution for building modern apps of any size.
  • Candidates will learn how to leverage Azure Cosmos DB and its SQL API to solve this type of business challenge. You’ll also gain some insight into the database’s operation. This will assist you in determining whether Azure Cosmos DB’s SQL API is a good fit for your needs. You’ll be able to do things like:
  • Assess whether Azure Cosmos DB SQL API is the best database for your needs.
    Describe how the Azure Cosmos DB SQL API’s functionalities are suitable for current applications.

2.) What is a NoSQL database, and how does it work?

New types of databases are needed by developers to meet the needs of modern programs. NoSQL databases were created to answer these requirements and issues, including:

  • Large amounts of data
  • Data from a variety of sources and formats
  • Different sorts of data can be stored using dynamic data schemas.
  • Using real-time and/or high-velocity data
  • Rather than a formal definition, NoSQL databases are defined by the common qualities they share. These qualities include the following:

It’s a non-relational data store.
Designed to be scaled up.
There is no requirement for a certain schema.
Because NoSQL databases do not enforce relational constraints or place locks on data, writes are quick. They’re also frequently intended to scale horizontally via sharding or partitioning, ensuring good performance regardless of size.

While there are many different types of NoSQL data models, there are four main types of data models that are typically employed when modeling data in a NoSQL database:

  • Documents
  • Graph
  • Column-Family
  • Key-Value

3.) With the document data model, why use a NoSQL database?

Data is broken down into individual document entities using the document data model. A document can be any organized data type, however, the most popular data format is JSON. JSON is natively supported by the Azure Cosmos DB SQL API. A document is an atomic object with its own data form that is independent of what is recorded in other documents in the same database. There is no requirement for a pre-defined schema because of this flexibility, making it easier to quickly design new applications. This flexibility also allows for scenarios in which multiple types of data to be kept together and models can grow over the course of an application’s lifespan.

4.) What is the definition of a JSON document?

JSON (JavaScript Object Notation) is a simple data format. JSON was designed to be extremely compatible with the JavaScript language’s literal object notation. JSON is a popular format for sending and storing data because it is supported natively by many frameworks, browsers, and even databases.

An example of a JSON document is as follows:

{
“device”: {
“type”: “mobile”
},
“sentTime”: “2019-11-12T13:08:42”,
“spoolRefs”: [
“6a86682c-be5a-4a4a-bacd-96c4d1c7ece6”,
“79e78fe2-93aa-4688-89db-a7278b034aa6”
]}

JSON is a relatively readable data format that plainly exposes its content, as you can see. In JavaScript apps, JSON is also relatively simple to parse and use.

5.) What is the SQL API for Azure Cosmos DB?

The Azure Cosmos DB SQL API is a fast NoSQL database service that allows for rich querying over a wide range of data, helps give adjustable and reliable performance, is globally distributed, and allows for rapid development.
For working with documents, the SQL API is the core or native API. With JSON documents, a query language with a familiar syntax, and client libraries for common programming languages, the SQL API allows for quick and flexible development. Other Azure Cosmos DB APIs, such as Mongo, Gremlin, and Cassandra, enable database ecosystem compatibility while mapping to the same underlying infrastructure as the native SQL API.

The Azure Cosmos DB SQL API has a number of benefits, including:

  • Anywhere in the world, the guaranteed speed at any scale—even via bursts—with instant, limitless flexibility, rapid reads, and multi-master writes.
  • With SDKs for common languages, a native SQL API, as well as APIs for MongoDB, Cassandra, and Gremlin, and no-ETL, you can build apps quickly and easily (extract, transform, load) analytics.
  • With guaranteed business continuity, 99.999 percent availability, and enterprise-grade security, it’s ready for mission-critical applications.
    Serverless database that is fully managed and cost-effective, with immediate, automatic scaling that responds to application needs.

Azure Cosmos DB is well-suited for modern application development because of these features. The SQL API for Azure Cosmos DB is ideal for applications that:

  • Traffic spikes and dips are unpredictably unpredictable.
  • Produce a large amount of data
  • User experiences must be delivered in real-time.
  • For company continuity, you can rely on them.
  • The Azure Cosmos DB SQL API may store native JSON documents with a customizable schema on an ad hoc basis. The data is automatically indexed and can be queried using a JSON-specific version of the SQL query language. SDKs for popular frameworks, such as.NET, can be used to access the SQL API.

6.) What are the components of the SQL API for Azure Cosmos DB?

You’ll need to create accounts, databases, containers, and things in Azure before you can start using Azure Cosmos DB.
Accounts. Accounts are the most basic units of distribution and have a high level of availability. In Azure Cosmos DB SQL API, you can configure the region[s] for your data at the account level. The globally unique DNS name used for API queries is likewise stored in accounts. You can also specify the account’s default consistency level for requests. The Azure portal, Azure Resource Manager templates, the Azure CLI, and Azure PowerShell can all be used to manage or create accounts.

Databases

  • One or more Databases can be found in each account. In Azure Cosmos DB SQL API, a database is a logical management unit for containers.

Containers

  • In Azure Cosmos DB SQL API, containers are the fundamental unit of scalability. You may provision throughput at the container level with Azure Cosmos DB. At the container level, you can also set an indexing policy and a default time-to-live number. The data in a container will be automatically and transparently partitioned by the Azure Cosmos DB SQL API.

Items

  • Individual documents are stored as items in the container by the SQL API for Azure Cosmos DB. Because write operations on JSON documents are atomic, the Azure Cosmos DB SQL API natively supports JSON files and can provide quick and predictable performance.

7.) When should you utilize the SQL API for Azure Cosmos DB?

Azure Cosmos DB SQL API is a fully managed NoSQL database service for modern app development, with assured single-digit millisecond response times and 99.999 percent availability, all backed by SLAs and automatic and fast scalability.

Azure Cosmos DB SQL API offers a complete set of financially supported service level agreements (SLAs) that include throughput, consistency, availability, and latency in enterprise applications.

The Azure Cosmos DB SQL API is commonly used in the following scenarios.
Azure Cosmos DB SQL API is well suited for high-performance applications with global ambitions as a fast NoSQL database with a configurable API. Azure Cosmos DB SQL API’s speed and flexibility make it ideal for web, retail, IoT, gaming, and mobile applications that require flexibility, low response times, and high volume or velocity transactions.

IoT/telemetry

  • Sensor workloads in the Internet of Things can be varied and unpredictable. These workloads necessitate a database infrastructure that is responsive and elastically scalable to meet the requirements of as many or as few data collection devices as are installed at any given time. In many circumstances, IoT workloads can write large amounts of data, so a write-optimized database platform would be beneficial. The Azure Cosmos DB SQL API is designed for workloads that require a lot of writing. With fast and predictable indexed write speeds, operations on a single document are atomic. The Azure Cosmos DB SQL API is also globally distributed and elastic, allowing it to support a wide range of IoT workloads.

Retail/marketing

  • The Azure Cosmos DB SQL API is ideal for retail and marketing workloads that can see large and unexpected changes in usage at any time of year. Azure Cosmos DB SQL API’s elastic scale ensures that the database platform can handle requests at peak times while saving money during off-peak times.

Web/mobile

  • Many modern social programs generate a large amount of user-generated content, which varies in quantity, shape, and volume. The Azure Cosmos DB SQL API is an excellent fit for this task since it can store data in a variety of schemas. Consider the SQL API for data with changing or evolving schemas as the company’s initiatives grow into new sectors.

8.) What is the procedure for creating a new account?

To get started with Azure Cosmos DB, you must first register a new account.

You must first choose an API for your workload when registering a new account on the portal. After the account has been created, the API choices cannot be modified. We’ll presume that the SQL API has been chosen for the rest of this section. After that, the Azure site will walk you through a step-by-step wizard with tabs for different configuration settings. You can customize options such as:

  • Your account’s internationally unique name
  • The account’s location (Azure region).
  • Mode of capacity (provisioned throughput or serverless)

9.) How to make a new database?

In Azure Cosmos DB SQL API, databases are logical management units that don’t take long to create. To create a new database, all you need is a unique database name within the account.

Note

If you opt to provision throughput at the database level, however, you may need to take further steps to configure the database. Other Azure Cosmos DB SQL API topics delve deeper into this.

10.) What’s the best way to make a new container?

In Azure Cosmos DB SQL API, containers are the primary scalability unit. When constructing a container, you need to include the following information:

  • The parent database
  • A name for the database container that is unique.
  • The partition key value’s route.
  • Optional: if not inferred from database provisioning, provisioned throughput.

Based on the value of the partition key for each individual item, the Azure Cosmos DB service will automatically and transparently partition your data.

11.) How to create a simple item?

You’re ready to build your first item once you’ve set up the database and container resources. A JSON document is an object in the Azure Cosmos DB SQL API.

Note

JavaScript Object Notation (JSON) is an open standard file format and data exchange format that stores and transmits data objects made up of attribute-value pairs and array data types using human-readable text (or any other serializable value)

JSON is a language-agnostic data format with well-defined data types and widespread support across a wide range of applications and programming languages.

12.) Describe the differences between relational and NoSQL databases.

There are two types of database systems in use: relational and non-relational. These systems have a lot of distinctions.

  • NoSQL stores unstructured or semi-structured data in the form of key/value or JSON documents, whereas relational databases contain connected tables.
  • The schema of a relational database is fixed, but the schema of a NoSQL database is dynamic.
  • Relational databases utilise SQL (Structured Query Language) to manage data, whereas NoSQL databases use a variety of models to maintain and retrieve data.
  • ACID guarantees are provided by relational tables, but not by NoSQL beyond the boundaries of a single DB split.
  • NoSQL is a high-performance database with ease-of-use, resilience, scalability, and availability features. Relational databases are mature, proven, and widely used, whereas NoSQL is a high-performance database with ease-of-use, resilience, scalability, and availability characteristics.

13.) Describe the most popular uses for Azure Cosmos DB.

Azure Cosmos DB is an excellent solution for any mobile, web, gaming, or IoT app that requires:

millisecond response times on the low and fast end of the scale
ability to query over schema-free data with predictable speed to automatically scale swiftly and worldwide.

14.) Explain the types of SQL subqueries.

A subquery is a query that sits inside another query. An outer query is a query or statement that contains a sub query. Inner query is another name for subquery. Subqueries are divided into two categories.
Only Correlated subqueries are supported by Azure Cosmos DB.

Correlated – This subquery is evaluated once for each row processed by the outer query, and it uses values from the outer query.
Non-correlated – This subquery is independent of the outer query. It can be run without the need to reference values from the outer query.
Subqueries are further divided into three groups based on the amount of rows and columns they return, as shown below.

  • Returns a table with several rows and columns.
  • Multiple rows and a single column are returned when using multi-value.
  • Single row and single column are returned in a scalar.

15.) What distinguishes Cosmos DB from other databases?

  • Complete and ready-to-use service: It gives you a comprehensive Azure-powered solution that can be automatically replicated in data centres all around the world.
  • Users can access data using any API of their choosing because data is automatically indexed. SQL, Gremlin, JavaScript, Azure Table Storage, and MongoDB are all tools they can use to see their data.
  • Support for several APIs and languages.
  • Support for many consistency types.
  • Data is automatically indexed.
  • Availability is high.
  • There are several levels of consistency: Bounded staleness, strong, session, eventual, and consistent-prefix are the five different consistency levels used.
  • Latency: When reading data, a latency of fewer than 10 milliseconds is practically guaranteed, and when writing data, a latency of less than 15 milliseconds is practically assured.
  • Globally dispersed
  • Scalable in a linear fashion.
  • Indexing that is schema-agnostic.
  • Multi-Model.

16.) In Cosmos DB, what does Databricks access?

Microsoft’s Azure Cosmos DB is a globally distributed, multi-model database. You can elastically and independently extend throughput and storage across any number of Azure geographic zones with Azure Cosmos DB. With complete service level agreements, it guarantees throughput, latency, availability, and consistency (SLAs).

17.) What Is A Master Key And How Does It Work?

A master key is a security token that grants access to all of an account’s resources. Individuals who have the key have read and write access to the database account’s resources. When distributing master keys, be cautious. On the Keys blade of the Azure portal, you can find the primary master key and secondary master key.

18.) Explain how Cosmos DB indexes data.

Azure Cosmos DB is a schema-agnostic database that lets you iterate on your project without worrying about schema or index maintenance. Without needing to create any schema or configure secondary indexes, Azure Cosmos DB automatically indexes every property for all items in your container. This article explains how Azure Cosmos DB indexes data and how indexes are used to increase query performance. Before learning how to adjust indexing policies, it’s a good idea to read this section first.

19.) What is the definition of a primary key?

A primary key is a security token that allows an account to access all of its resources. Individuals who have the key have read and write access to the database account’s resources. When distributing primary keys, be cautious. On the Keys blade of the Azure portal, you can find the primary primary key and secondary primary key. See View, copy, and regenerate access keys for additional information about keys.

20.) What are the multiple levels of consistency that Cosmos DB has to offer?

Azure Cosmos DB allows you to choose a consistency level that meets your requirements for latency, throughput, and availability. The following are the many levels of consistency available:

  • Strong Uniformity: Maintains consistency across all nodes and regions at the cost of overall performance.
  • Staleness with a stale Boundary Consistency: This feature allows you to determine the level of freshness of your data. This is still a good consistency, based on the level of freshness picked. There’s a chance you’ll get dirty reads.
  • Session Consistency: Ensures that the writer does not have any dirty reads, despite the fact that other users may have dirty reads. This is the default consistency level for Azure Cosmos DB.
  • Consistent Prefix: Ensures that the read data on all replicas has been updated. At this level, readers never see out-of-order writing.
  • Eventual Consistency: There are no guarantees about the data or order’s accuracy. This, on the other hand, provides the fastest performance.

21.) How does Cosmos Db provide predictable results?

In Azure Cosmos DB, a request unit (RU) is a unit of measurement for throughput. A 1-RU throughput is equal to the GET throughput of a 1-KB page. Every operation in Azure Cosmos DB has a deterministic RU number depending on the throughput necessary to execute the operation, including reads, writes, SQL queries, and stored procedure executions. You can conceive of a single RU measure instead of worrying about CPU, IO, and memory and how they all effect your application throughput. Each Azure Cosmos DB container can be reserved with provisioned throughput in terms of RUs per second. You can also change the throughput of your container as your application’s requirements change.

22.) What are Authorization header?

To interact with a resource, you must include the authorization header with the authorization string in all REST operations, whether you’re using a master key token or a resource token.
The following are the parts included in brackets:
The type of token is indicated by typeoftoken: master or resource.
Tokenversion refers to the token’s current version, which is 1.0.
The hashed token signature is denoted by the term hassignature.
To ensure that the authorisation string does not contain any erroneous characters, it should be encoded before being added to the REST request.

23.) What’s the best way to get started with the documentdb Api?

The Azure site has the Microsoft DocumentDB API. To begin, you must first purchase an Azure subscription. You can add DocumentDB API container to your Azure subscription once you’ve signed up for one. See Create an Azure Cosmos DB database account for details on how to add an Azure Cosmos DB account.
For.NET, Python, Node.js, JavaScript, and Java, SDKs are available. Developers can interface with Azure Cosmos DB resources using RESTful HTTP APIs from a variety of platforms and languages.

24.) What is the best way to bulk-insert documents into Cosmos Db?

There are two techniques to bulk-insert documents into Azure Cosmos DB:

  • As specified in Database migration tool for Azure Cosmos DB, the statistics migration device.
  • Server-aspect JavaScript programming for Azure Cosmos DB describes stored techniques.

25.) Is Resource Link Caching Supported by the Documentdb Api?

Because Azure Cosmos DB is a RESTful provider, valuable resource URLs are immutable and cacheable. Customers using the DocumentDB API can specify a “If-None-Match” header for reads against any aid-like document or series, then replace their local copies after the server model changes.

26.) Is it possible to run Documentdb Api locally?

Yes. The Azure Cosmos DB Emulator simulates the Cosmos DB provider with high fidelity. It has the same capabilities as Azure Cosmos DB, including instructions for building and querying JSON documents, deploying and scaling collections, and running saved tactics and triggers. You can use the Azure Cosmos DB Emulator to develop and test programmes, and then deploy them to Azure on a global scale by sending a single setup request to the Azure Cosmos DB connection endpoint.

27.) What Is The Azure Cosmos Db Api For Mongodb?

The Azure Cosmos DB API for MongoDB is a compatibility layer that allows programmes to communicate with the Azure Cosmos DB database engine in a simple and transparent manner by leveraging existing, community-supported Apache MongoDB APIs and drivers.

28.) When I import data into Azure Table Storage, I never get a “quota full” notification (showing that a partition is full). I Receive This Message When Using The Table Api. Is this offer restricting my options and forcing me to abandon my current application?

Azure Cosmos DB is a service-level agreement (SLA)-based device that provides limitless scalability while ensuring latency, throughput, availability, and consistency. Make sure your information length and index are both possible and scalable to ensure top-notch performance. The 10-GB limit on the amount of entities or gadgets in accordance with partition keys ensures that we can deliver excellent research and question performance. We recommend not creating a hot partition by keeping all data in one partition and querying it to ensure that your application scales well, especially for Azure Storage.

29.) What Are The Table Api’s Error Messages?

Because Azure Table Garage and Azure Cosmos DB Table API use the same SDKs, the majority of issues are likely to be the similar.
Question

30.) Why do I get throttled when I try to create many tables in the Table Api at the same time?

Azure Cosmos DB is a fully machine with SLAs that guarantees latency, throughput, availability, and consistency. Because it’s a provisioned device, it has resources set aside to meet these requirements. The rapid rate of table creation is noticed and slowed. We recommend that you examine the rate at which tables appear and reduce it to less than five per minute. The Table API is a provided device, so keep that in mind. You’ll start paying for it as soon as you provide it.

DP-420 Practice Tests


Menu