This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Which block of code should be used to create a client to connect to the Azure Cosmos DB account with an endpoint?
string endpoint = "<nosql-account-endpoint>"; DefaultAzureCredential credential = new(); using CosmosClient client = new(endpoint, credential);
string endpoint = "<nosql-account-endpoint>"; using CosmosClient client = new(endpoint);
string endpoint = "<nosql-account-endpoint>"; using CosmosClient client = new();
Consider a new Azure Cosmos DB account without any resources. Which block of code creates the first server-side resource that is required to store a set of containers?
using CosmosClient client = new(connectionString);
Container container = await database.CreateContainerIfNotExistsAsync( "products", "/department", throughput: 400 );
Database database = await client.CreateDatabaseIfNotExistsAsync( "example-database" );
An item already exists in the Azure Cosmos DB for NoSQL account with a unique identifier of 04b3038c-b966-4a86-a1f3-5d1fa5c2a47c. Which of the following blocks of code replace the existing item in the container with a newly created item without running the risk of creating an entirely new item.
04b3038c-b966-4a86-a1f3-5d1fa5c2a47c
Item item = new("04b3038c-b966-4a86-a1f3-5d1fa5c2a47c", "item-category", "item-name", 0, true); await container.UpsertItemAsync<Item>(item);
Item item = new("04b3038c-b966-4a86-a1f3-5d1fa5c2a47c", "item-category", "item-name", 0, true); container.ReplaceItemAsync("04b3038c-b966-4a86-a1f3-5d1fa5c2a47c", item);
Item item = new("04b3038c-b966-4a86-a1f3-5d1fa5c2a47c", "item-category", "item-name", 0, true); await container.CreateItemAsync<Item>(item);
Here's an Azure Cosmos DB for NoSQL query: SELECT * FROM container c WHERE c.partitionKey == 'some-category' ORDER BY c.id. What is the language-integrated query (LINQ) equivalent of this query?
SELECT * FROM container c WHERE c.partitionKey == 'some-category' ORDER BY c.id
using FeedIterator<Product> feed = container.GetItemLinqQueryable<Item>() .OrderBy(i => i.partitionKey) .ToFeedIterator();
using FeedIterator<Product> feed = container.GetItemLinqQueryable<Item>() . Where(i => i.id == "some-category") .ToFeedIterator();
using FeedIterator<Product> feed = container.GetItemLinqQueryable<Item>() . Where(i => i.partitionKey == "some-category") .OrderBy(i => i.id) .ToFeedIterator();
You must answer all questions before checking your work.
Was this page helpful?