Welcome!

Think first. Code later.

Adam Grocholski

Subscribe to Adam Grocholski: eMailAlertsEmail Alerts
Get Adam Grocholski via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Blog Feed Post

Azure CLI Day 52 – sql db create

bash-azure

In my previous post (http://thinkfirstcodelater.com/blog/?p=3531) I showed you how to use the Windows Azure cross platform command line tools to delete a firewall rule from a SQL server. In this post I’ll show you how to use the tools to create a SQL database.

Once again, just a reminder that I’m using the command line tools on a MacBook Air with OSX (Mavericks) installed, and I’m using Google Chrome as my default browser. However, the experience should be identical on Windows and Linux as well.

Open an instance of your command line (Terminal, Bash, Command Prompt, etc.) and type the following:

azure sql db create -h

Screen Shot 2013-11-09 at 3.50.36 PM

The azure sql db create command creates a database on a SQL server. At a minimum there are four parameters you need to provide:

  • serverName – the name of the SQL server where the new database will be created.
  • databaseName – the name of the new database.
  • administratorLogin – the administrator login for the SQL server.
  • administratorPassword – the administrator’s password for the SQL server.

There are also some optional parameters you can use:

  • collationName – the database collation to use.
  • edition – the database edition to use.
  • maxSizeInGB – the maximum size of the database in GB.
  • location – the location of the database.

For this post, we’ll just stick with the required parameters.

Note: in order to use the Windows Azure command line tools to create a SQL database, you must have a firewall rule created on your SQL server that allows your computer’s IP address to connect to the SQL server. To learn how to do this please see my post on the topic (http://thinkfirstcodelater.com/blog/?p=3479).

To create a database, enter the following into your CLI, substituting where appropriate:

azure sql db create ‘[YOUR SQL SERVER NAME]‘ ‘my_new_db’ ‘[YOUR ADMINISTRATOR LOGIN]‘ ‘[YOUR ADMINISTRATOR PASSWORD]‘

I used the following:

azure sql db create ‘thbmcjr7xb’ ‘my_new_db’ ‘MY ADMIN LOGIN’ ‘MY ADMIN PASSWORD’

Screen Shot 2013-11-09 at 4.06.45 PM

Once the command completes, you can confirm the database was created by going to the Windows Azure Management Portal and navigating to the SQL DATABASES section.

Screen Shot 2013-11-09 at 4.11.53 PM

That’s all for now. In my next post I’ll show you how to list the databases on a specific SQL server.

Did you know you can try Windows Azure for free for 30 days? Just go to http://aka.ms/thecloud and sign up.

Read the original blog entry...

More Stories By Adam Grocholski

Hey there! My name is Adam Grocholski, and I'm a Technical Evangelist at Microsoft where I spend time focusing on Windows, Windows Phone, and Windows Azure. I live in the frozen tundra of Minnesota and run thinkfirstcodelater.com. You can also follow me on twitter at @codel8r.