SlideShare a Scribd company logo
Azure DocumentDB
Emanuele Zanchettin
ezanchettin@thinkit.it - @_thinkIT_
Hi! I’m Emanuele Zanchettin
• 15+ anni di esperienza in ambito IT
• Data architect e consulente per
SQLServer e Azure SQL Database
• Coordinatore team di sviluppo presso
@ Sci-Tech Labs Daresbury (UK)
• Co-founder thinkIT
• ezanchettin@thinkit.it
http://www.thinkit.it/
• Co-coordinatore 1nn0va
Official Microsoft Community
• Speaker a user-group e conferenze
nazionali e internazionali su
SQLServer e Azure SQL Database
Azure DocumentDB
Marco Parenzan, @marco_parenzan
Hi! I’m
• Microsoft MVP 2016 for Azure
• Azure Trainer in Cloud Academy,
Inc.
• Community Lead per 1nn0va
Marco Parenzan
Sponsors
Global Sponsors
Twitter
#GlobalAzure
#Pordenone
Agenda
• Introduzione a JSON
• Introduzione a DocumentDB
• Usare DocumentDB
• Conclusioni
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a JSON – Storia
In informatica, nell'ambito della
programmazione web, JSON, acronimo di
JavaScript Object Notation, è un formato
adatto all'interscambio di dati fra applicazioni
client-server
https://it.wikipedia.org/wiki/JavaScript_Object_Notation
• Basato su STD JS Dicembre 1999
• Indipendete
• Alternativa a XML
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a JSON – tipi di dato
• booleani
• numeri
• stringhe
• array
• array associativi
• null
• oggetti
• date  … (stringa )
• binari  … (base64 )
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a JSON – confronto XML e JSON
• XML
<impiegati>
<impiegato>
<nome>Pippo</nome>
<genere>M</genere>
</impiegato>
<impiegato>
<nome>Pluto</nome>
<genere>M</genere>
</impiegato>
</impiegati>
• JSON
{
"impiegati": [
{
"nome": "Pippo",
"genere": "M"
},
{
"nome": "Pluto",
"genere": "M"
}
]
}
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a JSON – regole JSON
• Un oggetto va sempre racchiuso tra { e }
• Le coppie chiavi/valori sono separate da :
• Le collezioni di coppie chiavi/valori vanno separati da ,
• Gli array sono rappresentati da [ ] e i valori separati da ,
Il «valore» può essere stringa, numero, oggetto, array, true, false e null
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a JSON – le stringhe
• Fare attenzione nel caso di gestione di stringhe UNICODE eccetto " e 
e caratteri di controllo, ad esempio
 " doppie virgolette
 barra retroversa
/ barra
b indietro
f fine pagina
r ritorno a capo
n nuova riga
t tabulazione
u<hex 4 digit> qualiasi carattere in esadecimale
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a JSON – conversione tipi
• JSON tipi «valore»
• Numero, segnato decimale con eventuale frazione ed esponente E
• Stringa, delimitata da " e gestita con  come carattere di escape
• Boolean, true o false
• Null
• Array, delimitato da [] come lista vuota o con elementi separati da ,
• Oggetto, delimitato da { } con eventuali coppie chiave/valore separati di ,
Semplice no!? 
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a
DocumentDb
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Introduzione a DocumentDB
• Velocità e scalabilità
• Replica multiarea
• Query con SQL familiar
• Esecuzione Javascript
• Livelli di coerenza perfezionabili
• Completamente gestito
• Indicizzazione
• Compatibilità MongoDB
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Stuttura di DocumentDB
• Fissa
Database
Utenti
Autorizzazioni
Raccolte/Collezioni
Stored Procedures
Triggers
UDF
• Libera
Documenti
Allegati
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Accesso alle risorse DocumentDB
/dbs
/dbs/{dbName}
/dbs/{dbName}/colls/
/dbs/{dbName}/colls/{collName}
/dbs/{dbName}/colls/{collName}/docs
/dbs/{dbName}/colls/{collName}/docs/{docId}
/dbs/{dbName}/users/
/dbs/{dbName}/users/{userId}
/dbs/{dbName}/users/{userId}/permissions
/dbs/{dbName}/users/{userId}/permissions/{permissionId}
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Livelli di coerenza
• Strong / Assoluta
• Bounded Staleness / Obsolescenza associata
• Session
• Eventual /Finale
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Assoluta - scrittura
dato B
dato B
dato A
dato B
replica 1
replica 2
replica 3
async
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Assoluta - lettura
dato B
dato B
dato A
dato B
replica 1
replica 2
replica 3
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Obsolescenza Aassociata - scrittura
dato B
dato B
dato A
dato A
replica 1
replica 2
replica 3
async
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Obsolescenza Aassociata - lettura
dato B
dato B
dato A
dato B
replica 1
replica 2
replica 3
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Sessione - scrittura
dato B
dato B
dato A
dato A
replica 1
replica 2
replica 3
async
Sessione 1
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Sessione - lettura
dato B
dato B
dato A
dato A
replica 1
replica 2
replica 3
async
Sessione 1
dato A
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Finale - scrittura
dato B
dato B
dato A
dato A
replica 1
replica 2
replica 3
async
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Coerenza Finale - lettura
dato A/B/?
dato B
dato A
dato A
replica 1
replica 2
replica 3
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Indici
• Nessun schema richiesto
• No indici secondari
• Chiavi senza blocchi e strutturate in Log
• Attivazione/Disattivazione Indicizzazione automatica
• Inclusione/Esclusione documenti
• Inclusione/Esclusione percorsi
• Aggiornamenti sincroni/asincroni
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Modeling
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Modellazione relazioni – male
Automobile:
{
"Id": 123,
"Targa": “AA123BB",
"Venditore": { "Nome": “Pinco Palla", “Indirizzo": “Qualche parte“ },
"GPSPosizione": { "Latitudine": 45.6543285, "Longitudine": -13.5834275 },
"Dati": [
{ "Id": 1, "TimeStamp": "2010-01-07", "MotoreOn": true, "Carburante": 100 },
{ "Id": 2, "TimeStamp": "2010-01-07", "MotoreOn": false, "Carburante": 88 },
...
{ "Id": 999999, "TimeStamp": "2017-04-22", "MotoreOn": true, "Carburante": 15 }
]
}
bassa frequenza
aggiornamenti
alta frequenza
aggiornamenti
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Modellazione relazioni – bene
Automobile:
{
"Id": 123,
"Targa": “AA123BB",
"Venditore":
{
"Nome": “Pinco Palla",
"Indirizzo": “Qualche parte“
}
}
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Modellazione relazioni – bene
PosizioneAutomobile:
{
"AutomobileId": 123, "GPSPosizione": { "Latitudine": 45.6543285, "Longitudine": -13.5834275 }
}
DatiAutomobile:
{
"AutomobileId": 123, "Dati": [
{ "Id": 1, "TimeStamp": "2010-01-07", "MotoreOn": true, "Carburante": 100 },
{ "Id": 2, "TimeStamp": "2010-01-07", "MotoreOn": false, "Carburante": 88 },
...
{ "Id": 999999, "TimeStamp": "2017-04-22", "MotoreOn": true, "Carburante": 15 }
]
}
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Collections
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
DocumentDb Performance
• Data is saved on SSD
• All writes to the primary are replicated across two secondary replicas
• (Replicas are spread on different hardware in same region to protect
against failures)
• All reads are distributed across the three copies (when and how
depend on consistency level for db account and query)
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Collections
• A unit of scale for transaction
• for stored procedures and triggers
• A unit of query throughput
• capacity units allocated uniformly across all collections)
• A unit of replication
• A collection is replicated three times
• A container of JSON documents
• JSON docs inside of a collection can vary dramatically
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Unit of query throughput
• Collection-based RU Reservation
• Capacity units allocated uniformly across all collections)
• Standard pricing tier with hourly billing
• Performance levels can be adjusted
• Each collection = 10GB of SSD
• Limit of 100 collections (1 TB)
• Soft limit, can be lifted as needed per account (with Support)
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Performance levels
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Request Units
• Predictable Performance
• Each DocumentDB collection has
reserved throughput in terms of
request units (RUs)
• Normalized currency across
database operations
• RU== 𝑓 𝑀𝑒𝑚𝑜𝑟𝑦, 𝐶𝑃𝑈, 𝐼𝑂
• RUs offer accurate accounting in
face of diverse database
operations
Operation RU
Consumed
Reading a single 1KB document 1
Reading a single 2KB document 2
Query with a simple predicate for a 1KB
document
3
Creating a single 1 KB document with 10
JSON properties (consistent indexing)
14
Create a single 1 KB document with 100
JSON properties (consistent indexing)
20
Replacing a single 1 KB document 28
Execute a stored procedure with two create
documents
30
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Use cases
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Casi d’uso – IoT e dati telematici
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Casi d’uso – Vendite e marketing
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Casi d’uso – Giochi
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Mano al codice
DEMO
«Hello World» con DocumentDB
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Conclusioni
• Valida alternativa al modello relazione
• Alte prestazioni e predicibili
• Flessibilità totale
• Scalabilità praticamente assoluta
• Utilizzo di strumenti e linguaggi noti
• Altro???? 
Pordenone, 22 aprile 2017#GlobalAzure
#Pordenone
Links
• Introduzione a DocumentDB: un Database NoSQL JSON
https://docs.microsoft.com/it-it/azure/documentdb/documentdb-introduction
• Modello di risorse gerarchico e concetti di base relativi a DocumentDB
https://docs.microsoft.com/it-it/azure/documentdb/documentdb-resources
• Livelli di coerenza dei dati ottimizzabili in DocumentDB
https://docs.microsoft.com/it-it/azure/documentdb/documentdb-consistency-levels
• Casi di utilizzo comuni di DocumentDB
https://docs.microsoft.com/it-it/azure/documentdb/documentdb-use-cases
Thanks! Grazie!
Q&A

More Related Content

Similar to Azure DocumentDb

Back to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQLBack to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQL
MongoDB
 
MongoDB - Back to Basics 2017 - Introduzione a NoSQL
MongoDB - Back to Basics 2017 - Introduzione a NoSQLMongoDB - Back to Basics 2017 - Introduzione a NoSQL
MongoDB - Back to Basics 2017 - Introduzione a NoSQL
Massimo Brignoli
 
Azure Synapse: data lake & modern data warehouse dalla A alla Z
Azure Synapse: data lake &  modern data warehouse dalla A alla ZAzure Synapse: data lake &  modern data warehouse dalla A alla Z
Azure Synapse: data lake & modern data warehouse dalla A alla Z
Roberto Messora
 
CDays15 - AZ08 - DocumentDB: il NoSql secondo Azure
CDays15 - AZ08 - DocumentDB: il NoSql secondo AzureCDays15 - AZ08 - DocumentDB: il NoSql secondo Azure
CDays15 - AZ08 - DocumentDB: il NoSql secondo Azure
Davide Benvegnù
 
2014 it - app dev series - 04 - indicizzazione
2014   it - app dev series - 04 - indicizzazione2014   it - app dev series - 04 - indicizzazione
2014 it - app dev series - 04 - indicizzazioneMongoDB
 
Crea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.jsCrea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.js
Matteo Collina
 
Power bi Clean and Modelling (SQL Saturday #675)
Power bi Clean and Modelling  (SQL Saturday #675)Power bi Clean and Modelling  (SQL Saturday #675)
Power bi Clean and Modelling (SQL Saturday #675)
Marco Pozzan
 
Azure No-Sql approach: DocumentDB
Azure No-Sql approach: DocumentDBAzure No-Sql approach: DocumentDB
Azure No-Sql approach: DocumentDB
Davide Benvegnù
 
Quanto mi costa SQL Pool Serverless Synapse
Quanto mi costa SQL Pool Serverless SynapseQuanto mi costa SQL Pool Serverless Synapse
Quanto mi costa SQL Pool Serverless Synapse
Marco Pozzan
 
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
MongoDB
 
Azure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT SolutionsAzure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT Solutions
Marco Parenzan
 
Power B: Cleaning data
Power B: Cleaning dataPower B: Cleaning data
Power B: Cleaning data
Marco Pozzan
 
Azure PaaS databases
Azure PaaS databasesAzure PaaS databases
Azure PaaS databases
Gianluca Hotz
 
PoC IoT in 1 ora
PoC IoT in 1 oraPoC IoT in 1 ora
PoC IoT in 1 ora
Alessio Biasiutti
 
iot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 oraiot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 ora
Alessio Biasiutti
 
JSON in SQL Server 2019
JSON in SQL Server 2019JSON in SQL Server 2019
JSON in SQL Server 2019
Gabriele Franco
 
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-servicePower BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Marco Pozzan
 
Azure Saturday Pordenone 2018 IoT real time processing for lazy developer
Azure Saturday Pordenone 2018 IoT real time processing for lazy developerAzure Saturday Pordenone 2018 IoT real time processing for lazy developer
Azure Saturday Pordenone 2018 IoT real time processing for lazy developer
Alessio Biasiutti
 
Back to Basics, webinar 1: Introduzione a NoSQL
Back to Basics, webinar 1: Introduzione a NoSQLBack to Basics, webinar 1: Introduzione a NoSQL
Back to Basics, webinar 1: Introduzione a NoSQL
MongoDB
 
Big data analytics quanto vale e come sfruttarlo con stream analytics e power bi
Big data analytics quanto vale e come sfruttarlo con stream analytics e power biBig data analytics quanto vale e come sfruttarlo con stream analytics e power bi
Big data analytics quanto vale e come sfruttarlo con stream analytics e power bi
Marco Pozzan
 

Similar to Azure DocumentDb (20)

Back to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQLBack to Basics webinar 1 IT 17 - Introduzione ai NoSQL
Back to Basics webinar 1 IT 17 - Introduzione ai NoSQL
 
MongoDB - Back to Basics 2017 - Introduzione a NoSQL
MongoDB - Back to Basics 2017 - Introduzione a NoSQLMongoDB - Back to Basics 2017 - Introduzione a NoSQL
MongoDB - Back to Basics 2017 - Introduzione a NoSQL
 
Azure Synapse: data lake & modern data warehouse dalla A alla Z
Azure Synapse: data lake &  modern data warehouse dalla A alla ZAzure Synapse: data lake &  modern data warehouse dalla A alla Z
Azure Synapse: data lake & modern data warehouse dalla A alla Z
 
CDays15 - AZ08 - DocumentDB: il NoSql secondo Azure
CDays15 - AZ08 - DocumentDB: il NoSql secondo AzureCDays15 - AZ08 - DocumentDB: il NoSql secondo Azure
CDays15 - AZ08 - DocumentDB: il NoSql secondo Azure
 
2014 it - app dev series - 04 - indicizzazione
2014   it - app dev series - 04 - indicizzazione2014   it - app dev series - 04 - indicizzazione
2014 it - app dev series - 04 - indicizzazione
 
Crea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.jsCrea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.js
 
Power bi Clean and Modelling (SQL Saturday #675)
Power bi Clean and Modelling  (SQL Saturday #675)Power bi Clean and Modelling  (SQL Saturday #675)
Power bi Clean and Modelling (SQL Saturday #675)
 
Azure No-Sql approach: DocumentDB
Azure No-Sql approach: DocumentDBAzure No-Sql approach: DocumentDB
Azure No-Sql approach: DocumentDB
 
Quanto mi costa SQL Pool Serverless Synapse
Quanto mi costa SQL Pool Serverless SynapseQuanto mi costa SQL Pool Serverless Synapse
Quanto mi costa SQL Pool Serverless Synapse
 
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
Back to Basics, webinar 4: Indicizzazione avanzata, indici testuali e geospaz...
 
Azure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT SolutionsAzure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT Solutions
 
Power B: Cleaning data
Power B: Cleaning dataPower B: Cleaning data
Power B: Cleaning data
 
Azure PaaS databases
Azure PaaS databasesAzure PaaS databases
Azure PaaS databases
 
PoC IoT in 1 ora
PoC IoT in 1 oraPoC IoT in 1 ora
PoC IoT in 1 ora
 
iot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 oraiot Saturday 2019 - PoC iot in 1 ora
iot Saturday 2019 - PoC iot in 1 ora
 
JSON in SQL Server 2019
JSON in SQL Server 2019JSON in SQL Server 2019
JSON in SQL Server 2019
 
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-servicePower BI: Introduzione ai dataflow e alla preparazione dei dati self-service
Power BI: Introduzione ai dataflow e alla preparazione dei dati self-service
 
Azure Saturday Pordenone 2018 IoT real time processing for lazy developer
Azure Saturday Pordenone 2018 IoT real time processing for lazy developerAzure Saturday Pordenone 2018 IoT real time processing for lazy developer
Azure Saturday Pordenone 2018 IoT real time processing for lazy developer
 
Back to Basics, webinar 1: Introduzione a NoSQL
Back to Basics, webinar 1: Introduzione a NoSQLBack to Basics, webinar 1: Introduzione a NoSQL
Back to Basics, webinar 1: Introduzione a NoSQL
 
Big data analytics quanto vale e come sfruttarlo con stream analytics e power bi
Big data analytics quanto vale e come sfruttarlo con stream analytics e power biBig data analytics quanto vale e come sfruttarlo con stream analytics e power bi
Big data analytics quanto vale e come sfruttarlo con stream analytics e power bi
 

More from Marco Parenzan

Azure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineerAzure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineer
Marco Parenzan
 
Azure Hybrid @ Home
Azure Hybrid @ HomeAzure Hybrid @ Home
Azure Hybrid @ Home
Marco Parenzan
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Marco Parenzan
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
Marco Parenzan
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
Marco Parenzan
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
Marco Parenzan
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
Marco Parenzan
 
Math with .NET for you and Azure
Math with .NET for you and AzureMath with .NET for you and Azure
Math with .NET for you and Azure
Marco Parenzan
 
Power BI data flow and Azure IoT Central
Power BI data flow and Azure IoT CentralPower BI data flow and Azure IoT Central
Power BI data flow and Azure IoT Central
Marco Parenzan
 
.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame
Marco Parenzan
 
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Marco Parenzan
 
Anomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NETAnomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NET
Marco Parenzan
 
Deploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data SolutionsDeploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data Solutions
Marco Parenzan
 
Deep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnetDeep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnet
Marco Parenzan
 
Azure IoT Central
Azure IoT CentralAzure IoT Central
Azure IoT Central
Marco Parenzan
 
Anomaly Detection with Azure and .net
Anomaly Detection with Azure and .netAnomaly Detection with Azure and .net
Anomaly Detection with Azure and .net
Marco Parenzan
 
Code Generation for Azure with .net
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
Marco Parenzan
 
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magicRunning Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
Marco Parenzan
 
Time Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETTTime Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETT
Marco Parenzan
 
Code Generation for Azure with .net
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
Marco Parenzan
 

More from Marco Parenzan (20)

Azure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineerAzure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineer
 
Azure Hybrid @ Home
Azure Hybrid @ HomeAzure Hybrid @ Home
Azure Hybrid @ Home
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 
Math with .NET for you and Azure
Math with .NET for you and AzureMath with .NET for you and Azure
Math with .NET for you and Azure
 
Power BI data flow and Azure IoT Central
Power BI data flow and Azure IoT CentralPower BI data flow and Azure IoT Central
Power BI data flow and Azure IoT Central
 
.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame
 
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
 
Anomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NETAnomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NET
 
Deploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data SolutionsDeploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data Solutions
 
Deep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnetDeep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnet
 
Azure IoT Central
Azure IoT CentralAzure IoT Central
Azure IoT Central
 
Anomaly Detection with Azure and .net
Anomaly Detection with Azure and .netAnomaly Detection with Azure and .net
Anomaly Detection with Azure and .net
 
Code Generation for Azure with .net
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
 
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magicRunning Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
 
Time Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETTTime Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETT
 
Code Generation for Azure with .net
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
 

Azure DocumentDb

  • 2. Hi! I’m Emanuele Zanchettin • 15+ anni di esperienza in ambito IT • Data architect e consulente per SQLServer e Azure SQL Database • Coordinatore team di sviluppo presso @ Sci-Tech Labs Daresbury (UK) • Co-founder thinkIT • ezanchettin@thinkit.it http://www.thinkit.it/ • Co-coordinatore 1nn0va Official Microsoft Community • Speaker a user-group e conferenze nazionali e internazionali su SQLServer e Azure SQL Database
  • 4. Hi! I’m • Microsoft MVP 2016 for Azure • Azure Trainer in Cloud Academy, Inc. • Community Lead per 1nn0va Marco Parenzan
  • 8. Agenda • Introduzione a JSON • Introduzione a DocumentDB • Usare DocumentDB • Conclusioni
  • 9. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a JSON – Storia In informatica, nell'ambito della programmazione web, JSON, acronimo di JavaScript Object Notation, è un formato adatto all'interscambio di dati fra applicazioni client-server https://it.wikipedia.org/wiki/JavaScript_Object_Notation • Basato su STD JS Dicembre 1999 • Indipendete • Alternativa a XML
  • 10. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a JSON – tipi di dato • booleani • numeri • stringhe • array • array associativi • null • oggetti • date  … (stringa ) • binari  … (base64 )
  • 11. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a JSON – confronto XML e JSON • XML <impiegati> <impiegato> <nome>Pippo</nome> <genere>M</genere> </impiegato> <impiegato> <nome>Pluto</nome> <genere>M</genere> </impiegato> </impiegati> • JSON { "impiegati": [ { "nome": "Pippo", "genere": "M" }, { "nome": "Pluto", "genere": "M" } ] }
  • 12. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a JSON – regole JSON • Un oggetto va sempre racchiuso tra { e } • Le coppie chiavi/valori sono separate da : • Le collezioni di coppie chiavi/valori vanno separati da , • Gli array sono rappresentati da [ ] e i valori separati da , Il «valore» può essere stringa, numero, oggetto, array, true, false e null
  • 13. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a JSON – le stringhe • Fare attenzione nel caso di gestione di stringhe UNICODE eccetto " e e caratteri di controllo, ad esempio " doppie virgolette barra retroversa / barra b indietro f fine pagina r ritorno a capo n nuova riga t tabulazione u<hex 4 digit> qualiasi carattere in esadecimale
  • 14. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a JSON – conversione tipi • JSON tipi «valore» • Numero, segnato decimale con eventuale frazione ed esponente E • Stringa, delimitata da " e gestita con come carattere di escape • Boolean, true o false • Null • Array, delimitato da [] come lista vuota o con elementi separati da , • Oggetto, delimitato da { } con eventuali coppie chiave/valore separati di , Semplice no!? 
  • 15. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a DocumentDb
  • 16. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Introduzione a DocumentDB • Velocità e scalabilità • Replica multiarea • Query con SQL familiar • Esecuzione Javascript • Livelli di coerenza perfezionabili • Completamente gestito • Indicizzazione • Compatibilità MongoDB
  • 17. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Stuttura di DocumentDB • Fissa Database Utenti Autorizzazioni Raccolte/Collezioni Stored Procedures Triggers UDF • Libera Documenti Allegati
  • 18. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Accesso alle risorse DocumentDB /dbs /dbs/{dbName} /dbs/{dbName}/colls/ /dbs/{dbName}/colls/{collName} /dbs/{dbName}/colls/{collName}/docs /dbs/{dbName}/colls/{collName}/docs/{docId} /dbs/{dbName}/users/ /dbs/{dbName}/users/{userId} /dbs/{dbName}/users/{userId}/permissions /dbs/{dbName}/users/{userId}/permissions/{permissionId}
  • 19. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Livelli di coerenza • Strong / Assoluta • Bounded Staleness / Obsolescenza associata • Session • Eventual /Finale
  • 20. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Assoluta - scrittura dato B dato B dato A dato B replica 1 replica 2 replica 3 async
  • 21. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Assoluta - lettura dato B dato B dato A dato B replica 1 replica 2 replica 3
  • 22. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Obsolescenza Aassociata - scrittura dato B dato B dato A dato A replica 1 replica 2 replica 3 async
  • 23. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Obsolescenza Aassociata - lettura dato B dato B dato A dato B replica 1 replica 2 replica 3
  • 24. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Sessione - scrittura dato B dato B dato A dato A replica 1 replica 2 replica 3 async Sessione 1
  • 25. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Sessione - lettura dato B dato B dato A dato A replica 1 replica 2 replica 3 async Sessione 1 dato A
  • 26. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Finale - scrittura dato B dato B dato A dato A replica 1 replica 2 replica 3 async
  • 27. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Coerenza Finale - lettura dato A/B/? dato B dato A dato A replica 1 replica 2 replica 3
  • 28. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Indici • Nessun schema richiesto • No indici secondari • Chiavi senza blocchi e strutturate in Log • Attivazione/Disattivazione Indicizzazione automatica • Inclusione/Esclusione documenti • Inclusione/Esclusione percorsi • Aggiornamenti sincroni/asincroni
  • 29. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Modeling
  • 30. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Modellazione relazioni – male Automobile: { "Id": 123, "Targa": “AA123BB", "Venditore": { "Nome": “Pinco Palla", “Indirizzo": “Qualche parte“ }, "GPSPosizione": { "Latitudine": 45.6543285, "Longitudine": -13.5834275 }, "Dati": [ { "Id": 1, "TimeStamp": "2010-01-07", "MotoreOn": true, "Carburante": 100 }, { "Id": 2, "TimeStamp": "2010-01-07", "MotoreOn": false, "Carburante": 88 }, ... { "Id": 999999, "TimeStamp": "2017-04-22", "MotoreOn": true, "Carburante": 15 } ] } bassa frequenza aggiornamenti alta frequenza aggiornamenti
  • 31. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Modellazione relazioni – bene Automobile: { "Id": 123, "Targa": “AA123BB", "Venditore": { "Nome": “Pinco Palla", "Indirizzo": “Qualche parte“ } }
  • 32. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Modellazione relazioni – bene PosizioneAutomobile: { "AutomobileId": 123, "GPSPosizione": { "Latitudine": 45.6543285, "Longitudine": -13.5834275 } } DatiAutomobile: { "AutomobileId": 123, "Dati": [ { "Id": 1, "TimeStamp": "2010-01-07", "MotoreOn": true, "Carburante": 100 }, { "Id": 2, "TimeStamp": "2010-01-07", "MotoreOn": false, "Carburante": 88 }, ... { "Id": 999999, "TimeStamp": "2017-04-22", "MotoreOn": true, "Carburante": 15 } ] }
  • 33. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Collections
  • 34. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone DocumentDb Performance • Data is saved on SSD • All writes to the primary are replicated across two secondary replicas • (Replicas are spread on different hardware in same region to protect against failures) • All reads are distributed across the three copies (when and how depend on consistency level for db account and query)
  • 35. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Collections • A unit of scale for transaction • for stored procedures and triggers • A unit of query throughput • capacity units allocated uniformly across all collections) • A unit of replication • A collection is replicated three times • A container of JSON documents • JSON docs inside of a collection can vary dramatically
  • 36. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Unit of query throughput • Collection-based RU Reservation • Capacity units allocated uniformly across all collections) • Standard pricing tier with hourly billing • Performance levels can be adjusted • Each collection = 10GB of SSD • Limit of 100 collections (1 TB) • Soft limit, can be lifted as needed per account (with Support)
  • 37. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Performance levels
  • 38. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Request Units • Predictable Performance • Each DocumentDB collection has reserved throughput in terms of request units (RUs) • Normalized currency across database operations • RU== 𝑓 𝑀𝑒𝑚𝑜𝑟𝑦, 𝐶𝑃𝑈, 𝐼𝑂 • RUs offer accurate accounting in face of diverse database operations Operation RU Consumed Reading a single 1KB document 1 Reading a single 2KB document 2 Query with a simple predicate for a 1KB document 3 Creating a single 1 KB document with 10 JSON properties (consistent indexing) 14 Create a single 1 KB document with 100 JSON properties (consistent indexing) 20 Replacing a single 1 KB document 28 Execute a stored procedure with two create documents 30
  • 39. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Use cases
  • 40. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Casi d’uso – IoT e dati telematici
  • 41. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Casi d’uso – Vendite e marketing
  • 42. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Casi d’uso – Giochi
  • 43. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Mano al codice DEMO «Hello World» con DocumentDB
  • 44. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Conclusioni • Valida alternativa al modello relazione • Alte prestazioni e predicibili • Flessibilità totale • Scalabilità praticamente assoluta • Utilizzo di strumenti e linguaggi noti • Altro???? 
  • 45. Pordenone, 22 aprile 2017#GlobalAzure #Pordenone Links • Introduzione a DocumentDB: un Database NoSQL JSON https://docs.microsoft.com/it-it/azure/documentdb/documentdb-introduction • Modello di risorse gerarchico e concetti di base relativi a DocumentDB https://docs.microsoft.com/it-it/azure/documentdb/documentdb-resources • Livelli di coerenza dei dati ottimizzabili in DocumentDB https://docs.microsoft.com/it-it/azure/documentdb/documentdb-consistency-levels • Casi di utilizzo comuni di DocumentDB https://docs.microsoft.com/it-it/azure/documentdb/documentdb-use-cases