Configure and Execute Requests in a No-SQL Globally-Distributed Database using .NET API

Creating an Object for Database Requests in Azure Solutions

Question

You develop Azure solutions.

You must connect to a No-SQL globally-distributed database by using the .NET API.

You need to create an object to configure and execute requests in the database.

Which code segment should you use?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C.

C.

Example: // Create a new instance of the Cosmos Client this.cosmosClient = new CosmosClient(EndpointUri, PrimaryKey) //ADD THIS PART TO YOUR CODE await this.CreateDatabaseAsync(); Reference: https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-get-started.

The correct answer is C. new CosmosClient(EndpointUri, PrimaryKey).

Explanation:

The scenario requires connecting to a globally-distributed No-SQL database and executing requests using the .NET API. Cosmos DB is a globally-distributed, multi-model database service that supports document, key-value, graph, and column-family data models. Cosmos DB provides APIs for various programming languages including .NET, Java, Node.js, Python, and others.

To connect to Cosmos DB using the .NET API, the CosmosClient class can be used. The CosmosClient class provides a client-side logical representation of the Azure Cosmos DB service. The constructor of the CosmosClient class takes two parameters: EndpointUri and PrimaryKey. EndpointUri is the endpoint URI of the Cosmos DB account, and PrimaryKey is the primary key of the Cosmos DB account.

Therefore, the correct code segment to create an object to configure and execute requests in the database is:

scss
new CosmosClient(EndpointUri, PrimaryKey);

Option A (new Container(EndpointUri, PrimaryKey)) is incorrect because Container is not a valid class for connecting to Cosmos DB.

Option B (new Database(EndpointUri, PrimaryKey)) is incorrect because Database is not a valid class for connecting to Cosmos DB.