Managing Databases and Collections with DocumentDB StudioSolution ·
I released the first Beta version of DocumentDB Studio.
DocumentDB Studio is to Azure DocumentDB what SQL Management Studio is to SQL Server and SQL Azure: a one-stop shop to manage and interact with your DocumentDB.
I posted an installation guide of the application (very simple).
In this post I want to walk you through:
- How to connect to a DocumentDB account
- How to create / delete databases in an account
- How to create / delete collections within an account
You need an Azure DocumentDB account to start using DocumentDB Studio.
See my article Creating an Azure DocumentDB account for an easy how-to. I'll assume you created such an account.
Now let's go and retrieve a ??? key.
- Go to the Azure Preview Portal: https://portal.azure.com/
- On the left hand side, select the BROWSE button and then DocumentDB Accounts
- You'll be presented with the list of DocumentDB accounts you own ; select the one you want to work with.
- You will be presented with the account blade. Click the keys button.
- In the keys blade, click the copy button next to the secondary key
DocumentDB accounts come with a primary and secondary. Personally, I always like to give applications the secondary key while keeping the primary for myself. But it's a personal choice, you can use the primary key as well.
Connect to an Account
Now that we have an account and an account key, let's connect to it in Azure DocumentDB Studio.
- Click the Connect button
- In the ID textbox, type the ID (or name) of your Database account, without the entire URL.
- In the Authorization Key, paste the secondary key you copied in the previous section.
You just connected Azure DocumentDB Studio to your database account.
Note that in the folder where you copied the binaries of the solution, a new file has been added: Studio.xml. This file now contains the ID and authorization key of your database account. This is how your connection persists between instances of the studio.
Creating a database
Now, let's create a database.
We'll expand the account tree branch and discover the databases and media. Let's select the databases.
Everywhere in the resource tree, resources are lazy loaded or loaded on demand. In the case of databases, until you select the tree node, databases aren't loaded. Once you select it they are asynchronously loaded.
In our case, there are no databases yet, so let's create one by clicking on the New Database button in the toolbar.
This pops up a dialog to query the ID (or name) of the database. Let's type MyDB and then click OK.
This creates a MyDB database with no collections.
By opening the MyDB tree node and clicking the Collections sub node the New Collection button in the toolbar becomes enabled.
Let's click it to create a collection. Very similar experience to creating a database.
Now if we want to delete the collection we just created, we need to select the collection in the tree view to enable the Remove Collection button in the toolbar.
Similarly, to delete the Database we created, we select the Database in the treeview.
So that was it for the management of databases and collection!