on October 4, 2021
I’m working through a series of tutorials and learning paths for Azure SQL and sharing bite-sized reviews.
In this first walkthrough, I’m stepping through the Create a Single Database tutorial.
A nice feature: choose if you wish to work in the graphic portal or in a command line
It’s really nice that the Quickstart offers multiple options to learn.
You can get instructions to walk through steps in the portal if you prefer, or you get three different options for working in a command line. Switching between these is as simple as clicking on tab headings in the Quickstart:
It’s convenient that you can run the Azure Cloud Shell in the same browser page as the documentation to try out the example. It’s nice to not need to open a separate terminal and toggle between windows.
What’s the difference between the Azure CLI, Azure CLI (sql up), and PowerShell examples?
I was immediately a bit puzzled as to why I have three command line options. This is a lot of choices!
Here’s how the three command line options compare and why you might choose one over another:
Option | Description | Why you would use it | Type of Azure SQL Database created in Quickstart |
---|---|---|---|
Azure CLI | This example utilizes a variety of commands that are part of the Azure CLI (command line interface). This example is written for the Bash shell. | You want more granular control over the database creation process. You are comfortable with or wish to learn Bash syntax. | Serverless, Gen 5, 2 vCores |
Azure CLI (sql up) | This example utilizes the Azure CLI and the example is written in the Bash shell. This example is much shorter, as it leverages the az sql up command – which can create the resource group, logical server, and database in a single command. | You want a single Bash command to quickly create an Azure SQL Database. | Provisioned, Gen 5, 2 vCores |
PowerShell | This example utilizes the Azure CLI but is written with PowerShell cmdlets and utilizes PowerShell syntax (instead of Bash commands and bash syntax). | You want more granular control over the database creation process. You are comfortable with or wish to learn PowerShell. | Serverless, Gen 5, 2 vCores |
Note that one line examples of the Azure CLI will work in any shell.
The PowerShell example worked perfectly
I’ve created Azure SQL Databases in the Portal quite a few times in the past. I have less experience using the command line options to create and manage Azure SQL Databases, so I wanted to try those out and learn more.
First I stepped through the PowerShell example using the in-browser Azure Cloud Shell. That worked very well.
At one point I needed to work on something else in the middle of trying the example. I found I needed to restart the browser shell, and it cleared out the parameters I was using. I simply restarted the example from the beginning and it all worked perfectly a second time through, even though I’d stopped mid-way.
The “sql up” example threw an error
Next I stepped through the Azure CLI (sql up) example. In the PowerShell example you could simply copy and past all the commands without modifying them, with the exception of needing to specify your own IP address for a firewall exception. That didn’t work this time. I ran the command as given:
az sql up \
--resource-group $resourceGroupName \
--location $location \
--server-name $serverName \
--database-name mySampleDatabase \
--admin-user $adminlogin \
--admin-password $password
This resulted in an error:
argument --resource-group/-g: expected one argument
I looked at what I’d run and realized that I hadn’t ever initialized the variables $resourceGroupName
, $location
, $serverName
, $adminlogin
, and $password
. I needed to either add a block of text assigning those values, remove the variables altogether (sql up will create defaults), or use literal values.
I changed my command to this:
az sql up \
--resource-group myResourceGroup \
--location eastus \
--server-name server-$RANDOM \
--database-name mySampleDatabase \
--admin-user azureuser \
--admin-password Azure1234567!
This worked, and created a resource group, logical server, and Azure SQL Database all in one step!
This was pretty fun to see this happen all in one command.
Highlights and lowlights
There’s a lot to like about the Quickstart experience with Azure:
-
One thing I’ve noticed over the years is that Microsoft has made it incredibly easy to configure initial firewall rules when setting up an Azure SQL Database. Configuring the firewall is part of the examples. If you are using the Azure Portal, SQL Server Management Studio, or Azure Data Studio to query an Azure SQL Database, they will attempt to help you configure firewall rules if needed.
-
Another thing I noticed is that the Quickstarts create a resource group at the beginning of the example. At the end of the example, they show you how to clean up everything you created by deleting the resource group. That’s a nice, simple way to help the user not need to manually delete items or risk leaving things around.
If there’s a lowlight, it’s simply that it can take a bit of time for things to spin up.
This is totally reasonable – when you step through the Quickstart, you are creating real resources in Azure. There’s a fair amount going on in the background.
However, you might be waiting for a minute or two at different points along the way. One nice thing about having the Azure Cloud Shell in the browser with the documentation is that you can read the documentation on the same page while you wait, and just keep an eye out to see when your command completes.