You need to connect to a globally distributed NoSQL database from .NET and create the object used to configure and execute database requests. Which code line should you use to create the client object?
Choose an answer
Tap an option to check your answer.
Correct answer: client = CosmosClient(endpoint, key).
Why this is the answer
The correct answer is client = CosmosClient(endpoint, key). This line of code instantiates the CosmosClient object, which is the primary object used in the Azure Cosmos DB .NET SDK to interact with a Cosmos DB account. It requires the endpoint (the URI of your Cosmos DB account) and the key (the primary or secondary key for authentication) to establish a connection. The other options are incorrect because they represent subsequent steps in interacting with Cosmos DB, not the initial client object creation: databasename = 'MyDatabase' database = client.createdatabaseifnotexists(id=databasename) creates or retrieves a database using an already instantiated client object. containername = 'MyContainer' container = database.createcontainerifnotexists(...) creates or retrieves a container within an already existing database object.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed