Introducing Azure SQL Database

Azure SQL Database Deployment using Azure PowerShell

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

This video segment walks the viewer through the deployment of Azure SQL Server and database using Azure PowerShell.


  • Azure PowerShell
  • deploy Cloud setup Azure SQL instance Cloudshell

About this video

Peter De Tender
First online
09 August 2019
Online ISBN
Copyright information
© Peter De Tender 2019

Video Transcript

Hey, there. Welcome or welcome back to this Apress course on Azure SQL. This video shows you how to deploy an Azure SQL database using Azure PowerShell.

In this section, you get introduced to running an Azure SQL instance deployment by using Azure PowerShell. Starting with some key information, I will quickly switch to a demo and showing you how to run that deployment.

Like any other PowerShell automation you want to use, it all starts with having the correct modules installed and even more important making sure they are the latest versions available. In order to deploy an Azure SQL Server or Azure SQL database instance using PowerShell, you need to have the correct Azure permissions first of all, allowing you to connect to the Azure subscription, but also allowing you to deploy and administer your Azure SQL instance. Next, you need to validate if you’re running the correct Azure PowerShell modules, the more general ones, like networking and storage, but obviously also the Azure SQL PowerShell module specifically.

Now, here as an example, I want to walk you through the different components for what a PowerShell script to deploy Azure SQL could look like. We start with the authentication step, obviously, where in case of having multiple subscriptions linked to your account, you would use the Set-AzContext and highlighting the subscription you want to use for that deployment.

Next, we’re going to create a resource group, unless you want to deploy into an existing resource group. That would obviously also work. The commandlet in PowerShell to create a new Azure resource group would be New-AzResourceGroup, specifying the name and location you want to use for that one.

Then lastly, we’re going to define a collection of variables, like the server name, a location, similar to required parameters during a portal-based deployment. The main PowerShell commandlet that follows for the actual creation of the SQL Server would be New-AzSqlServer.

Next, we provide the server name, the location. And then optionally, if you want, you could provide like a new variable asking for administrative credentials or during that initial deployment waiting for input like what I’m going to show you in a demo, instead of providing those credentials. Another option could even be integrating with the secret store measure called Azure Key Vault, where you’re going to store your administrator username and password, and having that picked up during the Azure PowerShell-based deployment.

While it’s hopefully interesting to learn about the different parts of your PowerShell script, let me show you what it looks like in another demo. I have a couple of options here to deploy or even define your integration with Azure from a PowerShell perspective. But the easiest one for me is integrating with Cloud Shell.

So Cloud Shell is a little web-based Linux environment that allows you to switch. As you can see here, it’s starting up from my latest option, which was a Linux mesh environment. But from here, I can easily switch to PowerShell.

The advantage is that I don’t need to install any modules, any specific latest module versioning to be managed. And next to that, it’s already recognizing my Azure subscription, since I’m already authenticated in the Azure portal. So from here, I can basically focus on creating a new resource group and running my SQL deployment.

So it’s going to start with creating that resource group, followed by recognizing or defining my parameters, and finally running the deployment script, where since I didn’t provide any specific credentials in my script itself, it’s going to ask me for that information during that deployment. And then from here, I could check back if my deployment is running, starting from my Resource Groups, where I have my Az SQL Power Shell Resource Group. And it’s holding that SQL Server instance. So it looks like a perfect deployment.

So with that, we’re at the end of this video, where I walked you through the concepts of deploying Azure SQL using PowerShell, highlighting a sample script structure, and showing you in a live demo what it looks like.