How to Create a SQL Database in Azure, Test the Database, configure the server and run a SQL query.
Published: 2023-05-24 13:09:02


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

**Azure SQL Database** is a fully managed platform as a service (PaaS) database engine that handles most of the database management functions such as upgrading, patching, backups, and monitoring without user involvement.

Step 1:
Sign in to the Azure portal. (portal.azure.com)

Step 2:
Search for SQL Database, click on create.

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

Step 3:

- Subscription: Choose the subscription where you wish to create the resource.
- Resource group: Choose the resource group where you wish to create the resource. If you wish to create a new group click on create a new option.
- Database Name: Enter a preferred unique name.(i chose tolu SQLdatabase)
- Server: Create a new unique name (I chose toluserver)
- Location: EastUS
- Authentication method: Use SQL authentication
- Server admin login: azureuser
- Password: Password12345
- Backup storage redundancy: Geo redundant backup storage
- Region: Select the location where you wish to create the account.

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

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

Step 4:
Click on "Next : Networking"
Connectivity method: public endpoint

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

Step 5:
Click on "Next : Security", and for Enable Azure Defender for SQL, choose Not now. Leave the remaining settings as default

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

Step 6:
Click on "Next : Additional settings"
Use existing data: Sample

Click on "Review + create"

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

Step 8:
Click on "create" to deploy the server and database. It can take approximately two to five minutes to create the server and deploy the sample database. The deployment pane shows the status, with updates for each resource that is created.

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

Step 9:
Click on "Go to resource". The toluSQLdatabase Overview pane shows the essentials of the newly deployed database

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

Step 10:
Click on "Set server firewall". The Firewall settings page appears.

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

Step 11:
Check the box next to Allow Azure services and resources to access this server at the bottom of the page, leaving other settings as default and then "Save" to update firewall settings, then close the Firewall settings pane.

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

Step 12:
## How to Test the database

Here, we'll configure the server and run a SQL query.

In Azure resources menu, select All resources. Search for and select the SQL database resource Type, and ensure that your new database was created. You might need to refresh the page.

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

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

Step 13:
Click on "toludatabase", i.e the SQL database you created. In the SQL database menu, select Query editor (preview). The Query editor (preview) pane appears.

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

Step 14:
Sign in as azureuser, with the password Password12345.

You will not be able to sign in because your IP address needs to be enabled in a firewall rule.

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

Step 15:
Click on "Overview" (your edits will be lost), and in the command bar, select Set server firewall. The Firewall settings page appears.

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

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

Step 16:
In the Client IP address section, your IP will be shown (verify that it is the same client IP address from the error you received in the previous step).

In the command bar select Add your client IPv4 address. This will add a Rule name that contains your IP address in both the Start IP and End IP fields and the Click on "Save"

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

Step 17:
Click on toludatabase (database you created) in the breadcrumb at the top of the page to return to your SQL database, and then select Query editor (preview) from the menu.

Step 18:
Sign in again as azureuser, with the password Password12345. This time you should succeed. It might take a couple of minutes for the new firewall rule to be deployed. If you still get an error, verify the client IP address in the error, and return to Firewall settings to add the correct client IP address.

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

Step 19:
After you sign in successfully, the query pane appears. Enter the following SQL query into the editor pane.

SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
FROM SalesLT.ProductCategory pc
JOIN SalesLT.Product p
ON pc.productcategoryid = p.productcategoryid;

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

Step 20:
Select Run, and then review the query results in the Results pane. The query should run successfully.

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

Congratulations! You've created a SQL database in Azure and successfully queried the data in that database.

Thank you for reading...