Reader small image

You're reading from  Learning Microsoft Azure Storage

Product typeBook
Published inNov 2017
PublisherPackt
ISBN-139781785884917
Edition1st Edition
Tools
Right arrow

Implementing Azure SQL Databases

In this chapter, we will go through one of the hottest topics, especially for database administrators (DBAs): Azure SQL Database. This chapter will be kicked off by an introduction to Azure SQL Database and why you should use this service, then the service tiers and performance level, which will be followed by some demonstrations of the Azure portal regarding how to create and restore Azure SQL Database. Finally, all the manual tasks we carry out in this chapter will be automated.

The following topics will be covered:

  • An introduction to Azure SQL Database
  • Why Azure SQL Database?
  • Service tiers
  • Creating an Azure SQL Database
  • Connecting to Azure SQL Database
  • Azure SQL Database business continuity
  • Automating your common tasks with Azure SQL Database

An introduction to Azure SQL Database

A database is the most important component of most modern applications. Therefore, it is no surprise that we have two chapters of which I will cover most of the important key points and best practices for using Azure SQL Database.

Azure SQL Database is a relational database as a service, which means it follows the Platform as a service (PaaS) cloud service model, wherein you do not have to manage the underlying infrastructure, including networks, storage, servers, the virtualization layer, the operating system, middleware, or runtime. You only have to manage your databases and do not even have to think about patching and updating your servers.

Why Azure SQL Database?

Besides the reasons I've covered in the previous chapters as to why the cloud is always better than a traditional infrastructure, there are lots of other reasons for using Azure SQL Database, especially:

  • Scalability: Azure SQL Database can be scaled according to your needs and usage, and more information about that topic will be covered later in the chapter.
  • Online scaling: No downtime is needed to scale your database size. For example, you can start your application with a size that fits it in the beginning, and Azure SQL Database can respond to the database's requirements by scaling whenever necessary without causing any downtime.
  • Hardcore monitoring: Azure SQL Database provides built-in monitoring and alerting tools that can be used to identify potential problems and even recommend actions to be taken in order to fix an issue. Alerts can also...

Service tiers

Azure SQL Database is available in two flavors:

  • Elastic database pools
  • Single databases

Elastic database pools

Elastic database pools are a great solution for managing multiple databases, scaling their performance according to the databases' needs, which means it is a good fit for databases with unpredictable usage demands, and that leads to a saving on credits. Elastic database pools share performance across many databases since all of these databases are built on a single Azure SQL Database server.

At the time of writing, elastic database pools are generally available in all Azure regions, except in West India, as they are in the preview there. However, they will be generally available there too as...

Creating an Azure SQL Database

To create an Azure SQL Database via the Azure portal, perform the following steps:

  1. Navigate to the Azure portal, then to More services, and search for SQL Databases, as shown in the following screenshot:
Figure 4.1: Searching for Azure SQL Database
  1. When you open SQL databases, a new blade pops up, and if there're any SQL Databases that you created earlier, they will be displayed here. But since no SQL Databases have been created so far, it will be blank, as shown in the following screenshot:
Figure 4.2: Azure SQL Database blade
  1. To create a new Azure SQL Database, click on Add, or Create SQL databases.

  1. Once you have done so, a new blade will pop up, as shown in the following screenshot:
Figure 4.3: Creating a new SQL Database

The fields in this demonstration will be filled in as follows:

    • Database name: PacktPubDB.
    • Subscription...

Connecting to Azure SQL Database

As mentioned earlier, when you create an Azure Database via the Azure portal, all Azure services will be allowed to access this database with no further configuration.

However, when you want to connect to the database from anywhere else, there is some configuration that needs to be done.

Server-level firewall rule

To allow access to an Azure SQL Database from somewhere else, you will have to set a server-level firewall rule, as described in the following steps:

  1. Navigate to the database blade, and click on Set server firewall, as shown in the following figure:
Figure 4.9: PacktPubDB settings
  1. Once you have clicked on it, you will be navigated to a new blade, where you can create firewall...

Azure SQL Database business continuity

So far, you have your database up and running on the cloud, and you can even connect to it, create, delete, and update the tables as you wish.

I think that should satisfy most of your needs, but since a database is something critical and you need to make sure that it will not be lost if corruption occurs, you will need to take some backups.

Unfortunately, when you check the database blade, you will notice that backup is not mentioned in the blade, as shown in the following screenshot:

Figure 4.16: Azure SQL Database blade settings

How business continuity works for Azure SQL Database

Microsoft does its best to address any issues that might occur with Azure SQL Database, and it provides...

Automating the tasks

As usual, at the end of each chapter, we get our hands dirty with automation.

Creating an Azure SQL Database using PowerShell

First off, you will have to create the SQL Server on which the database will be built, and since the SQL Server needs an admin name and a password, they will be created and stored in variables:

$SQLAdmin = “SQL Admin User Name”
$Password = “SQL Admin Password”

Then, you can work on creating the SQL Server with the following cmdlets:

New-AzureRmSqlServer -ResourceGroupName PacktPub -ServerName packtpubsqlps -Location WestEurope -SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $SQLAdmin,$(ConvertTo...

Summary

So far, we have covered basic concepts about Azure SQL Database and the reasons to use them. In addition, we looked at an overview of service tiers and performance levels, which will help with designing your database solution. Also, some demonstrations were implemented in order to have a better understanding of what is going on when you deal with things in Azure.

Next, some topics that have been mentioned in this chapter and some of the main concerns, such as security, will be covered in more detail in the coming chapter.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Microsoft Azure Storage
Published in: Nov 2017Publisher: PacktISBN-13: 9781785884917
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime