Creating a database with Azure SQL database.
Tags: azure, sql, learning, cloud
Published: 2023-04-29 12:55:03

Azure SQL database is a fully-managed platform as a service (PAAS), that handles management functions such as patching, upgrading, backups, etc and gives an SLA of 99.99% availability. 

In Azure SQL family, there are also other offerings / deployment options such as:
- Azure SQL managed instance, a Platform As A Service.
- SQL server on azure virtual machine - an Infrastructure As A Service.

This article is a walkthrough on creating a database with Azure SQL database and connecting to SQL Server Management Studio (an integrated environment for managing SQL infrastructure) to query the database.

Steps
- Login to your azure account with an active subscription and navigate to azure SQL by using the search bar, then click on create SQL resource.

- Select SQL database as deployment option, and single database as resource type (other resource types include elastic pool and database server)

![SQL db deployment option](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhnh09hthh3k1tvd84a5.png)

- Click on create to configure the database, a summary of my configuration options:

- Server details includes a server name, authentication method, admin login and password, where my database name is unique and my authentication method is SQL authentication.

![Basic config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g0dspxn7vrsxhwg6553f.png)
![Networking](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sz96m9zznyzq4betlkh6.png)

- For data source, I choose the sample option so as to create a sample database (AdventureWorksLT).
![Additional settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2yu835n9x7gt3gtr60p.png)

- This deployment option created a server and a database among other resources.

![Deployment progress](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4j5fdw2euani7l1qqsl1.png)
- My server is online

![Database Overview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8f5z74joqipplzngyjr1.png)

- To connect and query the database via the query editor or SSMS, a fire wall rule has to be configured on the server; this is done on the LHS, Security section =>networking (I am allowing just my public IP address to access my resources) 

![Adding firewall rule using my public IP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/em4p5j9twxkf6z2ovib6.png)

- Using query editor, I logged in on the portal with my username and password.

![Login with Query editor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xcsuac8r40ylrtuunu0p.png)

- Query the database with SQL commands.

![sql commands](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yq8gmvk1ikjieu0zchpx.png)

- Another option is to connect Azure SQL db to SSMS (SSMS should already be installed on your machine), with server name, username, password and authentication method


![SSMS login](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02ophngvl5gwi06xua0y.png)

![Authentication](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tu11oaw5oj2thplpx123.png)
- Connection is successful and some query has been done.


![SQL server](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5w5opygjzfetjmy1a0o.png)

Thank you for reading and I hope you learned something new.