Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confused about DocumentDB Access Keys

In the Azure Portal under DocumentDB, I see two access keys i.e. primary and secondary.

Which one should I use calling DocumentDB from my app or should I create a new user account?

like image 718
Sam Avatar asked Feb 21 '26 18:02

Sam


1 Answers

You can use either key to call DocumentDB from your app.

The users feature is generally used for granting permissions to specific resources (collections, documents, etc) - which may be useful in multi-tenant scenarios.

So why does DocumentDB have two access keys? It’s for rolling key changes. If you want to change the key (which is probably a good idea to do every once in a while in case it gets leaked somehow), you would have some downtime if there was only one key available (the time it takes between changing the key and updating your application configuration to reflect that). With two keys, you can first update your configuration file to use the secondary key, then regenerate the primary key and update your application’s configuration to use that – with no downtime!

like image 69
Andrew Liu Avatar answered Feb 23 '26 14:02

Andrew Liu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!