How to Deploy and configure servers and database for Azure SQL
Tags: cloudcomputing, sql, database, azuresql
Published: 2023-05-01 18:31:02

If you have ever wondered and would like to know how to Deploy and configure servers and database for Azure SQL and query some sample data then this article is just the cup of tea you need to get you going. 


Before you get started make sure you have the following:

**Prerequisites**
- Azure subscription account (you can create a free trial)
- Azure Data Studio
- SQL Server Management Studio-SSMS


Firstly in order for you to deploy and configure anything you need to be on the Azure portal and create the server and database for Azure SQL. These two go hand in hand as the database would require a database server in order to run.


**STEP 1:** Sign in to the Azure portal (https://portal.azure.com).

**STEP 2:** Create a new resource group for your Azure SQL deployment.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dekmov9aph0f92ge0d93.PNG)
**STEP 3:** Create a new Azure SQL Server instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/geyu0pkqzssu4e1ctvap.PNG)

You will need to specify a server name, choose the subscription, resource group, location, and administrator login and password.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdkmai4h9il8f252ejwo.PNG)

**STEP 4:** Create a new Azure SQL database. 
Search for database and click on SQL Database and click create 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2ccpzi5es2288vc0a9p.PNG)

Click the + symbol or click on create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gc1f0lk65hc4v0sz1pw1.PNG)

Under the **Basic** Tab:

Select the subscription account and and choose the resource group you previously created. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0nsmtzuq77pnvg0qa6o.PNG)

Fill in the **Database name** , make sure that the **Server** you have created is selected, if you have any issues you can always click on the **Create new** link and add a new server.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l03t9mvt48l60vna6gk4.PNG)

Next up is the Service Tier, **Compute + storage** , the default compute and storage is a bit costly and not really what we need so we'll configure the preferred service tier and go for the **basic tier** .

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvvqv7p9lf85ww97kcnk.PNG) 

Next up you have to configure **backups and disaster recovery** settings for your Azure SQL database. 
By default, Azure SQL Database stores backups in **geo-redundant storage** blobs that are replicated to a paired region. Geo-redundancy helps protect against outages that affect backup storage in the primary region.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ogknjxgmf33ys88f80cn.PNG)

Under the **Networking** tab:

Configure firewall settings for the server. By default, Azure SQL will block all connections that originate outside of Azure. 

Set the connectivity method to **Public Endpoint** . Adjust the **firewall** settings to **Yes ** to Allow access to the server, and to add the current client IP address

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mcy1ciox3vvvup3kktuz.png)

Under the **Additional Settings** tabs:

You can choose to create an empty database, import an existing database, or create a database from a template. For this exercise you can select use **sample data** .


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7cxkijvobmz6777723b.PNG)

Now you can create and deploy your database.
Once it has completed deploying you can click on the Go to resource button to navigate your database resources and settings.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kfsryw57q2s99mv343v.PNG)

Now you need to configure you firewall. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8kfcv13dpfdbwpyy51l.PNG)

Add a client IP address. You can use the Azure portal to specify which IP addresses or ranges can access your Azure SQL server.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rxhua05psiuhkswz384.PNG)

**STEP 5:** Test your connection

Test the connection to the Azure SQL database to ensure that everything is working as expected.

Click on Open with and choose Azure Data Studio


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fu39gohdtetad9cyoen.PNG)

Click Launch it now link

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/48epewcwk8dayb4vgjh3.PNG)

Click Open Azure Data Studio

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xz1cd0mq8utvttkp2rhv.PNG)

Connect by entering the details of your database and sql server

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lyl2fy3uld5j908rl5i8.PNG)

Well done you have connected and here is your database

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwu9vh4sum6x83qtktp6.PNG)

If you have downloaded Microsoft SQL Server Management Studio
You can simply open the app and connect to the database.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpe75f90fzxxbzw48qbo.PNG)

Congratulations! Here is your database

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hibmnb5qit46xbhh0kvk.PNG)
**STEP 6: Query data**
You can go a step further and query some data as indicated below and execute to run the query.

SELECT * FROM SalesLT.Product
WHERE color = 'red';

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwnbgvxhj81bnjv7lf4d.PNG)

**Summary**
What we have done and learned in summary is the process of setting up infrastructure to host and manage data in a scalable and secure manner on Microsoft's cloud platform, Azure.

We went a step further and connected the database to SQL Server Management Studio-SSMS.

Lastly we queried some sample data that is provided by Microsoft.