Configuring and Deploying Databases on Microsoft Azure
Tags: devops, beginners, database, azure
Published: 2023-05-03 17:59:10

A database is an organized collection of data, so it can be easily accessed, managed, and updated. You can think of it like a library. It is where data is stored.
Azure SQL Database is a database meant for cloud applications.
Microsoft Azure offers users three (3) namely; 
SQL Server on Azure VMs, Azure SQL Database, and Azure SQL Database Managed Instance.
This article will be focused on configuring and deploying a database using the Azure SQL Database which is PaaS option for SQL Server or specifically database as a service (DBaaS).

The first thing we will do is to create a server for the database.

#### Creating the Server
**Step 1:** Signup/Login into your[Azure portal](https://azure.microsoft.com/en-us/free/)

**Step 2:** In the search bar on your portal, type SQL and select the SQL Server and click create SQL server.

**Step 3:** Under the Basics tab, configure your server your SQL server as you wish by selecting your preferred location, resource group, in the Authentication Method section, select 'Use SQL authentication', set the admin details, admin name and password.
![configuring servers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4pgtrrvd90enal5tfy3.png)
**Step 4:** Under the Networking tab, in the Allow Azure resources and services to access this server, select 'Yes' so that other resources can communicate with your server. You can also add tags if you wish to
![Configuring servers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9ecdtmq0uy3cef7pt4s.png)
Click Review and Create and if your validation is passed, go ahead and click Create.

![Review & create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/up7j4ch47knxum3btd5p.png)
Well done your have deployed your server.
Now that we have deployed our server, next up we will create the database.

#### Creating the Database
**Step 1:**  Also in the search bar, type SQL and select SQL database or go to resource and the Overview tab of the Settings section select SQL database.
![SQL database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ffxe2f32vqg0c8k71f4.png)

**Step 1:** Having done that, click on create database, assign your database a name, attach the previously created server, also configure the compute and storage so as to save cost since the database won't be used for any serious task. However, in an event where your database will loads of applications and workload attached to it, select an appropriate database as required by your task.
1. To configure the Compute and Storage, click on it and select Basic for the Service tier and click apply
![configure compute & storage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdx8sacw1u4pnjoctudc.png)
2. Under the Backup storage redundancy, select Geo-redundant backup storage

**Step 3:** Head over to the Networking tab, Add current client IP address and by select 'Yes'. Also select 'Yes' for Allow Azure services and resources to access this server if your selected location highlights that section.

**Step 4:** Leave the everything under the Security tab as Default and head over to the Additional settings tab.
Since we do not have an existing data source, we will make use of the sample dataset provided by Azure. Hence, select the sample for Use existing data, this will give a prompt about AdventureWorksLT database to be use, click you wish to continue. 
![Additional settings tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kenknd0lln7pf5ryqis7.png)
This is the database we will be querying. If you have an existing data source, you can select it.

**Step 5:** Assign tags to your database then review and create your database. With that, your database should be deployed
Upon creating your database, it is important to add firewall so you won't have issues connecting to the Azure Data Studio. To do this, scroll down the overview tab and you will see a 'Configure access' section
![configuring access](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gysuurgffib612zkbzbl.png)
Click on the configure access, scroll down the page and under the firewall rules, select add your client IPV4 address and save
![firewalls](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2s210le7n076s1behtq.png)

#### Connecting and Querying the Database
Now that you have deployed your database, the next thing is to query the database.

**Step 1:** To query the database, you will need to connect to it. Click go to resource, on the Overview tab, click on the drop arrow on Connect with and select Azure Data Studio. 
![connection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/331z26hd6opqv2i36tvi.png)
This will open another window for you to either download or launch Azure Data studio if you already have it installed
![azure data studio](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ql6k0rziijy51rrttwzz.png)

**Step 2:** If you already have Azure Data Studio installed, launch it else you can go ahead and download it ensure to choose to your laptop specification. Clicking on the launch button will open a prompt that Azure Data Studio will opened. 
Click open Azure Data Studio.
![Azure Data Studio.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwjdtfydtbhm851rtf2q.png)

**Step 3:** If you downloaded the Azure Data Studio, install it and it's once done, launch it from your Azure portal so that the server details will be automatically populated in the Azure Data studio.
Enter the admin name you set up and password when you were creating the server. The connect button should be highlighted, click on the connect
![Connection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zemv7wo7dfn3q9d04ui5.png)

**Step 4:** The data studio should be populated with the AdventureWorksLT database. This is the reason why we selected the sample database so we can a database to query.

**Step 5:** Above the populated database is the option to a New query tab, click on it so we can query the database.
You can write the queries in the image below to query your database
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87ezwdp8uxsyfe80wpmk.png)