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 )
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(...)
I think its B, but its missing new keyword.
CosmosClient cosmosClient = new CosmosClient(
"connection-string-from-portal",
new CosmosClientOptions()
{
ApplicationRegion = Regions.EastUS2,
});
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.
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
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
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
...
...
This section is not available anymore. Please use the main Exam Page.AZ-204 Exam Questions
Log in to ExamTopics
Sign in:
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.
imanonion
Highly Voted 2 years, 3 months ago[Removed]
1 year, 9 months agoexamtopicsLogin123
Most Recent 7 months, 1 week agotempacc4nk
1 year, 8 months agoLHU
6 months ago[Removed]
1 year, 9 months agokabbas
1 year, 10 months agodeathRac3
1 year, 11 months agorcardenas72
2 years, 2 months agouffuchsi
2 years, 2 months agoBrettusMaximus
2 years, 2 months agoLeoIT
2 years, 3 months agoEsward
2 years, 3 months agoAmitPaul
2 years, 3 months agoKavin235
2 years, 3 months agoSkelletcz
2 years, 3 months agoNhiendo
2 years, 3 months agochettir01
2 years, 3 months ago