Book a Demo Free Trial

Azure Management Cmdlets Now Support SQL Azure

Gaurav Mantri

Oct 29, 2010

Category: General

Today we released a new version of Azure Management Cmdlets in public beta. In this version, we have focused exclusively on SQL Azure. This new version includes 7 cmdlets which will help users do some basic management tasks on SQL Azure databases. Following is the list of cmdlets for SQL Azure Management:

Backup-Database

Backs up a SQL Azure database using bcp.exe utility and saves the data on local computer. Optionally this cmdlet can also upload the data in blob storage as well after saving it to local disk.

Copy-Database

Copies one SQL Azure database to another in same database server.

Get-DatabaseInformation

Gets information about a SQL Azure database like maximum size of the database, current size of the database, database edition and database status.

Get-Databases

Gets information about all user databases in a SQL Azure database server like maximum size of the database, current size of the database, database edition and database status.

Get-DatabaseTables

Gets information about all user tables in a SQL Azure database like size of the table and number of rows in the table.

New-Database

Creates a new SQL Azure database.

Remove-Database

Removes a SQL Azure database.

One particular cmdlet of interest is ”Backup-Database” and I will talk more about how to use this cmdlet to backup your SQL Azure databases. As the name suggests, this cmdlet can be used to backup your SQL Azure databases. It makes use of bcp.exe utility to download the data from tables in a SQL Azure database and saves them as tab delimited text files on your local computer. This cmdlet also has the capability to store this backup data in blob storage as well. The way it works is that it first downloads all the data in text files on your computer and then uploads these files in blob storage. To save space in blob storage, you can also instruct this cmdlet to compress these files using GZIP compression before uploading to blob storage as well.

To use this cmdlet, first you would need to install these cmdlets which you can download from our website @ http://www.cerebrata.com/products/azure-management-cmdlets/introduction. In order to use this cmdlet in particular, please ensure that SQL Server 2008 R2 tools are installed (esp. bcp.exe version 10.50.1600.1 or higher). Following sections describe the usage of this cmdlet:

Backup SQL Azure database to local disk only:

# Name of your SQL Azure database server. Please specify just the name of the database server.
# For example if your database server name is “abcdefgh”, just specify that
# and NOT “tcp:abcdefgh.database.windows.net” or “abcdefgh.database.windows.net”
$databaseServerName = “<your sql azure database server name>”;
# User name to connect to database server. Please specify just the user name.
# For example if your user name is “myusername”, just specify that
# and NOT “[email protected]”.
$userName = “<your sql azure user name>”;
# Password to connect to database server.
$password = “<your sql azure password>”;
# Name of the database e.g. mydatabase
$databaseName = “<name of the database>”;
# Download location where the contents will be saved e.g. “D:\Temp”
$downloadLocation = “<download location>”;
Backup-Database -Name $databaseName -DownloadLocation $downloadLocation -Server $databaseServerName -Username $userName -Password $password

To upload these backup files to blob storage, you would need to specify following additional parameters in these cmdlets:

-SaveToBlobStorage: Specify this switch parameter which will instruct the cmdlet to upload these backup files.

-BlobContainerName: Name of the blob container where these backup files will go.

-AccountName: Name of your storage account.

-AccountKey: Your storage account key.

-CompressBlobs: Specify this switch parameter to compress the files using GZIP before these files are uploaded to blob storage.

Do try these cmdlets out and let us know your feedback.