16
International TechNet Wiki Summit 2015 Creating and Querying Microsoft Azure DocumentDB Chervine Bhiwoo

2015 International TechNet Wiki Summit 2015 Creating and Querying Microsoft Azure DocumentDB Chervine Bhiwoo

Embed Size (px)

Citation preview

International TechNet Wiki Summit2015

Creating and Querying Microsoft Azure DocumentDB

Chervine Bhiwoo

Meet Chervine | @chervinebhiwoo

2

Software Developer

From Mauritius – Indian Ocean - Africa

Works mainly on Microsoft Technologies such as C# and ASP.NET.

Also has a good knowledge on BI, Data- warehousing, MS Azure and Windows Phone

http://chervinebhiwoo.blogspot.com/

In this session

• TechNet Wiki• Why DocumentDB..?• Introduction to Azure DocumentDB• Creating a DocumentDB Account• Storing & Querying Data• Using Azure DocumentDB in as ASP.NET MVC

Application• Code Samples on Gallery

3

TechNet Wiki

4

1. Articles about Microsoft Azure1. http://social.technet.microsoft.com/wiki/contents/articles/tags/Microsof

t+Azure/default.aspx

2. Creating and Querying Microsoft Azure DocumentDB

1. http://social.technet.microsoft.com/wiki/contents/articles/29717.using-microsoft-azure-documentdb-in-an-asp-net-mvc-application.aspx

3. Using Microsoft Azure DocumentDB in an ASP.NET MVC Application

1. http://social.technet.microsoft.com/wiki/contents/articles/29717.using-microsoft-azure-documentdb-in-an-asp-net-mvc-application.aspx

4. Other articles by Chervine1. http://social.technet.microsoft.com/wiki/contents/articles/tags/Chervin

e/default.aspx

Why..?

Applications load balance varies rapidly and application should be able to adapt

5

Modern Applications produce and consume incredibly high volume of data

Users today expects near instantaneous response times

Applications Database models are no longer fixed and evolve continuously

What is Azure DocumentDB?

It is a fully managed, highly scalable, queryable, schema-free document database, delivered as a service, for modern applications.

6

What is DocumentDB?

7

Query against Schema-Free JSON

Multi-Document transactions

Tunable, High Performance

Designed for cloud first

Azure DocumentDB Resources

8

Source: http://azure.microsoft.com/en-us/documentation/articles/documentdb-introduction/

The DocumentDB Data Model

9

All data is stored in JSON Documents

Object created in code

Object saved in Database

Demo: Creating a DocumentDB Account

10

From the preview portal (https://portal.azure.com), click on New > Data + Storage > DocumentDB, fill in the required information and click create.

Demo: Querying DocumentDB (1)

11

Create an instance

of DocumentClient

Create a Documen

tDB Database

Create a Docume

nt Collectio

n

Create & Save Docum

ents

Provides a client-side logical representation of the Azure DocumentDB service

The method CreateOrGetDatabase check if the database already exists, if not, it will create it and return an instance of the database

A document collection is a named logical container for documents. 

The method CreateOrGetCollection returns the collections if it already exists, else it will create the collection.

To save documents, the method CreateDocumentAsync is used which creates a document as an asynchronous operation.

Demo: Querying DocumentDB (2)

12

Query Documen

ts

Update Documen

ts

Delete Documen

ts

Both SQL and LINQ can be used to retrieve data from DocummentDB using the CreateDocumentQuery method.

You first need to get the document to update, make the changes and replace the document using the ReplaceDocumentAsync mthod

Get the required document and delete it using the DeleteDocumentAsync method

Demo: Azure DocumentDB and ASP.NET MVC Application (1)

13

Request Controller

Model View

DocumentDB Repository

Azure DocumentDB

Application Architecture and Flow

Demo: Azure DocumentDB and ASP.NET MVC Application (2)

14

Instantiate

DocumentClient

Get Database

Get Collection

Do CRUD

Operations

Provides a client-side logical representation of the Azure DocumentDB service. 

The Method ReadOrCreateDatabase will create the database if it does not exist

The Method ReadOrCreateCollectionwill create the collection if it does not exist

After getting the database and collection, Create, Read, Update and Delete operations can be done.

The DocumentDB Repository Flow

Gallery Download

15

1. Creating and Querying Microsoft Azure DocumentDB1. Gallery Download: https://

gallery.technet.microsoft.com/Querying-Azure-DocumentDB-d12e7e39

2. Using Microsoft Azure DocumentDB in an ASP.NET MVC Application

1. Gallery Download: https://gallery.technet.microsoft.com/Using-Azure-DocumentDB-in-738b277d

16

Thank You!