It is supporting all SDK platforms. It uses standard HTTPS port and Single DNS endpoint. Gateway mode is best choice for secure connection. Gateway mode requests create by client are routed to a server and send requests to the appropriate partitions in AzureCosmosDB backend.
Protocol – TCP: CosmosDB Port :443
Connection Protocol- HTTPS: Default 443
It is supporting on .NET and Java SDK. This mode provides selection between TCP or HTTPs.
Direct mode is based on condition the route that data plan request and document read and writes, take from client machine to partitions in Azure CosmosDB backend and send request directly.
Protocol – TCP: CosmosDB Port :443 , different port range between 10000 to 20000
Connection Protocol- HTTPS: Default 443
Optimistic Concurrency Control allows to prevent lost updates and delete. Every item stored in container has “_etag” property. “_etag” value automatically generated and updated when document update. “_etag” value if match request header is no longer current “_etag” value then server rejects and throw error. By using “_etag” we can prevent lost of changes if request comes in single time. This is reapplying updates and retry the original request.
Below are few practical implementation tips / best practices :
Bulk executor supports bulk import, update and delete operations. It is consuming more Rus in Upsert queries. It is supporting in .NET Core API.
Bulk executors create batches and all operations in group and upset records in containers. A loop will go through documents to be imported by partition and the partition range id will be used to get the list of documents to import by partition.
CosmosDB provides continuation token to fetch number data from container. We can say if we want apply paging then we need to use Continuation token. It is used to recreate the state of index and track progress of execution.
Query result will be dividing in multiple pages. We can “MaxItemCount” to -1 if we want to fetch all data from container. We can set number of records in “MaxItemCount” which we want to fetch from container.
Continuation Token works on query which we pass, it will return combined object of multiple value as a Continuation Token. One thing we need to understand whatever we received from continuation token we need to pass exact value to fetch next page data from container.
you can manage continuation tokens with the x-ms-continuation header. You cannot use it for queries like GROUPBY.
Continuation token look like
{\”token\”:\”+RID:qqhuAMREDACTEDAAAAAAA==REDACTED:AQwAAAAAAAAAEwAAAAAAAAA=\”,\”range\”:{\”min\”:\”\”,\”max\”:\”FF\”}}
This all values are not fixed; token value can change in length also new values like range or any other can come. Continuation token format is not fixed we only need to pass whatever we have received from previous request.
To put in nutshell, Azure CosmosDB provides variety of advantages for better performance of services and cost effective. We need to take care some points white integrating CosmosDB