AZ-204 Exam QuestionsBrowse all questions from this exam

AZ-204 Exam - Question 121


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?

Show Answer
Correct Answer: C

To connect to a No-SQL globally-distributed database using the .NET API, you need to create an instance of the CosmosClient class. The CosmosClient class is designed specifically for handling interactions with Azure Cosmos DB, which is a globally-distributed No-SQL database. By creating a new CosmosClient object using the EndpointUri and PrimaryKey, you can configure and execute requests against the database. This approach is standard practice for connecting to Azure Cosmos DB in .NET.

Discussion

22 comments
Sign in to comment
Mr2302682
Aug 15, 2020

The Answer is correct!

mlantonis
May 23, 2021

Correct Answer: C Azure Cosmos DB is a fully managed NoSQL database for modern app development. Single-digit millisecond response times, and automatic and instant scalability, guarantee speed at any scale. // 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/dotnet/api/microsoft.azure.cosmos.cosmosclient?view=azure-dotnet https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-get-started

lugospod
Jan 19, 2022

Got this one 01/2022. Went with most voted (to avoid writing answers again)

Mev4953
Jan 21, 2022

Got this in the exam 01/22

oescm
Feb 7, 2022

Got this one 02/2022. Went with highly voted answer.

glam
May 14, 2021

correct.

SlavMar
Jun 29, 2021

But why we assume it is Cosmos? App needs to access some No-SQL database that may already exist - maybe it is Cosmos, maybe not

27close
Nov 14, 2020

https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-get-started public static async Task Main(string[] args) { } // ADD THIS PART TO YOUR CODE /* Entry point to call methods that operate on Azure Cosmos DB resources in this sample */ public async Task GetStartedDemoAsync() { // Create a new instance of the Cosmos Client this.cosmosClient = new CosmosClient(EndpointUri, PrimaryKey); answer is correct

Tom87
Apr 5, 2021

Correct answer. CosmosClient is the only one with the appropriate constructor. https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.cosmosclient.-ctor?view=azure-dotnet https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.database.-ctor?view=azure-dotnet https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.container.-ctor?view=azure-dotnet

debanjan10
Oct 5, 2021

Order: Cosmos Client > Database > Container > Item

DParekh
May 31, 2021

There are two ways by which we can created cosmosclient instance. 1. CosmosClient cosmosClient = new CosmosClient(connectionString); 2. CosmosClient cosmosClient = new CosmosClient(EndpointUri, PrimaryKey) So answer C is correct.

sanjayrawat
Oct 7, 2021

Answer : C

petitbilly
Mar 10, 2022

Got it in exam 03/22

EltoothOption: C
Jun 10, 2022

C is correct answer. Global fully managed No-SQL DB = CosmosDB

dimsok
Feb 9, 2023

I dont get this question, Cosmos DB is a No-SQL globally-distributed database, but there are others that .NET can connect.

Jorax
Apr 16, 2025

Yes, but "You develop Azure solutions."

FreidrichOption: C
Feb 23, 2022

The correct answer is C.

rohitpatil113Option: C
Aug 22, 2022

The Answer is correct!

OPT_001122Option: C
Nov 19, 2022

C. new CosmosClient(EndpointUri, PrimaryKey);

AvinashVarmaOption: C
Dec 15, 2022

CosmosClient(String, String, CosmosClientOptions) https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.cosmosclient?view=azure-dotnet

Nhiendo
Jan 2, 2023

Correct Answer: C

Tej_007
Sep 6, 2024

wow. finally one correct answer.

wafa_chaariOption: C
Jan 27, 2025

cosmosclient is the entry point for interacting with Azure Cosmos DB