Creating and Querying Microsoft Azure

Download Report

Transcript Creating and Querying Microsoft Azure

International TechNet Wiki Summit
2015
Creating and Querying Microsoft Azure DocumentDB
Chervine Bhiwoo
Meet Chervine | @chervinebhiwoo
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/
2
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
1. Articles about Microsoft Azure
1.
http://social.technet.microsoft.com/wiki/contents/articles/tags/Microsoft+Azure/
default.aspx
2. Creating and Querying Microsoft Azure DocumentDB
1.
http://social.technet.microsoft.com/wiki/contents/articles/29717.usingmicrosoft-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.usingmicrosoft-azure-documentdb-in-an-asp-net-mvc-application.aspx
4. Other articles by Chervine
1.
4
http://social.technet.microsoft.com/wiki/contents/articles/tags/Chervine/default.
aspx
Why..?
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
Applications load balance varies rapidly and application should be able to adapt
5
What is Azure DocumentDB?
It is a fully managed, highly scalable, queryable, schemafree document database, delivered as a service, for
modern applications.
6
What is DocumentDB?
Query against Schema-Free JSON
Multi-Document transactions
Tunable, High Performance
Designed for cloud first
7
Azure DocumentDB Resources
Source: http://azure.microsoft.com/en-us/documentation/articles/documentdb-introduction/
8
The DocumentDB Data Model
All data is stored in JSON Documents
Object created in code
Object saved in Database
9
Demo: Creating a DocumentDB
Account
From the preview portal
(https://portal.azure.com),
click on New > Data +
Storage > DocumentDB, fill in
the required information and
click create.
1
0
Demo: Querying DocumentDB (1)
A document collection is a named logical
container for documents.
Provides a client-side logical representation of the
Azure DocumentDB service
The method CreateOrGetCollection
returns the collections if it already exists,
else it will create the collection.
Create an
instance of
DocumentClient
The method
CreateOrGetDatabase check
if the database already exists,
if not, it will create it and
return an instance of the
database
11
Create a
DocumentDB
Database
Create a
Document
Collection
To save documents, the
method
CreateDocumentAsync is
used which creates a
document as an
asynchronous operation.
Create & Save
Documents
Demo: Querying DocumentDB (2)
Both SQL and LINQ can be used to retrieve data from
DocummentDB using the CreateDocumentQuery
method.
Query
Documents
Update
Documents
You first need to get the document to update, make
the changes and replace the document using the
ReplaceDocumentAsync mthod
12
Get the required document and delete it using the
DeleteDocumentAsync method
Delete
Documents
Demo: Azure DocumentDB and
ASP.NET MVC Application (1)
Application Architecture and Flow
Request
Model
13
Controller
DocumentDB
Repository
View
Azure
DocumentDB
Demo: Azure DocumentDB and
ASP.NET MVC Application (2)
The DocumentDB Repository Flow
Instantiate
DocumentClient
Provides a client-side
logical representation of
the Azure DocumentDB
service.
14
Get Database
The Method
ReadOrCreateDatabase
will create the database
if it does not exist
Get Collection
The Method
ReadOrCreateCollection
will create the collection
if it does not exist
Do CRUD
Operations
After getting the
database and collection,
Create, Read, Update
and Delete operations
can be done.
Gallery Download
1.
Creating and Querying Microsoft Azure DocumentDB
1.
2.
Using Microsoft Azure DocumentDB in an ASP.NET MVC
Application
1.
15
Gallery Download: https://gallery.technet.microsoft.com/Querying-Azure-DocumentDB-d12e7e39
Gallery Download:
https://gallery.technet.microsoft.com/Using-Azure-DocumentDB-in-738b277d
Thank You!
16