To build a database with Microsoft Azure DocumentDB, you must:
- Have an Azure account. You can get a free Azure account if you don't have one already.
- Create a DocumentDB account.
You can create a DocumentDB account using either the Azure portal, Azure Resource Manager templates, or Azure command-line interface (CLI). This article shows how to create a DocumentDB account using the Azure portal. To create an account using Azure Resource Manager or Azure CLI, see Automate DocumentDB database account creation.
Are you new to DocumentDB? Watch this four-minute video by Scott Hanselman to see how to complete the most common tasks in the online portal.
- Sign in to the Azure portal.
On the left navigation, click New, click Databases, and then click NoSQL (DocumentDB).
In the New account blade, specify the desired configuration for the DocumentDB account.
- In the ID box, enter a name to identify the DocumentDB account. When the ID is validated, a green check mark appears in the ID box. The ID value becomes the host name within the URI. The ID may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. Note that documents.azure.com is appended to the endpoint name you choose, the result of which becomes your DocumentDB account endpoint.
In the NoSQL API box, select the programming model to use:
- MongoDB: DocumentDB also offers protocol-level support for MongoDB APIs. When you choose the MongoDB API option, you can use existing MongoDB SDKs and tools to talk to DocumentDB. You can move your existing MongoDB apps to use DocumentDB, with no code changes needed, and take advantage of a fully managed database as a service, with limitless scale, global replication, and other capabilities.
- For Subscription, select the Azure subscription that you want to use for the DocumentDB account. If your account has only one subscription, that account is selected by default.
- In Resource Group, select or create a resource group for your DocumentDB account. By default, a new resource group is created. For more information, see Using the Azure portal to manage your Azure resources.
- Use Location to specify the geographic location in which to host your DocumentDB account.
Once the new DocumentDB account options are configured, click Create. To check the status of the deployment, check the Notifications hub.
After the DocumentDB account is created, it is ready for use with the default settings. The default consistency of the DocumentDB account is set to Session. You can adjust the default consistency by clicking Default Consistency in the resource menu. To learn more about the consistency levels offered by DocumentDB, see Consistency levels in DocumentDB.
Now that you have a DocumentDB account, the next step is to create a DocumentDB collection and database.
You can create a new collection and database by using one of the following:
- The Azure portal, as described in Create a DocumentDB collection using the Azure portal.
- The all-inclusive tutorials, which include sample data: .NET, .NET MVC, Java, Node.js, or Python.
- The .NET, Node.js, or Python sample code available in GitHub.
- The .NET, .NET Core, Node.js, Java, Python, and REST SDKs.
After creating your database and collection, you need to add documents to the collections.
After you have documents in a collection, you can use DocumentDB SQL to execute queries against your documents. You can execute queries by using the Query Explorer in the portal, the REST API, or one of the SDKs.
To learn more about DocumentDB, explore these resources: