Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 8.87 KB

documentdb-create-collection.md

File metadata and controls

79 lines (57 loc) · 8.87 KB
title description services author manager editor documentationcenter ms.assetid ms.service ms.workload ms.tgt_pltfrm ms.devlang ms.topic ms.date ms.author
Create a DocumentDB database and collection | Microsoft Docs
Learn how to create NoSQL databases and JSON document collections using the online service portal for Azure DocumentDB, a cloud based document database. Get a free trial today.
documentdb
mimig1
jhubbard
monicar
b81ad2f6-df7f-4c6d-8ca9-f8a9982d647e
documentdb
data-services
na
na
article
12/13/2016
mimig

How to create a DocumentDB collection and database using the Azure portal

To use Microsoft Azure DocumentDB, you must have a DocumentDB account, a database, a collection, and documents. This topic describes how to create a DocumentDB collection in the Azure portal.

Not sure what a collection is? See What is a DocumentDB collection?

  1. In the Azure portal, in the Jumpbar, click DocumentDB (NoSQL), and then in the DocumentDB (NoSQL) blade, select the account in which to add a collection. If you don't have any accounts listed, you'll need to create a DocumentDB account.

    Screen shot highlighting the DocumentDB Accounts in the Jumpbar, the account in the DocumentDB Accounts blade, and the database in the DocumentDB account blade, in the Databases lens

    If DocumentDB (NoSQL) is not visible in the Jumpbar, click More Services and then click DocumentDB (NoSQL). If you don't have any accounts listed, you'll need to create a DocumentDB account.

  2. In the DocumentDB account blade for the selected account, click Add Collection.

    Screen shot highlighting the DocumentDB Accounts in the Jumpbar, the account in the DocumentDB Accounts blade, and the database in the DocumentDB account blade, in the Databases lens

  3. In the Add Collection blade, in the ID box, enter the ID for your new collection. Collection names must be between 1 and 255 characters, and cannot contain / \ # ? or a trailing space. When the name is validated, a green check mark appears in the ID box.

    Screen shot highlighting the Add Collection button on the Database blade, the settings on the Add Collection blade, and the OK button - Azure portal for DocumentDB - Cloud based database creator for NoSQL JSON databases

  4. By default, Pricing Tier is set to Standard so that you can customize the throughput and storage for your collection. For more information about the pricing tier, see Performance levels in DocumentDB.

  5. Select a Partitioning mode for the collection, either Single Partition or Partitioned.

    A single partition has a reserved storage capacity of 10GB, and can have throughput levels from 400-10,000 request units/second (RU/s). One RU corresponds to the throughput of a read of a 1KB document. For more information about request units, see Request units.

    A partitioned collection can scale to handle an unlimited amount of storage over multiple partitions, and can have throughput levels starting at 10,100 RU/s. For more informaiton about partitioned collections, see Single Partition and Partitioned Collections.

    By default, the throughput for a new single partition collection is set to 1000 RU/s with a storage capacity of 10 GB. For a partitioned collection, the collection throughput is set to 10100 RU/s with no upper limit on capacity or throughput.

  6. If you are creating a partitioned collection, select the Partition Key for the collection. Selecting the correct partition key is important in creating a performant collection. For more information on selecting a partition key, see Designing for partitioning.

  7. In the Database blade, either create a new database or use an existing one. Database names must be between 1 and 255 characters, and cannot contain / \ # ? or a trailing space. To validate the name, click outside the text box. When the name is validated, a green check mark appears in the box.

  8. Click OK at the bottom of the screen to create the new collection.

  9. The new collection now appears in the Collections lens on the Overview blade.

    Screen shot of the new collection in the Database blade - Azure portal for DocumentDB - Cloud based database creator for NoSQL JSON databases

  10. Optional: To modify the throughput of collection in the portal, click Scale on the Resource menu.

    Screen shot of the resource menu, with Scale selected

What is a DocumentDB collection?

A collection is a container of JSON documents and the associated JavaScript application logic. A collection is a billable entity, where the cost is determined by the provisioned throughput of the collection. Collections can span one or more partitions/servers and can scale to handle practically unlimited volumes of storage or throughput.

Collections are automatically partitioned into one or more physical servers by DocumentDB. When you create a collection, you can specify the provisioned throughput in terms of request units per second and a partition key property. The value of this property will be used by DocumentDB to distribute documents among partitions and route requests like queries. The partition key value also acts as the transaction boundary for stored procedures and triggers. Each collection has a reserved amount of throughput specific to that collection, which is not shared with other collections in the same account. Therefore, you can scale out your application both in terms of storage and throughput.

Collections are not the same as tables in relational databases. Collections do not enforce schema, in fact DocumentDB does not enforce any schemas, it's a schema-free database. Therefore you can store different types of documents with diverse schemas in the same collection. You can choose to use collections to store objects of a single type like you would with tables. The best model depends only on how the data appears together in queries and transactions.

Other ways to create a DocumentDB collection

Collections do not have to be created using the portal, you can also create them using the DocumentDB SDKs and the REST API.

Troubleshooting

If Add Collection is disabled in the Azure portal, that means your account is currently disabled, which normally occurs when all the benefits credits for the month are used.

Next steps

Now that you have a collection, the next step is to add documents or import documents into the collection. When it comes to adding documents to a collection, you have a few choices:

  • You can add documents by using the Document Explorer in the portal.
  • You can import documents and data by using the DocumentDB Data Migration Tool, which enables you to import JSON and CSV files, as well as data from SQL Server, MongoDB, Azure Table storage, and other DocumentDB collections.
  • Or you can add documents by using one of the DocumentDB SDKs. DocumentDB has .NET, Java, Python, Node.js, and JavaScript API SDKs. For C# code samples showing how to work with documents by using the DocumentDB .NET SDK, see the C# document samples. For Node.js code samples showing how to work with documents by using the DocumentDB Node.js SDK, see the Node.js document samples.

After you have documents in a collection, you can use DocumentDB SQL to execute queries against your documents by using the Query Explorer in the portal, the REST API, or one of the SDKs.