Auto-scaling Cosmos DB throughput

In the previous recipe, we read data from the Excel and put it into an employee collection. The next step is to insert the collection into a Cosmos DB collection. However, before inserting the data into the Cosmos DB collection, we need to understand that in real-world scenarios, the number of records that we would need to import would be huge and so you might face performance issues if the capacity of the Cosmos DB collection is not sufficient. 

Cosmos DB collection throughput is measured by the number of Request Units (RU) allocated to the collection. You can read more about it at https://docs.microsoft.com/en-us/azure/cosmos-db/request-units.

Also, in order to lower costs, for every service, it is recommended to have the capacity at a lower level and increase it whenever needed. The Cosmos DB API allows us to control the number of RUs based on our needs. As we need to do a bulk import, we will increase the RUs before we start importing the data. Once the importing process is complete, we can decrease the RUs to the minimum level.