Freigeben über


Windows Azure info clips: How to create a SQL Database using command line

In the last SQL Conference, I have presented a session about the execution of a workload based on SQL Server in Windows Azure.

According to the agenda, I have also spoken about SQL Database, the SQL Server edition available as Platform as a Service (PaaS). 

Server and database creation process is very fast in SQL Database: this is one of the main features of the product.

You can use two different methods to create a new server:

  • Using the Windows Azure Management Portal

image

  • Using Powershell scripts, command line tools or REST API.

In this example, we use the Windows Azure multi-platform command line interface: you can download it

 here.

image

 

1 – Download the SQL Server configuration file from the Windows Azure management portal and import it

This is an XML file containing access information to Windows Azure management API.

 azure account download
 azure account import [path]
azure account set [subscription]

 

2 – Create a new SQL Server Database

In this step, you have to define the SQL Server administrator and the location where you desire to place the new server: if all is ok, the command will return you the name  of the new server (highlighted with a green rectangle in the example).

 azure sql server create

sqldatabase

    

3 – Remote access

To help protect your data, a firewall has been integrated into SQL Database: you can create firewall rules at the server and database levels.

In this example, we create a rule “Any IP” at the server level: remember to configure a rule compliant with your security policy in a production environment.

 azure sql firewallrule create

image

4 – Database creation

Now, we create the new database: the command prompts for the database name.

 azure sql db create

image

5 – Operational test

We use SSMS for checking that database creation process was completed without errors.

We use the following FQDN to connect to SQL Database [server name].database.windows.net.

imageimage

On the Windows Azure Management Portal, you can see the new database server.

image

image

6 – Database and server removal

After the testing phase is finished, we delete database and server used in this example:

image

Francesco