From when ever there is need to rotate access keys to your CosmosDB or any other storage service using Access keys this is the best practis method to do so.
So for CosmosDB these are the steps needed to be used.
- Head into Azure portal and navigate to your CosmosDB and select “keys” from the menu.
- rotate the “Secondary Access key” by selecting the “Regenerate Secondary Key” from the ellipsis menu
- Change the key used within your application to use the newly generated “Secondary Access key“
- Head back to the Azure portal and rotate the “Primary Access key“
After these four steps you have rotated both keys within your services and your application is now running on the secondary key. No need to switch to the primary key at this point.