exam questions

Exam AZ-204 All Questions

View all questions & answers for the AZ-204 exam

Exam AZ-204 topic 3 question 38 discussion

Actual exam question from Microsoft's AZ-204
Question #: 38
Topic #: 3
[All AZ-204 Questions]

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?

  • A. database_name = 'MyDatabase'
    database = client.create_database_if_not_exists(id=database_name)
  • B. client = CosmosClient(endpoint, key)
  • C. container_name = 'MyContainer'
    container = database.create_container_if_not_exists(
    id=container_name, partition_key=PartitionKey(path="/lastName"), offer_throughput=400 )
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
imanonion
Highly Voted 2 years, 3 months ago
Selected Answer: B
CosmosClient has to be created before you can do option A and C to create databases and execute requests. client = CosmosClient(endpoint, key) database_name = 'MyDatabase' database = client.create_database_if_not_exists(id=database_name) container_name = 'MyContainer' container = database.create_container_if_not_exists( id=container_name, partition_key=PartitionKey(path="/lastName"), offer_throughput=400 )
upvoted 19 times
[Removed]
1 year, 9 months ago
It doesn't matter. Question is asking about .NET API. A and C are not .NET code
upvoted 9 times
...
...
examtopicsLogin123
Most Recent 7 months, 1 week ago
I found that this question has the following answer options: A. new Container(EndpointUri, PrimaryKey); B. new Database(EndpointUri, PrimaryKey); C. new CosmosClient(EndpointUri, PrimaryKey); and the correct answer is: new CosmosClient(...)
upvoted 1 times
...
tempacc4nk
1 year, 8 months ago
I think its B, but its missing new keyword. CosmosClient cosmosClient = new CosmosClient( "connection-string-from-portal", new CosmosClientOptions() { ApplicationRegion = Regions.EastUS2, });
upvoted 4 times
LHU
6 months ago
Agreed, all these examples are incorrect C# code. Also note the strings denoted as ' ' and not " "
upvoted 1 times
...
...
[Removed]
1 year, 9 months ago
B is only one .NET code here. So, B is a correct answer
upvoted 3 times
...
kabbas
1 year, 10 months ago
Selected Answer: B
You need to create the client before anything else
upvoted 4 times
...
deathRac3
1 year, 11 months ago
Selected Answer: B
correct
upvoted 1 times
...
rcardenas72
2 years, 2 months ago
The correct code segment to configure and execute requests in the No-SQL globally-distributed database by using the .NET API would be option B: client = CosmosClient(endpoint, key) This code initializes the CosmosClient class and connects to the database with the specified endpoint and key parameters. This is the first step in creating a client to communicate with the Azure Cosmos DB. Option A shows how to create a database, and option C shows how to create a container inside a database, but they do not create the client object that is needed to communicate with the database. Therefore, they are not correct options for this scenario.
upvoted 4 times
...
uffuchsi
2 years, 2 months ago
Has to be B - How could you do either A or C before B?
upvoted 2 times
...
BrettusMaximus
2 years, 2 months ago
A You need to" create an object" to configure and execute requests in the "database". Not B Sure B must be done before A, but A is the actual database Object Not C C is the container and not the database object
upvoted 2 times
...
LeoIT
2 years, 3 months ago
B as “by using the .NET API”
upvoted 2 times
...
Esward
2 years, 3 months ago
B is the correct answer https://learn.microsoft.com/en-us/python/api/azure-cosmos/azure.cosmos.cosmosclient?view=azure-python
upvoted 1 times
...
AmitPaul
2 years, 3 months ago
Selected Answer: B
CosmosClient has to be created first
upvoted 2 times
...
Kavin235
2 years, 3 months ago
Selected Answer: B
I believe Cosmos client type object can be used to configure and execute requests in the Azure Cosmos DB database service. https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.cosmosclient?view=azure-dotnet
upvoted 1 times
...
Skelletcz
2 years, 3 months ago
Selected Answer: B
I vote for CosmosClient, which can connect to No-SQL database
upvoted 3 times
...
Nhiendo
2 years, 3 months ago
i think answer B
upvoted 2 times
chettir01
2 years, 3 months ago
i don't think so, in my point of view, cosmos client can be used to create your datababe, but not to manipulate it. to do that, you have to create a container from this database, and use this object to do some requests !
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago