nerdexam
MicrosoftMicrosoft

AZ-204 · Question #374

AZ-204 Question #374: Real Exam Question with Answer & Explanation

The correct configuration requires 'compositeIndexes' as the top-level policy property, since querying with ORDER BY on multiple fields requires a composite index in Cosmos DB - a regular index is insufficient. The sort order must match the query exactly: 'descending' for the fir

Submitted by asante_acc· Mar 30, 2026Develop for Azure Storage - specifically configuring and optimizing Cosmos DB indexing policies to support ordered queries using composite indexes (AZ-204 / DP-420 certification domain)

Question

Drag and Drop Question You are developing a new page for a website that uses Azure Cosmos DB for data storage. The feature uses documents that have the following format: You must display data for the new page in a specific order. You create the following query for the page: You need to configure a Cosmos DB policy to the support the query. How should you configure the policy? To answer, drag the appropriate JSON segments to the correct locations. Each JSON segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point. Answer:

Explanation

The correct configuration requires 'compositeIndexes' as the top-level policy property, since querying with ORDER BY on multiple fields requires a composite index in Cosmos DB - a regular index is insufficient. The sort order must match the query exactly: 'descending' for the first field (matching the DESC in the ORDER BY clause) and 'ascending' for the second field (matching ASC or the default ascending order), because Cosmos DB composite indexes must mirror the exact sort direction of the query or its perfect inverse for the index to be utilized.

Topics

#Azure Cosmos DB#Composite Indexes#Indexing Policy#Query Optimization

Community Discussion

No community discussion yet for this question.

Full AZ-204 PracticeBrowse All AZ-204 Questions