azure documentdb 101
DESCRIPTION
Introduction to Azure DocumentDBTRANSCRIPT
Azure DocumentDB 101Presented by Ike Ellis, MVP
What we will cover
Introduction to DocumentDB
Configuring DocumentDB
Creating Databases and Collections
Document CRUD
Simple Stored Procedures
What is Azure DocumentDB?
Document-oriented, schema-free NoSQL data store
Fully-managed database-as-a –service
Still in PREVIEW
NoSQL? Why?
Simplicity of design
Ability to scale horizontally
Big data and real-time web applications
NoSQL? Why not?
Compromise consistency
Use of low-level query languages
Few standardized interfaces
Lots of existing investment in SQL
DocumentDB Features & Benefits
Ad hoc queries with SQL Syntax
JavaScript execution within the database
Tunable consistency levels
Fully managed
Elastically scalable throughput and storage
Open by design
DocumentDB Resource Model
DocumentDB Resource Model Cont…
Database Account
One or more capacity units
Unique DNS
Database
Logical container of users and collections
Partitioned across collections
Collection
Container of JSON Documents
Scope for transactions & queries
Smallest unit of scale
Document
CRUD-able objects within a collection
No enforced schema or specialized data types
DocumentDB Resource Model Cont…
Users
Logical namespace for scoping permissions
May represent people OR roles
Permissions
Authorization token associated with a user
Controls access to specific resources
Stored Procedures, Triggers and User-Defined-Functions
Application logic to run directly within the transaction of the database
Written entirely in JavaScript
Attachments and Media
Allows storage of binary blobs/media
May be within DocumentDB or in a remote media store (attachment)
Common Resource Properties
Collections are really important
Unit of scale, transactions, and queries
DocumentDB scales out by adding additional collections
Backed by elastic SSD storage
Limited to 10GB in Preview
Automatic Indexing
By default, documents are indexed as they are added to the collection
Enabled by write-optimized, lock-free and log-structured index maintenance
techniques
Emphasises fast writes while serving consistent queries
Policy may be configured at the collection level
Developing against DocumentDB
REST API
SDKs/Libraries Available for
.NET
Node.js
JavaScript
Python
What we will cover
Introduction to DocumentDB
Configuring DocumentDB
Creating Databases and Collections
Document CRUD
Simple Stored Procedures
Create an Account Only available from the new preview portal
http://portal.azure.com
Again, currently in preview
Pricing Tiers
Standard Only
50% discount
Geographic Availability
West US
North Europe
West Europe
10GB Limit on CU
Limited to 5 CUs (50GB)
What is a CU?
CU = Capacity Unit
Document DB Unit of Scale
1 CU performance per second
2,000 single-document reads
500 single-document inserts/replaces/deletes
1,000 single-document queries
20 stored procedures (assuming 50 document insert/sproc)
If you need to scale, just add another CU!
Collection Index Policy Config
Automatic Indexing
Can turn on/off
Can choose to include or exclude specific document (x-ms-indexingdirective)
Include or exclude specific paths within documents
Synchronous versus Asynchronous indexing
Default is synchronous
Lazy indexing ideal for bulk ingestion scenarios on read-heavy collections
What we will cover
Introduction to DocumentDB
Configuring DocumentDB
Creating Databases and Collections
Document CRUD
Simple Stored Procedures
Getting Connected
DocumentDB Account Endpoint
Primary/Secondary Access Key
Provide administrative access to the account
Can retrieve keys with limited access according to permissions
Don’t store access tokens in code (or in demos)!
Creating a Database
Creating a Collection
CollectionsLink is a property of the database the collection will belong to
What we will cover
Introduction to DocumentDB
Configuring DocumentDB
Creating Databases and Collections
Document CRUD
Simple Stored Procedures
Creating a Document
Requires the DocumentsLink property of the collection the document will
belong to
Querying Documents DocumentDB SQL
LINQ
LINQ Lamda
Updating a Document
Updates are performed through document replacement
Deleting a Document
What we will cover
Introduction to DocumentDB
Configuring DocumentDB
Creating Databases and Collections
Document CRUD
Simple Stored Procedures
Stored Procedures in DocumentDB
JavaScript as a modern day T-SQL
High level programming language
Atomic Transactions
JavaScript allows optimization when dealing with JSON documents
Batching
Pre-compilation
Sequencing
Encapsulated Business Logic
5-second timout
Creating a Stored Procedure
Registering a Stored Procedure
Execute a Stored Procedure
Consistency
Trade-off between consistency, availability, and latency
Consistency levels
Strong
Write is only visible after it is committed durably by the majority of quorum replicas
Lowest level of read/write performance
Bounded Staleness
Guarantees order of propagation of writes
Reads might lag behind writes
Session
You can see your writes
low write latency
Eventual
Classic noSQL
Weak consistency
Fast performance, low latency
Cool Stuff
www.documentDB.com/sql/demo
https://social.msdn.microsoft.com/forums/azure/en-
US/home?forum=AzureDocumentDB
http://feedback.azure.com/forums/263030-documentdb
https://github.com/mingaliu/DocumentDBStudio
Next Steps
Pre and Post Triggers
User Defined Functions
Users and Permissions
Additional SDKs (REST, Node, JavaScript etc…)
Advanced Queries
Performance and Monitoring
Preview Limits
That’s it!
John Ackerman, Partner at The Monastery
http://www.the-monastery.com
Always looking for awesome developers!
Ike Ellis, Azure/SQL MVP
@ike_ellis
Slides and code will be posted later, links on Code Camp Website