Book Image

Learning Azure DocumentDB

By : Riccardo Becker
Book Image

Learning Azure DocumentDB

By: Riccardo Becker

Overview of this book

Learning DocumentDB adopts a practical, step-by-step approach to help you learn the basics of DocumentDB and use your new-found abilities in real-life scenarios and enterprise solutions. We start with the absolute basics, such as setting up a DocumentDB environment, and guide you through managing your databases, and executing simple and complex queries. Next, we explain how to work with DocumentDB using the open REST protocol, and demonstrate how JavaScript works with DocumentDB. We’ll also show you how to authenticate and execute queries. Moving on, you’ll find out how to use DocumentDB from within Node.js to kick-start your Node.js projects. Next, you’ll discover how to increase the performance of your DocumentDB database and fine-tune it. Finally, you’ll get to grips with using DocumentDB in conjunction with other services offered from the Microsoft Azure platform.
Table of Contents (15 chapters)
Learning Azure DocumentDB
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Managing your keys


As we have seen in Chapter 1, Getting Started with DocumentDB, access to your databases is granted by a combination of the URI to your DocumentDB and a key. In the Azure portal, on the All Settings blade of your database, you can see both your primary and secondary keys. Both keys can be used to access your database. But why are there two keys?

Recycling keys

DocumentDB, like other persistency mechanisms on Azure, such as Table storage, provides two keys. This is because it is good practice to regenerate your keys periodically to keep your connections more secure. The two-key approach enables access to your database with one key while regenerating the other. This way, your application is always online, while the keys are changed on a regular basis. This process is called rolling your keys.

Perform the following steps to roll your keys:

  1. Update all your applications that are using the primary key to use the secondary key.

  2. Regenerate the primary key from the Azure portal.

    Note

    Clicking...