Cosmosdb
Cosmosdb
Distributed to regions
CosmosDB Account
{ } Database
Collection
Document
Demo – creating a collection
Pricing
By collection
size
RU per hour (reserved, not effectively used)
RU – Request Units
The capacity of your system
1 RU = 1 Kb for 1 request
Demo – pricing
Data Models
SQL API
Document Database (JSON)
documentDB API
“id” column mandatory, manually or automatically set
SQL language for documents
Demos – SQL API
The Wines Collection Importing JSON
https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-feature-support
MongoDb Sharding
Importing into Mongo CosmosDB
Mongo
MongoImport
MongoExport
Demos – mongodb api
The Wines Collection Using the Shell
Demos – mongodb api
Robo 3T Aggregation Framework
Table API
Simple Key-Value (KV) store
Get and Set
You can search in values, everything is indexed
Hash table, very fast for keys
API is recent : https://docs.microsoft.com/en-
us/azure/cosmos-db/table-sdk-dotnet
No support yet for .NET Core (use the old one)
Graph API
1 2
Type: enemy
g.V().as("a").out("knows").as("b").
select("a","b").
by("name").
by("age")
Apache Tinkerpop
Demos – graph api
Create a vertex Using Gremlin console
SP, Triggers, UDF
Javascript
UserDefinedFunction regexMatchUdf = new UserDefinedFunction
{
Id = "REGEX_MATCH",
Body = @"function (input, pattern) {
return input.match(pattern) !== null;
};",
};
No scalability, obviously
localhost:8081
Data migration tool
From To
https://github.com/azure/azure-documentdb-datamigrationtool
eTag Management – OCC, MVCC
this.client.ReplaceDocumentAsync(doc.SelfLink, wine,
new RequestOptions {AccessCondition = ac}
);
Indexing
Automatic. All fields are indexed.
Can be set manually, even by document
Online strategy changes, no impact on RUs
https://docs.microsoft.com/en-us/azure/cosmos-db/query-cheat-sheet