Skip to content

Commit ab9ce63

Browse files
authored
Merge pull request #57712 from SnehaGunda/partitioningdocs
Indexing, change feed, optimistic concurrency, container and items docs
2 parents 229da67 + e11b2a7 commit ab9ce63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1191
-1463
lines changed

.openpublishing.redirection.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@
361361
"redirect_url": "/azure/cosmos-db/conflict-resolution-policies",
362362
"redirect_document_id": true
363363
},
364+
{
365+
"source_path": "articles/cosmos-db/manage-account.md",
366+
"redirect_url": "/azure/cosmos-db/how-to-manage-database-account",
367+
"redirect_document_id": false
368+
},
369+
{
370+
"source_path": "articles/cosmos-db/indexing-policies.md",
371+
"redirect_url": "/azure/cosmos-db/indexing-policy",
372+
"redirect_document_id": true
373+
},
364374
{
365375
"source_path": "articles/cosmos-db/distribute-data-globally-benefits.md",
366376
"redirect_url": "/azure/cosmos-db/distribute-data-globally",
@@ -9271,7 +9281,7 @@
92719281
},
92729282
{
92739283
"source_path": "articles/documentdb/documentdb-indexing-policies.md",
9274-
"redirect_url": "https://docs.microsoft.com/azure/cosmos-db/indexing-policies",
9284+
"redirect_url": "/azure/cosmos-db/indexing-policy",
92759285
"redirect_document_id": false
92769286
},
92779287
{

articles/cosmos-db/TOC.yml

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@
6969
href: create-table-python.md
7070
- name: Concepts
7171
items:
72+
- name: Working with Azure Cosmos account
73+
href: account-overview.md
74+
- name: Containers and items
75+
items:
76+
- name: Working with databases, containers, and items
77+
href: databases-containers-items.md
78+
- name: Indexing
79+
items:
80+
- name: Overview
81+
href: index-overview.md
82+
- name: Indexing policy
83+
href: index-policy.md
84+
- name: Index types
85+
href: index-types.md
86+
- name: Index paths
87+
href: index-paths.md
88+
- name: Change feed
89+
items:
90+
- name: Overview
91+
href: change-feed.md
92+
- name: Reading change feed
93+
href: read-change-feed.md
94+
- name: Change feed processor
95+
href: change-feed-processor.md
96+
- name: Change feed with Azure Functions
97+
href: change-feed-functions.md
98+
- name: Time to live
99+
href: time-to-live.md
100+
- name: Unique key constraints
101+
href: unique-keys.md
102+
- name: Transactions and optimistic concurrency
103+
href: database-transactions-optimistic-concurrency.md
72104
- name: Resource model
73105
href: sql-api-resources.md
74106
- name: Global distribution
@@ -85,7 +117,7 @@
85117
href: consistency-levels-tradeoffs.md
86118
- name: High availability
87119
href: high-availability.md
88-
- name: Scale throughput globally
120+
- name: Globally scaling provisioned throughput
89121
href: scaling-throughput.md
90122
- name: Conflict resolution policies
91123
href: conflict-resolution-policies.md
@@ -105,14 +137,6 @@
105137
href: request-units.md
106138
- name: Provision throughput on containers and databases
107139
href: set-throughput.md
108-
- name: Indexing
109-
href: indexing-policies.md
110-
- name: Change feed
111-
href: change-feed.md
112-
- name: Time to live
113-
href: time-to-live.md
114-
- name: Unique keys
115-
href: unique-keys.md
116140
- name: Security
117141
items:
118142
- name: Overview
@@ -392,6 +416,32 @@
392416
href: /rest/api/storageservices/Table-Service-Concepts
393417
- name: How-to guides
394418
items:
419+
- name: Manage database account
420+
href: how-to-manage-database-account.md
421+
- name: Configure time to live
422+
href: how-to-time-to-live.md
423+
- name: Global distribution
424+
items:
425+
- name: Manage consistency
426+
href: how-to-manage-consistency.md
427+
- name: Manage conflicts
428+
href: how-to-manage-conflicts.md
429+
- name: Provisioned throughput
430+
items:
431+
- name: Provision container throughput
432+
href: how-to-provision-container-throughput.md
433+
- name: Provision database throughput
434+
href: how-to-provision-database-throughput.md
435+
- name: Working with containers and items
436+
items:
437+
- name: Create a container
438+
href: how-to-create-container.md
439+
- name: Query a container
440+
href: how-to-query-container.md
441+
- name: Indexing
442+
items:
443+
- name: Configure indexing
444+
href: how-to-manage-indexing-policy.md
395445
- name : Manage
396446
items:
397447
- name: Manage using PowerShell
@@ -402,8 +452,6 @@
402452
href: storage-explorer.md
403453
- name: Manage using data explorer
404454
href: data-explorer.md
405-
- name: Manage your account
406-
href: manage-account.md
407455
- name : Logging
408456
items:
409457
- name: Diagnostic logging
@@ -426,26 +474,6 @@
426474
href: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb
427475
- name: Set up Azure DevOps CI/CD pipeline
428476
href: tutorial-setup-ci-cd.md
429-
- name: Global distribution
430-
items:
431-
- name: Manage Database Account
432-
href: how-to-manage-database-account.md
433-
- name: Manage Consistency
434-
href: how-to-manage-consistency.md
435-
- name: Manage Conflicts
436-
href: how-to-manage-conflicts.md
437-
- name: Provisioned throughput
438-
items:
439-
- name: Provision container throughput
440-
href: how-to-provision-container-throughput.md
441-
- name: Provision database throughput
442-
href: how-to-provision-database-throughput.md
443-
- name: Working with containers and items
444-
items:
445-
- name: Create a container
446-
href: how-to-create-container.md
447-
- name: Query a container
448-
href: how-to-query-container.md
449477
- name: Best practices
450478
items:
451479
- name: Performance tips
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Working with Azure Cosmos DB accounts
3+
description: This article describes how create and use Azure Cosmos DB accounts
4+
author: dharmas
5+
6+
ms.service: cosmos-db
7+
ms.topic: conceptual
8+
ms.date: 11/08/2018
9+
ms.author: dharmas
10+
ms.reviewer: sngun
11+
12+
---
13+
14+
# Working with Azure Cosmos DB accounts
15+
16+
Azure Cosmos DB is a fully managed platform-as-a-service (PaaS). To begin using Azure Cosmos DB, you should initially create an Azure Cosmos DB account in your Azure subscription. Your Azure Cosmos account contains a unique DNS name and you can manage an account by using Azure portal, Azure CLI or by using different language-specific SDKs. For more information, see [how to manage your Azure Cosmos account](how-to-manage-database-account.md).
17+
18+
The Azure Cosmos DB account is the fundamental unit of global distribution and high availability. For globally distributing your data and throughput across multiple Azure regions, you can add and remove Azure regions to your Azure Cosmos account at any time. You can configure your Azure Cosmos account to have either a single or multiple write regions. For more information, see [how to add and remove Azure regions to your Azure Cosmos account](how-to-manage-database-account.md). You can configure the [default consistency](consistency-levels.md) level on Azure Cosmos account. Azure Cosmos DB provides comprehensive SLAs encompassing throughput, latency at the 99th percentile, consistency, and high availability. For more information, see [Azure Cosmos DB SLAs](https://azure.microsoft.com/en-us/support/legal/sla/cosmos-db/v1_2/).
19+
20+
To securely manage access to all the data within your Azure Cosmos account, you can use the master keys associated with your account. To further secure access to your data, you can configure a VNET service endpoint and IP-firewall on your Azure Cosmos account.
21+
22+
## Elements in an Azure Cosmos account
23+
24+
Azure Cosmos DB container is the fundamental unit of scalability. You can virtually have an unlimited provisioned throughput (RU/s) and storage on a container. Azure Cosmos DB transparently partitions your container using the logical partition key that you specify in order to elastically scale your provisioned throughput and storage. For more information, see [working with Azure Cosmos containers and items](databases-containers-items.md).
25+
26+
Currently, you can create a maximum of 100 Azure Cosmos accounts under an Azure subscription. A single Azure Cosmos account can virtually manage unlimited amount of data and provisioned throughput. To manage your data and provisioned throughput, you can create one or more Azure Cosmos databases under your account and within that database, you can create one or more containers. The following image shows the hierarchy of elements in an Azure Cosmos account:
27+
28+
![Hierarchy of a Azure Cosmos account](./media/account-overview/hierarchy.png)
29+
30+
## Next steps
31+
32+
You can now proceed to learn how to manage your Azure Cosmos account or see other concepts associated with Azure Cosmos DB:
33+
34+
* [How-to manage your Azure Cosmos account](how-to-manage-database-account.md)
35+
* [Global distribution](distribute-data-globally.md)
36+
* [Consistency levels](consistency-levels.md)
37+
* [Working with Azure Cosmos containers and items](databases-containers-items.md)
38+
* [VNET service endpoint for your Azure Cosmos account](firewall-support.md)
39+
* [IP-firewall for your Azure Cosmos account](vnet-service-endpoint.md)
40+
* [How-to add and remove Azure regions to your Azure Cosmos account](how-to-manage-database-account.md)
41+
* [Azure Cosmos DB SLAs](https://azure.microsoft.com/en-us/support/legal/sla/cosmos-db/v1_2/)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: How to use Azure Cosmos DB change feed with Azure Functions
3+
description: Use Azure Cosmos DB change feed with Azure Functions
4+
author: rimman
5+
6+
ms.service: cosmos-db
7+
ms.topic: conceptual
8+
ms.date: 11/06/2018
9+
ms.author: rimman
10+
11+
---
12+
# How to use Azure Cosmos DB change feed with Azure Functions
13+
14+
If you're using Azure Functions, the simplest way to connect to change feed is to add an [Azure Cosmos DB trigger](../azure-functions/functions-bindings-cosmosdb-v2.md#trigger) to your Azure Functions app. When you create a Cosmos DB trigger in an Azure Functions app, you select the Cosmos container to connect to and the function is triggered whenever you change something in the container.
15+
16+
Triggers can be created in the Azure Functions portal or in the Azure Cosmos DB portal or programmatically. For more information, see [serverless database computing using Azure Cosmos DB and Azure Functions](serverless-computing-database.md).
17+
18+
## Frequently asked questions
19+
20+
### How can I configure Azure functions to read from a particular region?
21+
22+
It is possible to define the [PreferredLocations](https://docs.microsoft.com/dotnet/api/microsoft.azure.documents.client.connectionpolicy.preferredlocations?view=azure-dotnet#Microsoft_Azure_Documents_Client_ConnectionPolicy_PreferredLocations) when using the Azure Cosmos DB trigger to specify a list of regions. It's same as you customize the ConnectionPolicy, to make the trigger read from your preferred regions. Ideally, you want to read from the closest region where your Azure Functions is deployed.
23+
24+
### What is the default size of batches in Azure Functions?
25+
26+
The default size is 100 items for every invocation of Azure Functions. However, this number is configurable within the function.json file. Here is complete [list of configuration options](../azure-functions/functions-bindings-cosmosdb-v2.md#trigger---configuration). If you are developing locally, update the application settings within the local.settings.json file.
27+
28+
### I am monitoring a container and reading its change feed, however I don't get all the inserted documents, some items are missing?
29+
30+
Make sure that there is no other Azure Function reading the same container with the same lease container. The missing documents are processed by the other Azure Functions that are also using the same lease.
31+
32+
Therefore, if you are creating multiple Azure Functions to read the same change feed, they must use different lease containers or use the "leasePrefix" configuration to share the same container. However, when you use change feed processor library you can start multiple instances of your Azure Function and the SDK will divide the documents between different instances automatically for you.
33+
34+
### Azure Cosmos item is updated every second, and I don't get all the changes in Azure Functions listening to change feed?
35+
36+
Azure Functions polls the change feed for changes continuously, with a maximum default delay of 5 seconds. If there are no pending changes to be read, or if there are changes pending after the trigger is applied, the function will read them right away. However, if there are no pending changes, the function will wait 5 seconds and poll for more changes.
37+
38+
If your document receives multiple changes in the same interval that took the Trigger to poll for new changes, you might receive the latest version of the document and not the intermediate one.
39+
40+
If you want to to poll change feed for less than 5 seconds, for example, for every second, you can configure the polling time "feedPollDelay", see [the complete configuration](https://docs.microsoft.com/dotnet/api/microsoft.azure.documents.client.connectionpolicy.preferredlocations?view=azure-dotnet#Microsoft_Azure_Documents_Client_ConnectionPolicy_PreferredLocations). It is defined in milliseconds with a default of 5000. Polling for less than 1 second is possible but it's not advised because you will start using more CPU memory.
41+
42+
### Can multiple Azure Functions read one container’s change feed?
43+
44+
Yes. Multiple Azure Functions can read the same container’s change feed. However, the Azure Functions needs to have a separate “leaseCollectionPrefix” defined.
45+
46+
### If I am processing change feed by using Azure Functions, in a batch of 10 documents, and I get an error at seventh Document. In that case the last three documents are not processed how can I start processing from the failed document (i.e, seventh document) in my next feed?
47+
48+
To handle the error, the recommended pattern is to wrap your code with try-catch block and, if you are iterating over the list of documents, wrap each iteration in its own try-catch block. Catch the error and put that document on a queue (dead-letter) and then define logic to deal with the documents that produced the error. With this method if you have a 200-document batch, and just one document failed, you do not have to throw away the whole batch.
49+
50+
In case of error, you should not rewind the check point back to beginning else you will can keep getting those documents from change feed. Remember, change feed keeps the last final snap shot of the documents, because of this you may lose the previous snapshot on the document. change feed keeps only one last version of the document, and in between other processes can come and change the document.
51+
52+
As you keep fixing your code, you will soon find no documents on dead-letter queue. Azure Functions is automatically called by change feed system and check point is maintained internally by Azure Function. If you want to roll back the check point and control every aspect of it, you should consider using change feed Processor SDK.
53+
54+
### Are there any extra costs for using the Azure Cosmos DB Trigger?
55+
56+
The Azure Cosmos DB Trigger leverages the Change Feed Processor library internally. As such, it requires an extra collection, called Leases collection, to maintain state and partial checkpoints. This state management is needed to be able to dynamically scale and continue in case you want to stop your Azure Functions and continue processing at a later time. To learn more, see [how to work with change feed processor library](change-feed-processor.md).
57+
58+
## Next steps
59+
60+
You can now proceed to learn more about change feed in the following articles:
61+
62+
* [Overview of change feed](change-feed.md)
63+
* [Ways to read change feed](read-change-feed.md)
64+
* [Using change feed processor library](change-feed-processor.md)
65+
* [How to work with change feed processor library](change-feed-processor.md)
66+
* [Serverless database computing using Azure Cosmos DB and Azure Functions](serverless-computing-database.md)

0 commit comments

Comments
 (0)