SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Azure DocumentDB 
Neil Mackenzie 
Satory Global , LLC
Who Am I 
• Neil Mackenzie 
• Azure Lead –Satory Global 
• @mknz 
• http://convective.wordpress.com 
• Author: Microsoft Windows Azure Development Cookbook 
• Microsoft MVP for Azure
Agenda 
• DocumentDB Overview 
• .NET Development
DOCUMENTDB 
OVERVIEW
Core Features 
• Schema-less, NoSQL document database 
• Fully managed, with provisioned capacity 
• Stored entities are JSON documents 
• Tunable consistency 
• Designed to scale into petabytes
Microsoft Databases in Azure 
• Relational 
• SQL Database (PaaS) 
• SQL Server (IaaS) 
• NoSQL 
• Azure Tables – key-value store 
• Azure DocumentDB – document database
Resource Model 
• Database Account 
• Database 
• Collection 
• Document 
• Attachment 
• Stored Procedure 
• Trigger 
• User-defined functions 
• User 
• Permission 
• Media
Resource Addressing 
• Core interface to DocumentDB is RESTful 
• Each resource has a permanent unique ID 
• API URL: 
• https://{database account}.documents.azure.com 
• Document Path: 
• /dbs/{database id}/colls/{collection id}/docs/{document id} 
• Example full URL for a document: 
• https://lochinver.documents.azure.com/dbs/ju1TAA==/colls/ju1TAPhIFAA=/docs/ju1TAP 
hIFAAJAAAAAAAAAA==
Operations 
• For each resource: 
• Create 
• Replace 
• Delete 
• Read 
• Query 
• Read is a GET Operation on a specified resource ID, returning a single resource. 
• Query is a POST operation on a collection with a request body containing 
DocumentDB SQL text, returning a possible empty collection of resources. 
• Query can filter only on indexed properties
DocumentDB SQL 
• SELECT <select-list> FROM <from-specification> WHERE <filter-condition> 
• Similar to normal SQL 
• Only self-join supported 
• Ability to reach into JSON tree to: 
• Access values for filter condition 
• Shape select list 
• User-defined functions 
• LINQ-to-SQL support for .NET
Consistency Levels 
• Default configured for database account, overridable (down) at request level. 
• Strong – write only visible after quorum commit. Quorum reads. 
• Bounded Staleness – write order guaranteed. Quorum reads may be behind by a 
specified number of operations (or time in seconds). 
• Session – write-order guaranteed within a client session. Reads are up-to-date 
within the session. “Usually sufficient.” (Default for a new database account) 
• Eventual – reads may be out of sequence.
Indexing Policy 
• Specified at the collection level 
• Automatic indexing 
• By default all properties indexed automatically. This is tunable for individual documents 
and paths within a document – either inclusion or exclusion of a path 
• Index precision can be specified for strings and numbers 
• Indexing mode 
• Consistent – By default indexes synchronously updated on insert, replace or delete 
• Lazy – asynchronous index update (targeted at bulk ingestion)
Performance 
• Capacity Unit 
• Specified amount of storage capacity and operational throughput 
• Collection quota per capacity unit 
• Provisioning unit for scaleout for both performance and storage 
• Configured at the database account level 
• Sharable among all databases and collections in the database account 
• Preview limit is 10GB, 3 collections per capacity unit 
• Storage is SSD backed 
• Microsoft has used databases with terabytes of storage (designed for petabytes)
Performance – Scalability Targets 
• Assumptions: 
• 1KB document with 10 properties 
• Session consistency level 
• Automatic indexing 
Database Operation Operations / second (Request units) 
Read 1 document 2000 
Insert, replace, update 1 document 500 
Simple query (returning 1 document) 1000 
Stored procedure with 50 inserts 20 
• Requests throttled if consumption exceeds overall capacity unit target
Stored Procedures,Triggers and UDFs 
• DocumentDB supports server-side JavaScript 
• Stored Procedures: 
• Registered at collection level 
• Operate on any document in the collection 
• Invoked inside transaction context on primary replica 
• Triggers: 
• Pre- or Post: create, replace or delete operations 
• Invoked inside transaction context on primary replica 
• User-Defined Functions 
• Scalar functions invoked only inside queries
Libraries 
• .NET API 
• Node.js 
• JavaScript client 
• JavaScript server 
• Python
Preview 
• Azure DocumentDB available in: 
• West US 
• North Europe 
• West Europe 
• Price: $0.73 /day, $22.50 / month – includes 50% preview discount
Management 
• DocumentDB is supported only in the new portal 
• Manage database account, collections, users, etc. 
• View consumption statistics 
• https://portal.azure.com 
• API support to manage DocumentDB resources 
• Be aware of limits: 
• e.g., 3 collections per database account
.NET DEVELOPMENT
RESTful API 
• Core interface to DocumentDB 
• Used by all client libraries 
• Standard operations against all DocumentDB resources: 
• CREATE, DELETE, PUT, GET, POST 
• Returns permanent resource URL on creation 
• HMAC authentication using management or resource key 
• DocumentDB request headers
Download 
• .NET API hosted on NuGet 
• Install-Package Microsoft.Azure.Documents.Client –Pre 
• Installs DocumentDB and JSON.NET packages
Class: DocumentClient 
• Constructed with endpoint URL and management key for Database account 
• Provides async/await methods for CRUD operations on DocumentDB resources 
• Manages the connection to DocumentDB 
// Create DocumentClient 
String documentDbAddress = 
"https://{account}.documents.azure.com"; 
String authorizationKey = "key=="; 
Uri documentDbUri = new Uri(documentDbAddress); 
DocumentClient documentClient = 
new DocumentClient(documentDbUri, authorizationKey);
Class: Resource 
• Base class for all DocumentDB resource classes 
• Exposes: 
• ETag - used for optimistic concurrency 
• SelfLink – URL path for resource 
• ResourceID – internal ID (base64 encoded) for resource 
• ID – ID of the resource, either provided or generated
Class: Database 
• Derived from Resource 
• Adds properties exposing collections and users 
// Create database 
Database database = new Database { Id = databaseId }; 
ResourceResponse<Database> response = await 
documentClient.CreateDatabaseAsync(database); 
database = response; 
String selfLink = database.SelfLink; 
String collections = database.CollectionsLink; 
String users = database.UsersLink;
Class: DocumentCollection 
• Derived from Resource 
• Adds properties exposing DocumentsLink, StoredProceduresLink, TriggersLink, 
UserDefinedFunctionsLink 
// Create document collection 
DocumentCollection documentCollection = 
new DocumentCollection { Id = "SomeId" }; 
ResourceResponse<DocumentCollection> response = await 
documentClient.CreateDocumentCollectionAsync( 
database.SelfLink, documentCollection); 
documentCollection = response;
Data Model 
• Uses JSON.NET library for serialization 
• Simple class 
• No special base class 
• All public properties are serialized into JSON 
• Obvious mapping from.NET to JSON 
• IList, etc. -> Array 
• Int32, etc. -> Integer 
• Float, etc. -> Float 
• DateTime -> String 
• Byte[] -> String
Class: Document 
• Derived from Resource 
• Adds property exposing AttachmentsLink 
// Insert document 
ResourceResponse<Document> response = await 
documentClient.CreateDocumentAsync( 
documentCollection.SelfLink, someDocumentEntity); 
Document document = response;
Class: ResourceResponse<T> 
• Encapsulates the response from a DocumentDB resource operation 
• Provides resource-dependent quota and usage information 
• Contains the response headers including HTTP StatusCode 
• Implicitly exposes the typed resource from the response
Read 
• A Read operation returns a single document. 
ResourceResponse<Document> response = 
await documentClient.ReadDocumentAsync(documentLink); 
Album album = 
JsonConvert.DeserializeObject<Album>(response.Resource.ToString());
Delete 
Album album = new Album() { 
AlbumName = "Let It Bleed", 
BandName = "Rolling Stones", 
ReleaseYear = "1969“ 
}; 
Document document = await 
documentClient.CreateDocumentAsync( 
documentCollection.SelfLink, album); 
ResourceResponse<Document> secondResponse = await 
documentClient.DeleteDocumentAsync( 
document.SelfLink);
Replace 
dynamic readResponse = await 
documentClient.ReadDocumentAsync(documentLink); 
RequestOptions requestOptions = new RequestOptions() { 
AccessCondition = new AccessCondition() { 
Type = AccessConditionType.IfMatch, 
Condition = readResponse.Resource.ETag 
} 
}; 
Album album = (Album)readResponse.Resource; 
album.ReleaseYear = "1990"; 
ResourceResponse<Document> replaceResponse = await 
documentClient.ReplaceDocumentAsync( 
documentLink, album, requestOptions);
Read From a Feed 
• The .NET API can return all the resources in a collection as a paged “feed.” 
String continuation = String.Empty; 
Do { 
FeedOptions feedOptions = new FeedOptions { 
MaxItemCount = 10, 
RequestContinuation = continuation 
}; 
FeedResponse<dynamic> response = await 
documentClient.ReadDocumentFeedAsync( 
documentCollectionLink, feedOptions); 
continuation = response.ResponseContinuation; 
} while (!String.IsNullOrEmpty(continuation));
DocumentDB Queries 
• DocumentDB supports queries at all resource levels, including: 
• Database, DocumentCollection, and Document 
• .NET API supports the following types of queries 
• SQL 
• LINQ SQL 
• LINQ Lambda 
• The DocumentQueryable class exposes helper extension methods to create 
various types of query
SQL Query 
foreach (var album in documentClient.CreateDocumentQuery<Album>( 
documentCollection.SelfLink, 
"SELECT * FROM albums a WHERE a.bandName = 'Radiohead'")) { 
Console.WriteLine("Album name: {0}", album.AlbumName); 
} 
Note that albums is the name of the DocumentDB collection
LINQ Query 
IQueryable<Album> albums = 
from a in documentClient.CreateDocumentQuery<Album>( 
documentCollection.SelfLink) 
where a.BandName == "Radiohead" 
select a; 
foreach (var album in albums) { 
Console.WriteLine("Album name: {0}", album.AlbumName) 
}
LINQ LambaWith Paging 
FeedOptions feedOptions = new FeedOptions() { 
MaxItemCount = 10 
}; 
var query = documentClient.CreateDocumentQuery<Album>( 
documentCollection.SelfLink, feedOptions) 
.Where(a => a.BandName == "Radiohead") 
.AsDocumentQuery(); 
do { 
foreach (Album album in await query.ExecuteNextAsync()) { 
Console.WriteLine("Album name: {0}", album.AlbumName); 
} 
} while (query.HasMoreResults);
Summary 
• Azure DocumentDB Preview 
• Fully managed document database storing JSON entities 
• High scale and performance 
• Wide variety of client libraries 
• .NET, Node.js, JavaScript, python 
• Supported only in the new Azure portal
Resources 
• Documentation: 
• http://documentdb.com 
• Azure Portal 
• http://portal.azure.com 
• Channel 9 Show on DocumentDB 
• http://channel9.msdn.com/Shows/Data-Exposed/Introduction-to-Azure-DocumentDB

Weitere ähnliche Inhalte

Was ist angesagt?

Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMohan Rathour
 
Session #2, tech session: Build realtime search by Sylvain Utard from Algolia
Session #2, tech session: Build realtime search by Sylvain Utard from AlgoliaSession #2, tech session: Build realtime search by Sylvain Utard from Algolia
Session #2, tech session: Build realtime search by Sylvain Utard from AlgoliaSaaS Is Beautiful
 
The CIOs Guide to NoSQL
The CIOs Guide to NoSQLThe CIOs Guide to NoSQL
The CIOs Guide to NoSQLDATAVERSITY
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBLee Theobald
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)Uwe Printz
 
Azure document db/Cosmos DB
Azure document db/Cosmos DBAzure document db/Cosmos DB
Azure document db/Cosmos DBMohit Chhabra
 
NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and UsesSuvradeep Rudra
 
Azure CosmosDB the new frontier of big data and nosql
Azure CosmosDB the new frontier of big data and nosqlAzure CosmosDB the new frontier of big data and nosql
Azure CosmosDB the new frontier of big data and nosqlRiccardo Cappello
 

Was ist angesagt? (20)

Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorial
 
Session #2, tech session: Build realtime search by Sylvain Utard from Algolia
Session #2, tech session: Build realtime search by Sylvain Utard from AlgoliaSession #2, tech session: Build realtime search by Sylvain Utard from Algolia
Session #2, tech session: Build realtime search by Sylvain Utard from Algolia
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
The CIOs Guide to NoSQL
The CIOs Guide to NoSQLThe CIOs Guide to NoSQL
The CIOs Guide to NoSQL
 
CouchDB
CouchDBCouchDB
CouchDB
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)
 
Apache CouchDB
Apache CouchDBApache CouchDB
Apache CouchDB
 
Mongo db
Mongo dbMongo db
Mongo db
 
Azure document db/Cosmos DB
Azure document db/Cosmos DBAzure document db/Cosmos DB
Azure document db/Cosmos DB
 
NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and Uses
 
Azure CosmosDB the new frontier of big data and nosql
Azure CosmosDB the new frontier of big data and nosqlAzure CosmosDB the new frontier of big data and nosql
Azure CosmosDB the new frontier of big data and nosql
 
Couch db
Couch dbCouch db
Couch db
 
Introduction to RavenDB
Introduction to RavenDBIntroduction to RavenDB
Introduction to RavenDB
 
NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
 
RavenDB Overview
RavenDB OverviewRavenDB Overview
RavenDB Overview
 
Azure CosmosDb
Azure CosmosDbAzure CosmosDb
Azure CosmosDb
 
Mongo db
Mongo dbMongo db
Mongo db
 
Introduction to datomic
Introduction to datomicIntroduction to datomic
Introduction to datomic
 

Andere mochten auch

Introduction to DocumentDB
Introduction to DocumentDBIntroduction to DocumentDB
Introduction to DocumentDBTakekazu Omi
 
今から始めるDocument db
今から始めるDocument db今から始めるDocument db
今から始めるDocument dbKazunori Hamamoto
 
Azure DocumentDB en Dev@Nights
Azure DocumentDB en Dev@NightsAzure DocumentDB en Dev@Nights
Azure DocumentDB en Dev@NightsMatias Quaranta
 
Introducing DocumentDB
Introducing DocumentDB Introducing DocumentDB
Introducing DocumentDB James Serra
 
[GAB2016] Azure DocumentDB - Jean-Luc Boucho
[GAB2016] Azure DocumentDB - Jean-Luc Boucho[GAB2016] Azure DocumentDB - Jean-Luc Boucho
[GAB2016] Azure DocumentDB - Jean-Luc BouchoCellenza
 
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...Andrew Liu
 
実プロジェクトの経験から学ぶazureサービス適用パターン
実プロジェクトの経験から学ぶazureサービス適用パターン実プロジェクトの経験から学ぶazureサービス適用パターン
実プロジェクトの経験から学ぶazureサービス適用パターンKuniteru Asami
 
Logic Apps と Api Apps の話
Logic Apps と Api Apps の話Logic Apps と Api Apps の話
Logic Apps と Api Apps の話Sunao Tomita
 
20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道
20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道
20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道Osamu Takazoe
 
Prevención Trabajo oficina
Prevención Trabajo oficinaPrevención Trabajo oficina
Prevención Trabajo oficinaaghconsultoria
 
0 blog pilpres 2014 jokowi 18092014 oke selesai
0 blog pilpres 2014 jokowi 18092014 oke selesai0 blog pilpres 2014 jokowi 18092014 oke selesai
0 blog pilpres 2014 jokowi 18092014 oke selesaiteguh.qi
 
El escultor Ignacio López y el Nazareno de El Puerto
El escultor Ignacio López y el Nazareno de El PuertoEl escultor Ignacio López y el Nazareno de El Puerto
El escultor Ignacio López y el Nazareno de El PuertoJOSE MANUEL MORENO
 
Viva Almería (Manolo Escobar)
Viva Almería (Manolo Escobar)Viva Almería (Manolo Escobar)
Viva Almería (Manolo Escobar)Sonialeta15
 
2014 12 31_icv_bulletin_december_2014_short
2014 12 31_icv_bulletin_december_2014_short2014 12 31_icv_bulletin_december_2014_short
2014 12 31_icv_bulletin_december_2014_shortICV_eV
 
R-Style Lab Mobile Portfolio
R-Style Lab Mobile PortfolioR-Style Lab Mobile Portfolio
R-Style Lab Mobile Portfolioahardziyenka
 
Figempa notas segundo hemisemestre
Figempa notas segundo hemisemestreFigempa notas segundo hemisemestre
Figempa notas segundo hemisemestreSanthy Rodriguez
 
Using flash type questions – stroke of luck or curse for data quality?
Using flash type questions – stroke of luck or curse for data quality?Using flash type questions – stroke of luck or curse for data quality?
Using flash type questions – stroke of luck or curse for data quality?QuestBack AG
 

Andere mochten auch (20)

Introduction to DocumentDB
Introduction to DocumentDBIntroduction to DocumentDB
Introduction to DocumentDB
 
今から始めるDocument db
今から始めるDocument db今から始めるDocument db
今から始めるDocument db
 
ゼロから始めるBlob
ゼロから始めるBlobゼロから始めるBlob
ゼロから始めるBlob
 
Azure DocumentDB en Dev@Nights
Azure DocumentDB en Dev@NightsAzure DocumentDB en Dev@Nights
Azure DocumentDB en Dev@Nights
 
Introducing DocumentDB
Introducing DocumentDB Introducing DocumentDB
Introducing DocumentDB
 
[GAB2016] Azure DocumentDB - Jean-Luc Boucho
[GAB2016] Azure DocumentDB - Jean-Luc Boucho[GAB2016] Azure DocumentDB - Jean-Luc Boucho
[GAB2016] Azure DocumentDB - Jean-Luc Boucho
 
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
[PASS Summit 2016] Blazing Fast, Planet-Scale Customer Scenarios with Azure D...
 
実プロジェクトの経験から学ぶazureサービス適用パターン
実プロジェクトの経験から学ぶazureサービス適用パターン実プロジェクトの経験から学ぶazureサービス適用パターン
実プロジェクトの経験から学ぶazureサービス適用パターン
 
Logic Apps と Api Apps の話
Logic Apps と Api Apps の話Logic Apps と Api Apps の話
Logic Apps と Api Apps の話
 
20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道
20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道
20141010 マイクロソフト技術と共に目指すフルスタックエンジニアへの道
 
Social Media Y Open Source
Social Media Y Open SourceSocial Media Y Open Source
Social Media Y Open Source
 
Prevención Trabajo oficina
Prevención Trabajo oficinaPrevención Trabajo oficina
Prevención Trabajo oficina
 
0 blog pilpres 2014 jokowi 18092014 oke selesai
0 blog pilpres 2014 jokowi 18092014 oke selesai0 blog pilpres 2014 jokowi 18092014 oke selesai
0 blog pilpres 2014 jokowi 18092014 oke selesai
 
El escultor Ignacio López y el Nazareno de El Puerto
El escultor Ignacio López y el Nazareno de El PuertoEl escultor Ignacio López y el Nazareno de El Puerto
El escultor Ignacio López y el Nazareno de El Puerto
 
Viva Almería (Manolo Escobar)
Viva Almería (Manolo Escobar)Viva Almería (Manolo Escobar)
Viva Almería (Manolo Escobar)
 
Tema 1
Tema 1Tema 1
Tema 1
 
2014 12 31_icv_bulletin_december_2014_short
2014 12 31_icv_bulletin_december_2014_short2014 12 31_icv_bulletin_december_2014_short
2014 12 31_icv_bulletin_december_2014_short
 
R-Style Lab Mobile Portfolio
R-Style Lab Mobile PortfolioR-Style Lab Mobile Portfolio
R-Style Lab Mobile Portfolio
 
Figempa notas segundo hemisemestre
Figempa notas segundo hemisemestreFigempa notas segundo hemisemestre
Figempa notas segundo hemisemestre
 
Using flash type questions – stroke of luck or curse for data quality?
Using flash type questions – stroke of luck or curse for data quality?Using flash type questions – stroke of luck or curse for data quality?
Using flash type questions – stroke of luck or curse for data quality?
 

Ähnlich wie Azure DocumentDB .NET Development Overview

Azure DocumentDB for Healthcare Integration
Azure DocumentDB for Healthcare IntegrationAzure DocumentDB for Healthcare Integration
Azure DocumentDB for Healthcare IntegrationBizTalk360
 
From SQL to MongoDB
From SQL to MongoDBFrom SQL to MongoDB
From SQL to MongoDBNuxeo
 
Microsoft Azure DocumentDB - Global Azure Bootcamp 2016
Microsoft Azure DocumentDB -  Global Azure Bootcamp 2016Microsoft Azure DocumentDB -  Global Azure Bootcamp 2016
Microsoft Azure DocumentDB - Global Azure Bootcamp 2016Sunny Sharma
 
Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!Brian Culver
 
TechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
TechEd AU 2014: Microsoft Azure DocumentDB Deep DiveTechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
TechEd AU 2014: Microsoft Azure DocumentDB Deep DiveIntergen
 
Sqlite
SqliteSqlite
SqliteKumar
 
Accesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformAccesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformLuca Di Fino
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIGert Drapers
 
Test driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDBTest driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDBAndrew Siemer
 
Multi-tier-performance-analysis-of-ADF-applications.pptx
Multi-tier-performance-analysis-of-ADF-applications.pptxMulti-tier-performance-analysis-of-ADF-applications.pptx
Multi-tier-performance-analysis-of-ADF-applications.pptxKuncoro21
 
Introduction to Azure DocumentDB
Introduction to Azure DocumentDBIntroduction to Azure DocumentDB
Introduction to Azure DocumentDBRadenko Zec
 
Full Text Search with Lucene
Full Text Search with LuceneFull Text Search with Lucene
Full Text Search with LuceneWO Community
 
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...MongoDB
 
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...MongoDB
 
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and Atlas
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and AtlasSolving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and Atlas
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and AtlasMongoDB
 

Ähnlich wie Azure DocumentDB .NET Development Overview (20)

Azure DocumentDB for Healthcare Integration
Azure DocumentDB for Healthcare IntegrationAzure DocumentDB for Healthcare Integration
Azure DocumentDB for Healthcare Integration
 
From SQL to MongoDB
From SQL to MongoDBFrom SQL to MongoDB
From SQL to MongoDB
 
Document db
Document dbDocument db
Document db
 
Microsoft Azure DocumentDB - Global Azure Bootcamp 2016
Microsoft Azure DocumentDB -  Global Azure Bootcamp 2016Microsoft Azure DocumentDB -  Global Azure Bootcamp 2016
Microsoft Azure DocumentDB - Global Azure Bootcamp 2016
 
AzureDocumentDB
AzureDocumentDBAzureDocumentDB
AzureDocumentDB
 
Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!Boost the Performance of SharePoint Today!
Boost the Performance of SharePoint Today!
 
No sql Database
No sql DatabaseNo sql Database
No sql Database
 
MongoDB_ppt.pptx
MongoDB_ppt.pptxMongoDB_ppt.pptx
MongoDB_ppt.pptx
 
TechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
TechEd AU 2014: Microsoft Azure DocumentDB Deep DiveTechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
TechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
 
Sqlite
SqliteSqlite
Sqlite
 
Accesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformAccesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data Platform
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPI
 
Test driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDBTest driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDB
 
Elasticsearch Introduction at BigData meetup
Elasticsearch Introduction at BigData meetupElasticsearch Introduction at BigData meetup
Elasticsearch Introduction at BigData meetup
 
Multi-tier-performance-analysis-of-ADF-applications.pptx
Multi-tier-performance-analysis-of-ADF-applications.pptxMulti-tier-performance-analysis-of-ADF-applications.pptx
Multi-tier-performance-analysis-of-ADF-applications.pptx
 
Introduction to Azure DocumentDB
Introduction to Azure DocumentDBIntroduction to Azure DocumentDB
Introduction to Azure DocumentDB
 
Full Text Search with Lucene
Full Text Search with LuceneFull Text Search with Lucene
Full Text Search with Lucene
 
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...
 
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...
 
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and Atlas
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and AtlasSolving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and Atlas
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and Atlas
 

Mehr von Neil Mackenzie

Project Orleans - Actor Model framework
Project Orleans - Actor Model frameworkProject Orleans - Actor Model framework
Project Orleans - Actor Model frameworkNeil Mackenzie
 
Windows Azure Virtual Machines
Windows Azure Virtual MachinesWindows Azure Virtual Machines
Windows Azure Virtual MachinesNeil Mackenzie
 
Node.js on Windows Azure
Node.js on Windows AzureNode.js on Windows Azure
Node.js on Windows AzureNeil Mackenzie
 
Windows Azure HDInsight Service
Windows Azure HDInsight ServiceWindows Azure HDInsight Service
Windows Azure HDInsight ServiceNeil Mackenzie
 
Windows Azure SQL Database Federations
Windows Azure SQL Database FederationsWindows Azure SQL Database Federations
Windows Azure SQL Database FederationsNeil Mackenzie
 
Brokered Messaging in Windows Azure
Brokered Messaging in Windows AzureBrokered Messaging in Windows Azure
Brokered Messaging in Windows AzureNeil Mackenzie
 
Windows Azure Diagnostics
Windows Azure DiagnosticsWindows Azure Diagnostics
Windows Azure DiagnosticsNeil Mackenzie
 
Introduction to Windows Azure AppFabric Applications
Introduction to Windows Azure AppFabric ApplicationsIntroduction to Windows Azure AppFabric Applications
Introduction to Windows Azure AppFabric ApplicationsNeil Mackenzie
 

Mehr von Neil Mackenzie (8)

Project Orleans - Actor Model framework
Project Orleans - Actor Model frameworkProject Orleans - Actor Model framework
Project Orleans - Actor Model framework
 
Windows Azure Virtual Machines
Windows Azure Virtual MachinesWindows Azure Virtual Machines
Windows Azure Virtual Machines
 
Node.js on Windows Azure
Node.js on Windows AzureNode.js on Windows Azure
Node.js on Windows Azure
 
Windows Azure HDInsight Service
Windows Azure HDInsight ServiceWindows Azure HDInsight Service
Windows Azure HDInsight Service
 
Windows Azure SQL Database Federations
Windows Azure SQL Database FederationsWindows Azure SQL Database Federations
Windows Azure SQL Database Federations
 
Brokered Messaging in Windows Azure
Brokered Messaging in Windows AzureBrokered Messaging in Windows Azure
Brokered Messaging in Windows Azure
 
Windows Azure Diagnostics
Windows Azure DiagnosticsWindows Azure Diagnostics
Windows Azure Diagnostics
 
Introduction to Windows Azure AppFabric Applications
Introduction to Windows Azure AppFabric ApplicationsIntroduction to Windows Azure AppFabric Applications
Introduction to Windows Azure AppFabric Applications
 

Kürzlich hochgeladen

Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 

Kürzlich hochgeladen (20)

Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 

Azure DocumentDB .NET Development Overview

  • 1. Azure DocumentDB Neil Mackenzie Satory Global , LLC
  • 2. Who Am I • Neil Mackenzie • Azure Lead –Satory Global • @mknz • http://convective.wordpress.com • Author: Microsoft Windows Azure Development Cookbook • Microsoft MVP for Azure
  • 3. Agenda • DocumentDB Overview • .NET Development
  • 5. Core Features • Schema-less, NoSQL document database • Fully managed, with provisioned capacity • Stored entities are JSON documents • Tunable consistency • Designed to scale into petabytes
  • 6. Microsoft Databases in Azure • Relational • SQL Database (PaaS) • SQL Server (IaaS) • NoSQL • Azure Tables – key-value store • Azure DocumentDB – document database
  • 7. Resource Model • Database Account • Database • Collection • Document • Attachment • Stored Procedure • Trigger • User-defined functions • User • Permission • Media
  • 8. Resource Addressing • Core interface to DocumentDB is RESTful • Each resource has a permanent unique ID • API URL: • https://{database account}.documents.azure.com • Document Path: • /dbs/{database id}/colls/{collection id}/docs/{document id} • Example full URL for a document: • https://lochinver.documents.azure.com/dbs/ju1TAA==/colls/ju1TAPhIFAA=/docs/ju1TAP hIFAAJAAAAAAAAAA==
  • 9. Operations • For each resource: • Create • Replace • Delete • Read • Query • Read is a GET Operation on a specified resource ID, returning a single resource. • Query is a POST operation on a collection with a request body containing DocumentDB SQL text, returning a possible empty collection of resources. • Query can filter only on indexed properties
  • 10. DocumentDB SQL • SELECT <select-list> FROM <from-specification> WHERE <filter-condition> • Similar to normal SQL • Only self-join supported • Ability to reach into JSON tree to: • Access values for filter condition • Shape select list • User-defined functions • LINQ-to-SQL support for .NET
  • 11. Consistency Levels • Default configured for database account, overridable (down) at request level. • Strong – write only visible after quorum commit. Quorum reads. • Bounded Staleness – write order guaranteed. Quorum reads may be behind by a specified number of operations (or time in seconds). • Session – write-order guaranteed within a client session. Reads are up-to-date within the session. “Usually sufficient.” (Default for a new database account) • Eventual – reads may be out of sequence.
  • 12. Indexing Policy • Specified at the collection level • Automatic indexing • By default all properties indexed automatically. This is tunable for individual documents and paths within a document – either inclusion or exclusion of a path • Index precision can be specified for strings and numbers • Indexing mode • Consistent – By default indexes synchronously updated on insert, replace or delete • Lazy – asynchronous index update (targeted at bulk ingestion)
  • 13. Performance • Capacity Unit • Specified amount of storage capacity and operational throughput • Collection quota per capacity unit • Provisioning unit for scaleout for both performance and storage • Configured at the database account level • Sharable among all databases and collections in the database account • Preview limit is 10GB, 3 collections per capacity unit • Storage is SSD backed • Microsoft has used databases with terabytes of storage (designed for petabytes)
  • 14. Performance – Scalability Targets • Assumptions: • 1KB document with 10 properties • Session consistency level • Automatic indexing Database Operation Operations / second (Request units) Read 1 document 2000 Insert, replace, update 1 document 500 Simple query (returning 1 document) 1000 Stored procedure with 50 inserts 20 • Requests throttled if consumption exceeds overall capacity unit target
  • 15. Stored Procedures,Triggers and UDFs • DocumentDB supports server-side JavaScript • Stored Procedures: • Registered at collection level • Operate on any document in the collection • Invoked inside transaction context on primary replica • Triggers: • Pre- or Post: create, replace or delete operations • Invoked inside transaction context on primary replica • User-Defined Functions • Scalar functions invoked only inside queries
  • 16. Libraries • .NET API • Node.js • JavaScript client • JavaScript server • Python
  • 17. Preview • Azure DocumentDB available in: • West US • North Europe • West Europe • Price: $0.73 /day, $22.50 / month – includes 50% preview discount
  • 18. Management • DocumentDB is supported only in the new portal • Manage database account, collections, users, etc. • View consumption statistics • https://portal.azure.com • API support to manage DocumentDB resources • Be aware of limits: • e.g., 3 collections per database account
  • 20. RESTful API • Core interface to DocumentDB • Used by all client libraries • Standard operations against all DocumentDB resources: • CREATE, DELETE, PUT, GET, POST • Returns permanent resource URL on creation • HMAC authentication using management or resource key • DocumentDB request headers
  • 21. Download • .NET API hosted on NuGet • Install-Package Microsoft.Azure.Documents.Client –Pre • Installs DocumentDB and JSON.NET packages
  • 22. Class: DocumentClient • Constructed with endpoint URL and management key for Database account • Provides async/await methods for CRUD operations on DocumentDB resources • Manages the connection to DocumentDB // Create DocumentClient String documentDbAddress = "https://{account}.documents.azure.com"; String authorizationKey = "key=="; Uri documentDbUri = new Uri(documentDbAddress); DocumentClient documentClient = new DocumentClient(documentDbUri, authorizationKey);
  • 23. Class: Resource • Base class for all DocumentDB resource classes • Exposes: • ETag - used for optimistic concurrency • SelfLink – URL path for resource • ResourceID – internal ID (base64 encoded) for resource • ID – ID of the resource, either provided or generated
  • 24. Class: Database • Derived from Resource • Adds properties exposing collections and users // Create database Database database = new Database { Id = databaseId }; ResourceResponse<Database> response = await documentClient.CreateDatabaseAsync(database); database = response; String selfLink = database.SelfLink; String collections = database.CollectionsLink; String users = database.UsersLink;
  • 25. Class: DocumentCollection • Derived from Resource • Adds properties exposing DocumentsLink, StoredProceduresLink, TriggersLink, UserDefinedFunctionsLink // Create document collection DocumentCollection documentCollection = new DocumentCollection { Id = "SomeId" }; ResourceResponse<DocumentCollection> response = await documentClient.CreateDocumentCollectionAsync( database.SelfLink, documentCollection); documentCollection = response;
  • 26. Data Model • Uses JSON.NET library for serialization • Simple class • No special base class • All public properties are serialized into JSON • Obvious mapping from.NET to JSON • IList, etc. -> Array • Int32, etc. -> Integer • Float, etc. -> Float • DateTime -> String • Byte[] -> String
  • 27. Class: Document • Derived from Resource • Adds property exposing AttachmentsLink // Insert document ResourceResponse<Document> response = await documentClient.CreateDocumentAsync( documentCollection.SelfLink, someDocumentEntity); Document document = response;
  • 28. Class: ResourceResponse<T> • Encapsulates the response from a DocumentDB resource operation • Provides resource-dependent quota and usage information • Contains the response headers including HTTP StatusCode • Implicitly exposes the typed resource from the response
  • 29. Read • A Read operation returns a single document. ResourceResponse<Document> response = await documentClient.ReadDocumentAsync(documentLink); Album album = JsonConvert.DeserializeObject<Album>(response.Resource.ToString());
  • 30. Delete Album album = new Album() { AlbumName = "Let It Bleed", BandName = "Rolling Stones", ReleaseYear = "1969“ }; Document document = await documentClient.CreateDocumentAsync( documentCollection.SelfLink, album); ResourceResponse<Document> secondResponse = await documentClient.DeleteDocumentAsync( document.SelfLink);
  • 31. Replace dynamic readResponse = await documentClient.ReadDocumentAsync(documentLink); RequestOptions requestOptions = new RequestOptions() { AccessCondition = new AccessCondition() { Type = AccessConditionType.IfMatch, Condition = readResponse.Resource.ETag } }; Album album = (Album)readResponse.Resource; album.ReleaseYear = "1990"; ResourceResponse<Document> replaceResponse = await documentClient.ReplaceDocumentAsync( documentLink, album, requestOptions);
  • 32. Read From a Feed • The .NET API can return all the resources in a collection as a paged “feed.” String continuation = String.Empty; Do { FeedOptions feedOptions = new FeedOptions { MaxItemCount = 10, RequestContinuation = continuation }; FeedResponse<dynamic> response = await documentClient.ReadDocumentFeedAsync( documentCollectionLink, feedOptions); continuation = response.ResponseContinuation; } while (!String.IsNullOrEmpty(continuation));
  • 33. DocumentDB Queries • DocumentDB supports queries at all resource levels, including: • Database, DocumentCollection, and Document • .NET API supports the following types of queries • SQL • LINQ SQL • LINQ Lambda • The DocumentQueryable class exposes helper extension methods to create various types of query
  • 34. SQL Query foreach (var album in documentClient.CreateDocumentQuery<Album>( documentCollection.SelfLink, "SELECT * FROM albums a WHERE a.bandName = 'Radiohead'")) { Console.WriteLine("Album name: {0}", album.AlbumName); } Note that albums is the name of the DocumentDB collection
  • 35. LINQ Query IQueryable<Album> albums = from a in documentClient.CreateDocumentQuery<Album>( documentCollection.SelfLink) where a.BandName == "Radiohead" select a; foreach (var album in albums) { Console.WriteLine("Album name: {0}", album.AlbumName) }
  • 36. LINQ LambaWith Paging FeedOptions feedOptions = new FeedOptions() { MaxItemCount = 10 }; var query = documentClient.CreateDocumentQuery<Album>( documentCollection.SelfLink, feedOptions) .Where(a => a.BandName == "Radiohead") .AsDocumentQuery(); do { foreach (Album album in await query.ExecuteNextAsync()) { Console.WriteLine("Album name: {0}", album.AlbumName); } } while (query.HasMoreResults);
  • 37. Summary • Azure DocumentDB Preview • Fully managed document database storing JSON entities • High scale and performance • Wide variety of client libraries • .NET, Node.js, JavaScript, python • Supported only in the new Azure portal
  • 38. Resources • Documentation: • http://documentdb.com • Azure Portal • http://portal.azure.com • Channel 9 Show on DocumentDB • http://channel9.msdn.com/Shows/Data-Exposed/Introduction-to-Azure-DocumentDB

Hinweis der Redaktion

  1. SQL reference: http://msdn.microsoft.com/en-us/library/azure/dn782250.aspx
  2. Preview Limits for DocumentDB: http://azure.microsoft.com/en-us/documentation/articles/documentdb-limits/
  3. http://azure.microsoft.com/en-us/documentation/articles/documentdb-manage/ http://azure.microsoft.com/en-us/documentation/articles/documentdb-limits/ Note that the x-ms-request-charge response header indicates the actual request units consumed by a given request
  4. Pricing page: http://azure.microsoft.com/en-us/pricing/details/documentdb/
  5. REST API documentation: http://msdn.microsoft.com/en-us/library/dn781481.aspx
  6. MSDN http://msdn.microsoft.com/en-us/library/azure/microsoft.azure.documents.client.documentclient.aspx
  7. MSDN http://msdn.microsoft.com/en-us/library/azure/microsoft.azure.documents.client.documentclient.aspx
  8. MSDN http://msdn.microsoft.com/en-us/library/azure/microsoft.azure.documents.client.documentclient.aspx
  9. JSON.NET documentation: http://james.newtonking.com/ Rename properties with JsonProperty [JsonProperty(PropertyName = "id")]