Practical SQL Azure: Moving into the cloud

41
Moving into the Cloud Practical SQL Azure

description

SQL Azure has been around for a few years now but you are still running all of your databases locally. You would like to use the cloud but you just aren't sure where to start. This presentation will get you started down the right path. We will start by going over the basics of SQL Azure, including what it is, how to set it up and what the benefits and drawbacks are of it. Next, we will look at how to move an existing database into SQL Azure. Finally, we will look at how to take advantage of the benefits of the cloud to make your SQL database safer and more redundant. By the end of this presentation, you should have a good understanding of where you could go with SQL Azure and how to get there.

Transcript of Practical SQL Azure: Moving into the cloud

Page 1: Practical SQL Azure: Moving into the cloud

Moving into the CloudPractical SQL Azure

Page 2: Practical SQL Azure: Moving into the cloud

Timothy Corey

@IAmTimCorey

www.TimothyCorey.com

www.Epicross.com

(570) 291-7789

Lead Technical Consultant at Epicross

PMP, MCP, A+

Page 3: Practical SQL Azure: Moving into the cloud

TODAY’S ROADMAP

A quick overview of SQL Azure,

including some of the advanced

features including load balancing

and local backups.

What is SQL Azure?We will look at how to take our

local database, fix any

compatibility issues and move it

into the cloud.

How do we get there?Security, redundancy and cost

prevention – we are going to look

at all of these and more.

What are the Best Practices

1 2 3

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 4: Practical SQL Azure: Moving into the cloud

WHAT THIS IS NOTThe top 4 reasons to get up and walk out the door right now

You need the one solution for all databasesIf you are looking for that perfect solution that

works in every situation, SQL Azure isn’t for you.

Maybe try XML. I hear that is pretty versatile.

You are looking for SQL Server installed on VMsInstalling SQL Server on an Azure Virtual

Machine can be a great solution. However, we

are not going to be covering this topic in this

session.

You need total control over your database installationBy using SQL Azure, you are giving some

control of how the database server is managed

over to Microsoft.

You cannot make any changes to your databaseYou may need to make changes to your

database in order to move it to SQL Azure.

These changes include adding clustered

indexes and changing how SQL jobs work.

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 5: Practical SQL Azure: Moving into the cloud

BENEFITS OF SQL AZUREWhy would we want to use this service anyway?

• Easy to set up• Easy to maintain• Continually kept up to date• Guaranteed SLA of 99.9%[1]

• Geo-redundant servers[2]

• Inexpensive• Scalable• Read-only replicas

Before the cloud, what would it take to create a geo-redundant SQL Server that is load-balanced and has multiple read-only secondary failover servers that can be used for reporting until they are needed to pick up for a failed primary server? What would the licensing costs be? How much would it take to keep these servers up to date on the latest security patches?

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

[1] http://azure.microsoft.com/en-us/support/legal/sla/[2] On the Premium version

Page 6: Practical SQL Azure: Moving into the cloud

PART 1 – SQL AZURE OVERVIEW

A quick overview of SQL Azure,

including some of the advanced

features including load balancing

and local backups.

What is SQL Azure?We will look at how to take our

local database, fix any

compatibility issues and move it

into the cloud.

How do we get there?Security, redundancy and cost

prevention – we are going to look

at all of these and more.

What are the Best Practices

1 2 3

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 7: Practical SQL Azure: Moving into the cloud

DEMO

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 8: Practical SQL Azure: Moving into the cloud

SETTING UP A DATABASECreating a clean SQL database on Microsoft Azure

Once you are logged into Azure, either click on the “NEW” button

in the lower left corner of the portal or under the SQL Databases

section, select “Create a SQL Database”.

Step 1 – Start the Process

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 9: Practical SQL Azure: Moving into the cloud

SETTING UP A DATABASECreating a clean SQL database on Microsoft Azure

Under the NEW menu you have the option of Quick Create. This

option allows you to create the database with the least amount

of work. Later, you can configure any extra options you want.

If you used the “Create a SQL Database” link or if you choose

Custom Create from the NEW menu, you will have the option to

specify the database size, server, and a couple other options

before creating the database.

Step 2 – Create a Database

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 10: Practical SQL Azure: Moving into the cloud

SETTING UP A DATABASECreating a clean SQL database on Microsoft Azure

Here you get to fill in all of the relevant details. Note that I

selected the Custom Install option to get to this step. This allows

me to be more specific in the creation of my database. For

example, I can specify the Edition and Max Size right away. Also,

when I select “New SQL database server” for the Server, I get a

second page to this wizard for setting up the server.

Step 3 – Specify the Details

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 11: Practical SQL Azure: Moving into the cloud

SETTING UP A DATABASECreating a clean SQL database on Microsoft Azure

Here you need to specify the admin login information and the

Region. The region is a big deal for a couple reasons. First, the

farther away your applications are from your database, the higher

the latency. Second, if you are going to be interacting with other

services and if they are in the same region then you will not be

paying bandwidth costs.

Step 4 – Create the Database Server

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 12: Practical SQL Azure: Moving into the cloud

SETTING UP A DATABASECreating a clean SQL database on Microsoft Azure

After about 10 seconds, your new database will show up in the

list like so. Now that you have created your database, you will

need to configure it.

Job Complete!

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 13: Practical SQL Azure: Moving into the cloud

DEMO

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 14: Practical SQL Azure: Moving into the cloud

CONFIGURING A DATABASEModifying SQL database settings in Microsoft Azure

Find the SQL Database you want to modify in your Microsoft

Azure portal and click the arrow next to it. When it opens up, you

will come to this screen. This is a quick overview of the most

useful items for accessing your database.

If you ever want to get back to this screen from the dashboard or

other pages, click the cloud with the lightning bolt in the upper

left of the screen.

Step 1 – Open Up Your Database

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 15: Practical SQL Azure: Moving into the cloud

SETTING UP A DATABASECreating a clean SQL database on Microsoft Azure

Click on “Design your SQL database” to bring up the web login to

your server. Before you can actually log in, though, you will need

to have added your IP address to the allowed IP addresses list.

Otherwise, you will get an error.

Step 2 – Log Into Your Database

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 16: Practical SQL Azure: Moving into the cloud

SETTING UP A DATABASECreating a clean SQL database on Microsoft Azure

Now that you are logged into the web interface of your SQL

database, you can add tables, views and stored procedures right

from the web page.

You can also connect to the database via SQL Server

Management Studio (SSMS) and perform these same actions.

Step 3 – Add SQL Objects

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 17: Practical SQL Azure: Moving into the cloud

PART 1 – SQL AZURE OVERVIEW

A quick overview of SQL Azure,

including some of the advanced

features including load balancing

and local backups.

What is SQL Azure?We will look at how to take our

local database, fix any

compatibility issues and move it

into the cloud.

How do we get there?Security, redundancy and cost

prevention – we are going to look

at all of these and more.

What are the Best Practices

1 2 3

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 18: Practical SQL Azure: Moving into the cloud

PART 2 – MIGRATING TO AZURE

A quick overview of SQL Azure,

including some of the advanced

features including load balancing

and local backups.

What is SQL Azure?We will look at how to take our

local database, fix any

compatibility issues and move it

into the cloud.

How do we get there?Security, redundancy and cost

prevention – we are going to look

at all of these and more.

What are the Best Practices

1 2 3

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 19: Practical SQL Azure: Moving into the cloud

FIX INCOMPATABILITIESMigrating to SQL Azure

Migrate to SQL Azure

using SSDT

bit.ly/ASMigrateMicrosoft’s guidelines on

Azure SQL databases

bit.ly/ASGuideOptions for moving

Access, MySQL, Oracle or

Sybase databases to SQL

Azure

bit.ly/ASConvertA tool for preparing a

database for identifying

issues and migrating to

Azure

bit.ly/ASWizard

• Missing Clustered Index• Extended Properties• Asymmetric / Symmetric Keys• FileTables

• Full Text Indexes• XML Collections / Indexes• User Defined Types (CLR)• Replication

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 20: Practical SQL Azure: Moving into the cloud

PACKAGE THE DATABASEMigrating to SQL Azure

The different Data Tier

options, including creating

DACPAC and BACPAC

files

bit.ly/ASDataTierA guide for moving your

local SQL database to

Azure SQL

bit.ly/ASMoveA breakdown of the

different tools from

Microsoft for migrating

bit.ly/ASToolsA guide for creating Azure

Storage and then using it

to transfer your SQL

database

bit.ly/ASStorage

• DACPAC – Just the schema of the database (Extract)• BACPAC – The schema and data (Export)• Scripts – User-generated scripts to re-create the database

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 21: Practical SQL Azure: Moving into the cloud

DEMO

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 22: Practical SQL Azure: Moving into the cloud

CREATING A BACPACCreating a data extract file that can be uploaded to Windows Azure

In SSMS, right-click on your database and select “Export Data-tier

Application” under the Tasks menu. This will kick off the BACPAC

wizard.

Step 1 – Start the Wizard

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 23: Practical SQL Azure: Moving into the cloud

CREATING A BACPACCreating a data extract file that can be uploaded to Windows Azure

The first screen of the wizard is simply an overview of what the

process will entail. You can hide this page from showing up in the

future.

Step 2 – Acknowledge the Overview

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 24: Practical SQL Azure: Moving into the cloud

CREATING A BACPACCreating a data extract file that can be uploaded to Windows Azure

You can either export the BACPAC file to disk (as I am doing

here) or you can send it directly to Windows Azure. If you upload

it to Windows Azure, you will need to have a storage account.

SQL Azure needs a storage account if it is to import a BACPAC

file or export it (which we will see later).

The advanced tab is for if you would like to limit what items get

put into your BACPAC file. In our case, we will do everything.

Step 3 – Choose the Export Location

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 25: Practical SQL Azure: Moving into the cloud

CREATING A BACPACCreating a data extract file that can be uploaded to Windows Azure

This screen gives you an overview of your selected options and

gives you a chance to go back before the process actually starts.

In our case, we are exporting all of our tables (and other items)

from the Northwnd database to a local BACPAC file.

Step 4 – Review the Settings

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 26: Practical SQL Azure: Moving into the cloud

CREATING A BACPACCreating a data extract file that can be uploaded to Windows Azure

The first time you run this wizard, you might get a screen like this.

A failed export typically means you have something in your local

database that is not compatible with SQL Azure. Remember

earlier we talked about the incompatibilities that need to be fixed

before we move to the cloud. This error indicates that we did not

fix all of them yet.

Step 5 – Failed Operation

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 27: Practical SQL Azure: Moving into the cloud

CREATING A BACPACCreating a data extract file that can be uploaded to Windows Azure

Clicking on the error link will give you a dialog like this one. This

dialog will give you information on every error in your database

that is preventing you from moving to SQL Azure. You can use

Ctrl+C to copy the text out so you can paste it into Notepad.

In this case, our errors all revolve around not having clustered

indexes on certain tables. Once the errors are fixed, this wizard

will need to be restarted.

Step 6 – Fixing the Errors

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 28: Practical SQL Azure: Moving into the cloud

CREATING A BACPACCreating a data extract file that can be uploaded to Windows Azure

If you have no errors, or if you resolve them all before running

the wizard, you will come to this screen. This indicates that your

BACPAC file is created and ready to be uploaded to SQL Azure

(if you didn’t do that as part of this wizard).

Job Complete!

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 29: Practical SQL Azure: Moving into the cloud

DEMO

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 30: Practical SQL Azure: Moving into the cloud

DIRECT DEPLOY TO AZURETake a snapshot of your database and load it directly to a new SQL Azure database

In SSMS, right-click on your database and select “Deploy

Database to Windows Azure SQL Database” under the Tasks

menu. This will kick off the upload wizard.

Note that this option is available in SSMS 2012 and up only. It is

also worded as “Deploy Database to SQL Azure” in SSMS 2012

(the wording above is from SSMS 2014).

Step 1 – Start the Wizard

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 31: Practical SQL Azure: Moving into the cloud

DIRECT DEPLOY TO AZURETake a snapshot of your database and load it directly to a new SQL Azure database

You will need to specify the SQL Azure instance to connect to,

the name of the new database and the initial settings for the

database.

Note that you are not asked about an Azure Storage account.

This new method bypasses the need for a storage account. It still

creates the BACPAC file though.

Step 2 – Set the Deployment Settings

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 32: Practical SQL Azure: Moving into the cloud

DIRECT DEPLOY TO AZURETake a snapshot of your database and load it directly to a new SQL Azure database

This screen gives you an overview of your selected options and

gives you a chance to go back before the process actually starts.

In our case, we are exporting the Northwnd database to SQL

Azure, creating a new database called Northwnd and setting it

up to be 1 GB in size.

Step 3 – Confirm the Settings

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 33: Practical SQL Azure: Moving into the cloud

DIRECT DEPLOY TO AZURETake a snapshot of your database and load it directly to a new SQL Azure database

When you get to this screen and all the checkboxes turn green,

you will be all set. Your new database will be live in SQL Azure.

Job Complete!

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 34: Practical SQL Azure: Moving into the cloud

PART 2 – MIGRATING TO AZURE

A quick overview of SQL Azure,

including some of the advanced

features including load balancing

and local backups.

What is SQL Azure?We will look at how to take our

local database, fix any

compatibility issues and move it

into the cloud.

How do we get there?Security, redundancy and cost

prevention – we are going to look

at all of these and more.

What are the Best Practices

1 2 3

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 35: Practical SQL Azure: Moving into the cloud

PART 3 – BEST PRACTICES

A quick overview of SQL Azure,

including some of the advanced

features including load balancing

and local backups.

What is SQL Azure?We will look at how to take our

local database, fix any

compatibility issues and move it

into the cloud.

How do we get there?Security, redundancy and cost

prevention – we are going to look

at all of these and more.

What are the Best Practices

1 2 3

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 36: Practical SQL Azure: Moving into the cloud

DATA SECURITYSQL Azure Best Practices

• Only allow specifically-needed IPs• Guard your connection strings• Use common sense

Security in SQL Azure is fairly simple. Microsoft takes care of most of the security for you. However, you need to be sure to use common sense when it comes to what you do control. Don’t allow people to see your connection strings, don’t give out your password, and don’t allow IP addresses without care. Hopefully, you are thinking “duh!” to all of this.

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 37: Practical SQL Azure: Moving into the cloud

DATA SAFETY AND AVAILABILITYSQL Azure Best Practices

• Turn on the Automated Export feature of your database (under the Configure tab) to back up your database on a periodic basis.

• Set up a Sync group to keep two databases (or just part of the databases) in sync. More information at bit.ly/ASSync

• For Premium databases, you can set up Geo-Replication for site redundancy. More information at bit.ly/ASGeoRedundant

SQL Azure is a high-availability environment. However, that does not mean that nothing bad will ever happen. You need to find your balance between availability and expense. Automated backups are cheap and easy but you won’t have a way to fail over quickly. On the other end, Geo-replication is a way to keep your server running even in a catastrophe but it is much more expensive.

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 38: Practical SQL Azure: Moving into the cloud

COST PREVENTIONSQL Azure Best Practices

• Use the same region for your servers that communicate with each other – Inter-region traffic is free

• Use SQL Azure instead of SQL on an Azure VM whenever possible• Use the least expensive backup solution that meets your needs• Remove stored BACPAC files when no longer needed

Basically, you need to try to keep things inside your same region whenever possible. Outside of that, know what the choices you are making mean when it comes to pricing. If you aren’t sure, contact a Microsoft representative or vendor to be sure. Don’t just guess and take the risk of blowing up your bill.

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 39: Practical SQL Azure: Moving into the cloud

PART 3 – BEST PRACTICES

A quick overview of SQL Azure,

including some of the advanced

features including load balancing

and local backups.

What is SQL Azure?We will look at how to take our

local database, fix any

compatibility issues and move it

into the cloud.

How do we get there?Security, redundancy and cost

prevention – we are going to look

at all of these and more.

What are the Best Practices

1 2 3

Practical SQL Azure: Moving into the CloudSQL Saturday #294 - Philadelphia

Page 40: Practical SQL Azure: Moving into the cloud

QuestionsSlides are on Slideshare at bit.ly/ASPresentation

Ping me via Twitter if you have questions later

Finally, I’m 6’8”. Yes, that IS tall. And yes, I played

basketball in High School.

?

Page 41: Practical SQL Azure: Moving into the cloud

Go Forth and Be Awesome!

@IAmTimCorey

www.Epicross.com

www.TimothyCorey.com

[email protected]