azure documentdb 101

36
Azure DocumentDB 101 Presented by Ike Ellis, MVP

Upload: ike-ellis

Post on 02-Jul-2015

758 views

Category:

Technology


0 download

DESCRIPTION

Introduction to Azure DocumentDB

TRANSCRIPT

Page 1: Azure DocumentDB 101

Azure DocumentDB 101Presented by Ike Ellis, MVP

Page 2: Azure DocumentDB 101

What we will cover

Introduction to DocumentDB

Configuring DocumentDB

Creating Databases and Collections

Document CRUD

Simple Stored Procedures

Page 3: Azure DocumentDB 101

What is Azure DocumentDB?

Document-oriented, schema-free NoSQL data store

Fully-managed database-as-a –service

Still in PREVIEW

Page 4: Azure DocumentDB 101

NoSQL? Why?

Simplicity of design

Ability to scale horizontally

Big data and real-time web applications

Page 5: Azure DocumentDB 101

NoSQL? Why not?

Compromise consistency

Use of low-level query languages

Few standardized interfaces

Lots of existing investment in SQL

Page 6: Azure DocumentDB 101

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

Page 7: Azure DocumentDB 101

DocumentDB Resource Model

Page 8: Azure DocumentDB 101

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

Page 9: Azure DocumentDB 101

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)

Page 10: Azure DocumentDB 101

Common Resource Properties

Page 11: Azure DocumentDB 101

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

Page 12: Azure DocumentDB 101

Developing against DocumentDB

REST API

SDKs/Libraries Available for

.NET

Node.js

JavaScript

Python

Page 13: Azure DocumentDB 101

What we will cover

Introduction to DocumentDB

Configuring DocumentDB

Creating Databases and Collections

Document CRUD

Simple Stored Procedures

Page 14: Azure DocumentDB 101

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)

Page 15: Azure DocumentDB 101

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!

Page 16: Azure DocumentDB 101

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

Page 17: Azure DocumentDB 101

What we will cover

Introduction to DocumentDB

Configuring DocumentDB

Creating Databases and Collections

Document CRUD

Simple Stored Procedures

Page 18: Azure DocumentDB 101

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)!

Page 19: Azure DocumentDB 101

Creating a Database

Page 20: Azure DocumentDB 101

Creating a Collection

CollectionsLink is a property of the database the collection will belong to

Page 21: Azure DocumentDB 101

What we will cover

Introduction to DocumentDB

Configuring DocumentDB

Creating Databases and Collections

Document CRUD

Simple Stored Procedures

Page 22: Azure DocumentDB 101

Creating a Document

Requires the DocumentsLink property of the collection the document will

belong to

Page 23: Azure DocumentDB 101

Querying Documents DocumentDB SQL

LINQ

LINQ Lamda

Page 24: Azure DocumentDB 101

Updating a Document

Updates are performed through document replacement

Page 25: Azure DocumentDB 101

Deleting a Document

Page 26: Azure DocumentDB 101

What we will cover

Introduction to DocumentDB

Configuring DocumentDB

Creating Databases and Collections

Document CRUD

Simple Stored Procedures

Page 27: Azure DocumentDB 101

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

Page 28: Azure DocumentDB 101

Creating a Stored Procedure

Page 29: Azure DocumentDB 101

Registering a Stored Procedure

Page 30: Azure DocumentDB 101

Execute a Stored Procedure

Page 31: Azure DocumentDB 101

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

Page 32: Azure DocumentDB 101

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

Page 33: Azure DocumentDB 101

Next Steps

Pre and Post Triggers

User Defined Functions

Users and Permissions

Additional SDKs (REST, Node, JavaScript etc…)

Advanced Queries

Performance and Monitoring

Page 34: Azure DocumentDB 101

Preview Limits

Page 35: Azure DocumentDB 101
Page 36: Azure DocumentDB 101

That’s it!

John Ackerman, Partner at The Monastery

http://www.the-monastery.com

Always looking for awesome developers!

[email protected]

Ike Ellis, Azure/SQL MVP

@ike_ellis

Slides and code will be posted later, links on Code Camp Website

[email protected]