Azure SQL
more or/and less than SQL Server
Rafał Hryniewski
@r_hryniewski
fb.me/hryniewskinet
.NET Dev
Blogger
Speaker
Community leader
https://hryniewski.net
rafal@hryniewski.net
Azure SQL
more or/and less than SQL Server
IOPS - input/output operations per second
DTU – Database Transaction Unit
IaaS, PaaS, SaaS – Infrastructure/Platform/Software as a Service
Glossary
Database possibilities in Azure
And anything on VM or in a
container
Lets focus on MS SQL
MS SQL Options in Azure
 SQL Server on VM
 SQL Server on container
 Site-to-site VPN with any physical machine (or other hybrid solution)
 Azure SQL
Azure SQL
 Released in 2010
 Database in PaaS model
 Based on most recent, stable SQL Server Enterprise version
 Available in DTU or vCore based pricing and scaling
 Not fully compatible with SQL Server…
 …unless it’s Azure SQL Database Managed Instance, then it’s almost 100%
compatible.
 Lots of out of the box stuff
Various Azure SQL Options
Various Azure SQL Options
Resource
group
Server
Database
Resource group
Azure’s logical container
Azure SQL Server
•Connection data
•Admin credentials
Database
Data
Billing
Service tier
Billing
Configuration
Two pricing/scaling models
DTU Model
 DTU – Data Transaction Unit
 DTU – CPU, memory, I/O and transaction log I/O in one metric
 3 Tiers – Basic, Standard, Premium
 Simple, effortless model.
DTU Tiers comparison
Basic:
 99,99% Uptime SLA
 7 days backup retention
 5 ms read latency
 10 ms write latency
 Up to 2GB storage
 2.5 IOPS per DTU
Standard:
• 35 days backup retention
• Columnstore indexing support
from S3 tier
• Up to 1TB storage
Premium:
 2 ms read/write latency
 Columnstore indexing support
 In-memory OLTP support
 48 IOPS per DTU
vCore Model
 Recommended scaling model
 More control upon resources during scaling
 General Purpose, Business critical and Hyperscale (preview) service tiers
 You’ll be billed for – service tier + no. of vCores and memory + hardware
generation
vCore Model - Choices
 Service Tier
 Hardware generation
 vCores amount (memory is strictly bound to it)
 Storage amount
vCore Model – Service Tiers
General Purpose:
 Premium remote storage (like
VMs)
 500 IOPS per vCore (7000
max)
 1 replica
Business Critical:
 Local SSD Storage
 5000 IOPS per vCore (200 000
max)
 3 replicas, 1 read-scale replica
 Build in support for Availability
Zones
 In-memory OLTP support
vCore Model – Hardware Generation
Gen 4:
 Up to 24 cores
 Based on Intel E5-2673 v3
(Haswell) 2.4 GHz processor
 Based on physical processor
 7 GB memory per vCore
 SSD storage
Gen 5:
 Up to 80 cores
 Based on Intel E5-2673 v4
(Broadwell) 2.3 GHz Processor
 Based on logical processor
 5.1 GB memory per vCore
 eNVM SSD storage (faster)
Can I migrate DTU model to vCore?
DTU -> vCore
 In standard tier each 100 DTU requires 1 General Purpose vCore
 In premium tier each 125 DTU requires 1 Business Critical vCore
Cool stuff
Firewall
Firewall - rules
 Each rule is IP range whitelist
 Rules can be created only by
 Server level rules can be managed with T-SQL, CLI, Powershell or REST
 Databasel level rules can be managed only with T-SQL
Scaling vertically
Scaling up – DTU model
Scaling up – vCore model
Scaling Up
 Minimum downtime
 Sadly, no autoscaling
 Still, it’s effortless...
 ...and there are some workarounds that makes autoscale possible
Scalling horizontaly and replication
Georeplication
Georeplication
 Creates readable replicas (secondaries)
 Manual failover
 Less than 1 minute downtime
 Each transaction is replicated to secondary after commiting to primary (Always
On)
Georeplication
Failover groups
 Defines two listeners read-only and read-write
 Automatic or manual failover
 Need to set grace period for data loss starting from 1 hour
Failover groups
Replication and read-scale out
 Basically read-only replicas for load balancing read-only database traffic
 Available in Premium (DTU) or Business Critical (vCore) Service Tiers
 All it takes is use of ApplicationIntent in Connection String ie:
Server=tcp:<serverName>.database.windows.net;D
atabase=<db>;ApplicationIntent=ReadOnly;User
ID=<login>;Password=<password>;
Recovering database
Auto backup and point-in-time recovery
 Automated backup with 7-35 days retention
 Stored in included Read-access geo-redundant storage (RA-GRS)
 It’s included in price!
Auto backup and point-in-time recovery
 Can be used to restore database from ANY point in time in retention period (on
the same server)
 Can be used to restore deleted db on same server
 Can be used to restore db to other geographic region (in same subscription)
 If server will be deleted – it won’t be possible to perform recovery
Up to ten years with long term backup retention
Long Term Backup Retention
 Backup retention up to 10 years
 Restoring DB is possible from
PowerShell or Azure CLI
 Read-access geo-redundant
storage
 Not available for Managed
Instaces (yet)
 Storage of your own choosing
Monitoring
Monitoring
 Fully integrated with Azure Monitor
 Easy access from portal
 With some other integrations can be used to develop some kind of autoscale
Automatic Performance Tuning
Automatic Performance Tuning
 3 independently toggled options – CREATE INDEX, DROP INDEX and FORCE
LAST GOOD PLAN
 When turned off – you can implement recomendations manually
 Gets smarter with time
Advanced data security
Data discovery and classification
Vulnerability Assesment
Threat detection
Advanced data security
 Set of monitoring and mitigation tools integrated with Azure Security Center
 Can detect some of most common vulnerabilities early and give some guidelines
for fixing them
 Gets smarter over time
 Can be used to monitor environments 24/7 and notify you when something
suspicious happen
Do we need a DBA?
A little bonus – you can integrate with...
 Logic Apps
 Data factory
 Stream Analytics
 Power BI
 Azure Search
 And more!
So... It’s better than SQL Server?
Most of the times eveything just works
Unless we try to do cross database query
Well, cross database queries are possible
but not so simple anymore
1. Read my blog post about this here :
https://hryniewski.net/2018/01/25/querying-external-databases-in-azure-sql/
2. Create master key
3. Create database scoped credential
4. Create external data source
5. Create external table
6. Query some shit
Many features related to master database
Many features regarding master database
 If it touches server level – it’s probably not available
 If it touches OS level – it’s probably not available
 If it touches filesystem - yep, it’s probably not available
 Databases in Azure SQL are separate, highly isolated beings – that’s why
So, forget about...
 Always On Availability Group (but you have other stuff for that)
 BACKUP command (but you have automated backups)
 Database mail (you can try using logic app)
 Server level triggers (yuck)
 Other than primary file group
 Service broker (there are better services for that)
 Profiler (it’s obsolete anyway)
 Windows authentication
You may also need to remodel your db if
you’re using some not supported syntax
So beware if you’re using
 LOGINS (you’ll ned to switch to USERS)
 CLR (entirelly not supported)
 USE statement
 Events, query notifications etc.
 In-memory OLTP (available only in higher service tiers)
 Column store indexes (available only in higher service tiers)
Gotchas
CREATE DATABASE – Creates S0 database (can be expensive if used for
development)
Gotchas
If you’re migrating from SQL Server 2005 or lower – be aware that 100 is the
minimum compatibility level that’s supported
Gotchas
Workloads that made physical server slightly warmed up can use 100% of your
resources easily and freeze your application for a long time.
Is migration of SQL Server to PaaS hard?
Migration 101
Migration 101 (very, very short version)
 Download Data Migration Assistant from the title
 Use VNET with VPN or Express Route to OnPrem
 Set up your network ruless to allow for traffic
 Perform compatibility assesment
 Create and configure Azure Database Migration Service
 Create and configure migration project
 Run
 Go home.
Questions?
It’s not better. It’s not worse. It’s different.
Grab a beer, try it when you sober up.
@r_hryniewskifb.me/hryniewskinet

Azure SQL - more or/and less than SQL Server

  • 2.
    Azure SQL more or/andless than SQL Server
  • 3.
  • 5.
    Azure SQL more or/andless than SQL Server
  • 6.
    IOPS - input/outputoperations per second DTU – Database Transaction Unit IaaS, PaaS, SaaS – Infrastructure/Platform/Software as a Service Glossary
  • 7.
    Database possibilities inAzure And anything on VM or in a container
  • 8.
  • 9.
    MS SQL Optionsin Azure  SQL Server on VM  SQL Server on container  Site-to-site VPN with any physical machine (or other hybrid solution)  Azure SQL
  • 11.
    Azure SQL  Releasedin 2010  Database in PaaS model  Based on most recent, stable SQL Server Enterprise version  Available in DTU or vCore based pricing and scaling  Not fully compatible with SQL Server…  …unless it’s Azure SQL Database Managed Instance, then it’s almost 100% compatible.  Lots of out of the box stuff
  • 13.
  • 14.
  • 15.
  • 16.
    Resource group Azure’s logicalcontainer Azure SQL Server •Connection data •Admin credentials Database Data Billing Service tier Billing Configuration
  • 17.
  • 18.
    DTU Model  DTU– Data Transaction Unit  DTU – CPU, memory, I/O and transaction log I/O in one metric  3 Tiers – Basic, Standard, Premium  Simple, effortless model.
  • 19.
    DTU Tiers comparison Basic: 99,99% Uptime SLA  7 days backup retention  5 ms read latency  10 ms write latency  Up to 2GB storage  2.5 IOPS per DTU Standard: • 35 days backup retention • Columnstore indexing support from S3 tier • Up to 1TB storage
  • 20.
    Premium:  2 msread/write latency  Columnstore indexing support  In-memory OLTP support  48 IOPS per DTU
  • 21.
    vCore Model  Recommendedscaling model  More control upon resources during scaling  General Purpose, Business critical and Hyperscale (preview) service tiers  You’ll be billed for – service tier + no. of vCores and memory + hardware generation
  • 22.
    vCore Model -Choices  Service Tier  Hardware generation  vCores amount (memory is strictly bound to it)  Storage amount
  • 23.
    vCore Model –Service Tiers General Purpose:  Premium remote storage (like VMs)  500 IOPS per vCore (7000 max)  1 replica Business Critical:  Local SSD Storage  5000 IOPS per vCore (200 000 max)  3 replicas, 1 read-scale replica  Build in support for Availability Zones  In-memory OLTP support
  • 24.
    vCore Model –Hardware Generation Gen 4:  Up to 24 cores  Based on Intel E5-2673 v3 (Haswell) 2.4 GHz processor  Based on physical processor  7 GB memory per vCore  SSD storage Gen 5:  Up to 80 cores  Based on Intel E5-2673 v4 (Broadwell) 2.3 GHz Processor  Based on logical processor  5.1 GB memory per vCore  eNVM SSD storage (faster)
  • 25.
    Can I migrateDTU model to vCore?
  • 27.
    DTU -> vCore In standard tier each 100 DTU requires 1 General Purpose vCore  In premium tier each 125 DTU requires 1 Business Critical vCore
  • 28.
  • 29.
  • 31.
    Firewall - rules Each rule is IP range whitelist  Rules can be created only by  Server level rules can be managed with T-SQL, CLI, Powershell or REST  Databasel level rules can be managed only with T-SQL
  • 32.
  • 33.
    Scaling up –DTU model
  • 34.
    Scaling up –vCore model
  • 35.
    Scaling Up  Minimumdowntime  Sadly, no autoscaling  Still, it’s effortless...  ...and there are some workarounds that makes autoscale possible
  • 36.
  • 37.
  • 38.
    Georeplication  Creates readablereplicas (secondaries)  Manual failover  Less than 1 minute downtime  Each transaction is replicated to secondary after commiting to primary (Always On)
  • 39.
  • 40.
    Failover groups  Definestwo listeners read-only and read-write  Automatic or manual failover  Need to set grace period for data loss starting from 1 hour
  • 42.
  • 43.
    Replication and read-scaleout  Basically read-only replicas for load balancing read-only database traffic  Available in Premium (DTU) or Business Critical (vCore) Service Tiers  All it takes is use of ApplicationIntent in Connection String ie: Server=tcp:<serverName>.database.windows.net;D atabase=<db>;ApplicationIntent=ReadOnly;User ID=<login>;Password=<password>;
  • 45.
  • 46.
    Auto backup andpoint-in-time recovery  Automated backup with 7-35 days retention  Stored in included Read-access geo-redundant storage (RA-GRS)  It’s included in price!
  • 47.
    Auto backup andpoint-in-time recovery  Can be used to restore database from ANY point in time in retention period (on the same server)  Can be used to restore deleted db on same server  Can be used to restore db to other geographic region (in same subscription)  If server will be deleted – it won’t be possible to perform recovery
  • 48.
    Up to tenyears with long term backup retention
  • 49.
    Long Term BackupRetention  Backup retention up to 10 years  Restoring DB is possible from PowerShell or Azure CLI  Read-access geo-redundant storage  Not available for Managed Instaces (yet)  Storage of your own choosing
  • 50.
  • 51.
    Monitoring  Fully integratedwith Azure Monitor  Easy access from portal  With some other integrations can be used to develop some kind of autoscale
  • 52.
  • 54.
    Automatic Performance Tuning 3 independently toggled options – CREATE INDEX, DROP INDEX and FORCE LAST GOOD PLAN  When turned off – you can implement recomendations manually  Gets smarter with time
  • 55.
  • 56.
    Data discovery andclassification
  • 57.
  • 58.
  • 59.
    Advanced data security Set of monitoring and mitigation tools integrated with Azure Security Center  Can detect some of most common vulnerabilities early and give some guidelines for fixing them  Gets smarter over time  Can be used to monitor environments 24/7 and notify you when something suspicious happen
  • 60.
    Do we needa DBA?
  • 62.
    A little bonus– you can integrate with...  Logic Apps  Data factory  Stream Analytics  Power BI  Azure Search  And more!
  • 63.
    So... It’s betterthan SQL Server?
  • 65.
    Most of thetimes eveything just works
  • 66.
    Unless we tryto do cross database query
  • 67.
    Well, cross databasequeries are possible but not so simple anymore 1. Read my blog post about this here : https://hryniewski.net/2018/01/25/querying-external-databases-in-azure-sql/ 2. Create master key 3. Create database scoped credential 4. Create external data source 5. Create external table 6. Query some shit
  • 68.
    Many features relatedto master database
  • 69.
    Many features regardingmaster database  If it touches server level – it’s probably not available  If it touches OS level – it’s probably not available  If it touches filesystem - yep, it’s probably not available  Databases in Azure SQL are separate, highly isolated beings – that’s why
  • 70.
    So, forget about... Always On Availability Group (but you have other stuff for that)  BACKUP command (but you have automated backups)  Database mail (you can try using logic app)  Server level triggers (yuck)  Other than primary file group  Service broker (there are better services for that)  Profiler (it’s obsolete anyway)  Windows authentication
  • 72.
    You may alsoneed to remodel your db if you’re using some not supported syntax
  • 73.
    So beware ifyou’re using  LOGINS (you’ll ned to switch to USERS)  CLR (entirelly not supported)  USE statement  Events, query notifications etc.  In-memory OLTP (available only in higher service tiers)  Column store indexes (available only in higher service tiers)
  • 74.
    Gotchas CREATE DATABASE –Creates S0 database (can be expensive if used for development)
  • 75.
    Gotchas If you’re migratingfrom SQL Server 2005 or lower – be aware that 100 is the minimum compatibility level that’s supported
  • 76.
    Gotchas Workloads that madephysical server slightly warmed up can use 100% of your resources easily and freeze your application for a long time.
  • 77.
    Is migration ofSQL Server to PaaS hard?
  • 78.
  • 79.
    Migration 101 (very,very short version)  Download Data Migration Assistant from the title  Use VNET with VPN or Express Route to OnPrem  Set up your network ruless to allow for traffic  Perform compatibility assesment  Create and configure Azure Database Migration Service  Create and configure migration project  Run  Go home.
  • 81.
  • 82.
    It’s not better.It’s not worse. It’s different. Grab a beer, try it when you sober up. @r_hryniewskifb.me/hryniewskinet