DP-420 cheat sheet
DP-420 · Keep the key ideas within reach.
Design and develop database solutions
A container's partition key path is fixed at creation; choose a property with high cardinality that appears in the filter of most queries so reads stay single-partition.
Hierarchical partition keys support up to three levels (for example /tenantId, /userId, /sessionId); a query must supply the full prefix to prune to one logical partition.
A transactional batch commits atomically only when every operation targets the same logical partition key; the limits are 100 operations and a 2 MB total payload.
Consistency levels from strongest to weakest: Strong, Bounded Staleness, Session, Consistent Prefix, Eventual. Session is the default and is pinned by a client session token.
Strong consistency permits only a single write region and cannot be combined with multi-region writes; bounded staleness caps staleness by a configured number of operations (RU) plus a time window.
A 1 KB point read by id and partition key costs 1 RU; an equivalent query costs more because the charge includes parsing, index lookup, and any cross-partition fan-out.
The default indexing policy includes /* and range-indexes every string and number; only the root paths /* and /? can be excluded, and editing the policy triggers a reindex.
An item-level ttl overrides the container default; -1 means the item never expires, and if the container DefaultTimeToLive is null, TTL is disabled entirely.
The change feed is ordered within a logical partition key and delivered at least once; all-versions-and-deletes mode requires continuous backup (point-in-time restore) on the account.
Secure, optimize, and deploy database solutions
Data-plane authorization uses account keys, resource tokens, or Microsoft Entra ID with the built-in roles Cosmos DB Built-in Data Reader and Cosmos DB Built-in Data Contributor.
Setting disableLocalAuth to true rejects all key-based and resource-token requests, forcing clients to authenticate with Microsoft Entra ID tokens.
Customer-managed keys for encryption at rest live in Azure Key Vault and must be configured when the account is created; the account's managed identity unwraps the key.
The integrated cache requires a dedicated gateway; point reads and queries served from the cache do not consume provisioned RU/s, subject to configured max staleness.
Autoscale moves between 10 percent of the configured maximum RU/s and that maximum, and billing uses the highest RU/s reached during each hour.
Indexing mode 'none' removes index maintenance cost from writes; reads then require scans, so pair it with analytical store or change feed consumers rather than point reads.
Read the x-ms-request-charge response header (RequestCharge in the SDK) to measure RU cost per operation; query metrics break down cross-partition fan-out.
AllowBulkExecution = true groups many concurrent item create/read/update/delete calls into batches to saturate throughput; it does not apply to queries or stored procedures.
Automatic failover promotes the next region in the account's failover priority list when the write region is unavailable; manual failover switches regions immediately for planned drills.
Implement AI and Analytics capabilities in database solutions
Vector search needs a container vector policy (path, dataType float32/float16/int8/uint8, dimensions, distanceFunction cosine/dotproduct/euclidean) plus a matching vectorIndexes entry in the indexing policy.
Use ORDER BY VectorDistance(v.embedding, @query) with a TOP clause to return ranked nearest neighbors; without TOP the results are not ordered by similarity.
Vector index type diskANN is the recommended approximate-nearest-neighbor index for large collections; quantizedFlat uses less memory and suits smaller collections.
Vector policy and vector index are both required: declaring only one causes vector queries to fail or return unranked results.
Synapse Link keeps a columnar analytical store that syncs automatically from the transactional store; analytical queries run on a separate column store and do not consume transactional RU/s.
analyticalStoreTimeToLiveInSeconds of -1 retains analytical data indefinitely and 0 disables the analytical store; the value is independent of the transactional TTL.
An embedding pipeline pattern: an Azure Functions change feed trigger sends new items to Azure OpenAI and writes the returned vector back into the same container.
RAG pattern: embed the user question, run a top-k vector query against the container, and inject the retrieved items into the model prompt as grounding context.
A Cosmos DB indexer in Azure AI Search pulls items and adds full-text search, filtering, and semantic ranking on top of the same documents.