How to autoincrement particular field in Azure CosmosDB with MySQL API

Author: D.Khumoyun

Originally Sourced from:

I need to implement an autoincrement functionality in Azure CosmosDB or using Node.js. I need to increment particular field every time item is inserted as it is done in PostgreSQL serial column type. This method should be reliable.

Let's say if we several requests are sent at once, there should not be situation where method generated the same number twice.

Thanks beforehands.