AZURE SQL Database

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

Azure SQL Database

If you want to host your database oriented application in cloud, you have two options if you want
to use Microsoft SQL database

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-paas-vs-sql-server-iaas

1. Azure SQL (PaaS) Database


2. SQL Server on Azure VMs (IaaS)

What is SQL Azure?


As stated above SQL Azure is Microsoft’s cloud database released in 2010, Platform as a
Service (PaaS) built on Windows Azure cloud computing platform. SQL Azure enables
organizations build database oriented applications in cloud to store relational data in the cloud.

Microsoft has recently changes the name of offering to Microsoft Azure SQL Database. It
enables you to leverage tools like Visual Studio, SQL Server Management Studio,
PowerShell, REST APIs and Azure Management Portal

Following image depicts where SQ Azure stand vs SQL Server.

SQL Azure Vs SQL Server


As we know now that there are two options to host database in azure cloud, let try to compare
both and see which is suitable in which scenario.

Azure SQL Database SQL Server on Azure Virtual Machines

This is Platform as a Service (PaaS) This is an Infrastructure as a Service


database or also referred as Database as (IaaS)
a Service (DBaaS)

This is a SQL database native to the SQL Server installed and hosted in the
Azure SQL Database SQL Server on Azure Virtual Machines

cloud. cloud on Windows Server Virtual


Machines (VMs) running on Azure.

Hosting server is isolated from you, You get full control of server on VM, you
servers are maintained by Microsoft and will be responsible for maintaining server
takes care of patches and updates. like patches and updates.

It is optimized for software-as-a-service SQL Server on Azure virtual machines is


(SaaS) app development optimized for migrating existing SQL
Server applications

It is perfect choice when your It is a perfect choice when an


organization does not want to invest on organization already has IT resources
resources to maintain servers. available to maintain the virtual
machines.

It provides built-in high availability, Need to configure and manage high


disaster recovery, and upgrade for the availability, disaster recovery, and
database. patching for SQL Server.

Your on-premises application can access With SQL Server on Azure VMs, you can
data in Azure SQL Database. have applications that run partly in the
cloud and partly on-premises.

Supports SQL Server transactional Fully supports SQL Server transactional


replication as a subscriber to replicate replication, AlwaysOn Availability
data. Groups, Integration Services, and Log
Shipping to replicate data.

Low Capital expenditure (CAPEX), you High Capital expenditure (CAPEX), you
don’t need to buy servers and expensive will have to buy servers and software
software licenses as your initial licenses as your initial investment
investment

Easily scalable, as it’s a cloud offering it’s Difficult to scale, you will have to buy
very easy to add resources as required hardware and probably might need
and remove them when not required, downtime too.
without any downtime.

For SQL Azure – Basic, Standard, Premium, and Premium RS service tiers Microsoft provides
an availability SLA of 99.99%.

Azure SQL Database is a fully managed, relational database in the Azure cloud as platform-as-
a-service offering. Microsoft handles all patching and updating of the SQL server and takes
away all management of the underlying infrastructure.
Azure SQL Database offers Basic, Standard, Premium, and Premium RS service tiers for
both single databases and elastic pools.

What are different offering of SQL Azure?


SQL Azure is offered with different pricing tiers, out of which main are Basic, Standard and
Premium.

Basic tier is used for light workloads. This is good for small use, new projects, testing,
development, or learning.

Standard  tier is used for most production online databases. The performance is more
predictable than the basic tier.

Premium tier is more robust and performance is typically measured in seconds.

Following image shows the Features vs Pricing Tiers, as features differ across pricing tiers.

Performance per tier

Basic tier can handle 16,600 transactions per hour.


Standard tier can handle 2,570 transactions per minute.
Premium tier can handle 735 transactions per second. That translates to 2,645,000 per hour in
basic tier terminology.

SQL Azure provides various database service options,  such as database transaction units
(DTU’s), max database size, disaster recovery options, and backup retention period, instead of
hardware (CPU/RAM/HD). 
What is DTU?
Database Transaction Unit (DTU) is a way to describe the relative performance level of a
database. The database can be created using Basic, Standard, or Premium pricing tier.

DTUs are based on a blended measure of CPU, memory, reads, and writes.

DTUs
There are two ways that you can deploy Azure SQL in Microsoft Azure. The first, and the most
common one that I see, is the Single database option. When you select a Single database,
Azure deploys 1 database that runs in it’s on bubble of performance. The database has  several
ways to size it’s performance, but the most commonly quoted and confusing one is Database
Transaction Units (DTUs).

Every database in Azure SQL offers a maximum number of DTUs. But what the heck are these
things? I’ve heard of IOPS, virtual CPUs, RAM, and so on, but DTU was a new one to me.

Microsoft describes DTUs as being:

… a blended measure of CPU, memory, I/O (data and transaction log I/O)

The goal of DTUs is to simplify the planning of performance for a database. There’s a good
chance that you’ve had a part in this conversation before:

 Database/App developer: “I’d like a database server, please.”


 IT Pro: “OK. How much CPU do you need?”
 Database/App developer: “Average … whatever the normal is.”
 IT Pro “Uh … OK. How many IOPS do you need?”
 Database/App developer: “What’s an IOP?”

And in the end, either too many or too few resources are provided and no one is happy. DTUs
take the metrics that determine the performance of a database and mush them together in a
measure that we can use to abstract and compare performance. I have no idea what a “brake
horsepower” is, but I know that a car with 500BHP is probably a lot more fun than one with
100BHP. The same goes for databases; the S7 database with 800DTUs offers a performance
baseline that is 40 times more than an S1 database with 20DTUs.

When you deploy an Azure SQL single database, you will pick one of the sizes. The main, but
not the only, performance limits of that size will be DTUs. The database will be able to scale up
to the documented DTU limit. If a database hits that limit:

 It will have no impact on any other database and no other database will have an impact on it.
 Query performance will degrade in the form of higher latency.

Microsoft provides a number of tools/methods to help you understand the DTU requirements of
existing SQL Server databases. Using this information you can correctly size and Azure SQL
single database before a migration.

Elastic Pools and eDTUs


A larger organization might have a number of databases that are:

 Hard to size because they are new.


 Very “bursty”, sometimes needing a lot of DTUs and sometimes needing only a few.

In this case, Microsoft offers an alternative to a single database. The elastic pool is a collection
of databases that share eDTUs or elastic DTUs. This is a similar kind of measure but how it is
used changes. Instead of being applied to a single database, an eDTU applies to a pool of
databases that share resources in an elastic pool, measuring the performance potential of the
entire pool instead of a single database.

Each database in the pool is capable of using a few or lots of the entire pool’s performance
capacity. If a single database needs to have a burst in performance, it can do so within the
constraints of the pool. This would impact other databases in the same pool, but has no impact
on any database outside of the pool.
Databases in an Elastic Pool Sharing the eDTUs of that Pool [Image Credit: Microsoft]

You might decide that some databases need a change in plan and this is possible:

 A single database might underuse it’s DTUs or prove to be “bursty” and might be more suitable to be part of
a pool. You can move the database into an elastic pool. The database can use the pool of eDTUs and the cost of
owning/operating the database should come down.
 A database that is already in a pool might require too many resources to remain in that pool; you can move
it out to become a single database with its own DTUs.
After SQL elastic pools are created, we can add new datbase to that
How to Create SQL Azure Database?
You can create Azure SQL Database databases using the Azure portal, PowerShell, the Azure
CLI, Transact-SQL, and the REST API.

Powershell:

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-get-started-powershell

Create Database from Azure Portal


To create database using ARM portal, login to the portal and navigate to NEW menu as shown
below.

New -> Database -> SQL Database -> provide the required details.

Once you click on create button, SQL Server and


SQL Database gets created. You can see server and
database in all resources section.

If you use – Source as Adventure works ITit has benn it has some db inside it

Elastic pool come into picture if ur using mutlpie DBs


Adding firewall rules for SQL database

We can use query option to serach queries from portal only


How to use SQL Azure Database?
Once you create database in SQL Azure, there are multiple ways to consume or use that
database.

1. Using SQL Server Management Studio

You need to install appropriate version of SQL Server Management Studio on your machine, in
order to connect to database. for demo purpose i am using VM in Azure.

Step 1: Install SQL Server Management Studio (SSMS)

If you don’t have SSMS on your machine you can install free version from Microsoft

Step 2: Connect to Database

Once you open SSMS, you will be prompted for Server name and credentials. if you are
connecting from your local machine make sure appropriate firewall setting are done at database
level so that it allows you to connect.

Provide server name as FQDNe.g. mydbserversci.database.windows.net , user name,


password and name of the database which you provided while creating.
Once you connect with proper credentials and server details, you will see the database structure
in SSMS as standard on-premises  SQL server as follows. From here your can create, modify,
delete all the artifacts related to database.

2. Using Visual Studio Azure Explorer & LINKpad (for developers)

Microsoft Visual studio server explorer gives you option to connect to your Azure tenant and the
services in Azure including SQL Azure database.
You get two options, either to open database in SQL server object browser or Management
Portal.

If you chose to open database in SQL Server object explores, you will get to see options to
create artifacts in database, as follows.

What is Geo-Replication?
Geo-replication is designed to improve the distribution of data across geographically
distributed data networks.  E.g. you have your OLTP SQL Azure database in West India zone,
you can configure to copy/replicate database from West India zone to South India zone.

This is intended to improve the response time for web portals, are you can setup geo-replication
with active mode too, which enables to read data from secondary copy.

Geo-replication in SQL Azure (async)


But sync to other db option in sql is sync

Every Azure SQL Database subscription has built-in redundancy. Three copies of your data are
stored across fault domains in the data center to protect against server and hardware failure.
This is built in to the subscription price and is not configurable. The source and target servers
must belong to the same subscription.

 
You can configure two more fault-tolerant options: standard geo-replication and active geo-
replication.

Standard geo-replication allows the user to fail over the database to a different region when a
database is not available. It is available on the standard and premium service tiers. Standard
geo-replication does not allow clients to connect to the secondary server. It is offline until it’s
needed to take over for the primary.

Active geo-replication allows clients to connect to the secondary server for read only data. This
helps systems to run BI related compute intensive jobs on secondary, and help to reduce
workload from primary server.

How  to configure Geo Replication for SQL Azure


There are couple of ways you can configure Geo Replication for your SQL Azure database.

1. From Azure Portal


2. Using PowerShell

Let’s see one by one.

Configure From ARM Portal


You can configure Geo Replication from ARM portal for existing SQL Azure database. Lets see
step by step how can achieve that.
After failover
Step 1: Create SQL Azure database

To more about how to create SQL Azure database please refer article Create and use SQL
Azure Database

Step 2: Configure Geo replication

You need to navigate to the properties of existing SQL Azure database, in the properties blade
select Geo Replication option.

You will be shown another blade with your primary database region and option to select region
for your secondary database.

Select the desired Azure data center location, it by default recommends you the nearest data
center so that if you want to use as a read only source it would give better performance.

Step 3: Select Secondary Type

As my primary database is in West India data center, i am recommended to replicate to nearest


which is South India.

once you select the region, next is to select the type of secondary database (Readable or Non-
Readable)
I have opted for readable option here, so that i use my secondary database for reporting
purpose.

Step 4: Create Secondary Server

Once you select secondary type you need to create backend SQL Server which will be used to
create and host your database copy.

once all the settings are configured, click on the OK button to process the request of Geo
Replication.

Step 5: Verify Geo Replication

You can verify Geo Replication from ARM portal. You will see, both primary and secondary
databases.
Configure Using PowerShell

Another option for you to create online or offline secondary database is using Windows
PowerShell with Start-AzureSqlDatabaseCopy cmdlet.

To create an online secondary, use the following command

Start-AzureSqlDatabaseCopy -ServerName "SourceServer" -DatabaseName "SourceDB" -PartnerServer "DestinationServer" –


ContinuousCopy

To create an offline secondary, use the following command:

Start-AzureSqlDatabaseCopy -ServerName "SourceServer" -DatabaseName "SourceDB" -PartnerServer "DestinationServer" –


ContinuousCopy –OfflineSecondary

Azure Database for MySQL servers (3306 port maybe)

Azure database for MySQL servers and Azure database for PostgreSQL servers are DBAS
No Azure Database for MySQL servers to display
Version – 5.6, 5.7

We can connect the above using MySQL workBench

You might also like