Open In App

Microsoft Azure SQL Database

Last Updated : 03 Apr, 2023
Like Article

Azure SQL Database is a relational database(RDBMS) service provided by Microsoft Azure that is widely used by developers when creating new applications in the cloud. It is managed completely by Microsoft and is a highly scalable platform-as-a-service (PaaS) designed especially for cloud applications. Here, we create a managed database server in the cloud and use the server to deploy our database. The server is a logical construct that acts as the central administration point for pooled databases or multiple logins, auditing rules, threat detection policy, and failover groups. 

The databases are available as Single databases and elastic pools.

A. Single Database

This option helps the developers instantly get started with a single SQL Server database by creating and running it in the cloud and accessing this database through the server. It is a PaaS offering so everything is managed by Microsoft, so all we have to do is to configure the database, create the necessary tables required to carry out the operations, and fill in the required data. We can scale the database as per our requirements (if we need more storage, memory, and processing power). By default, Microsoft pre-allocates some resources and we are charged per hour based on the resources we are using. 

We can also choose to have a server-less configuration. Here, Microsoft creates its own server for the database, which may get shared among other Azure subscribers but maintains the privacy of the database of its users. The database automatically scales and resources are allocated and unallocated as per the necessary requirements.

B. Elastic Pool

It is similar to single databases that we have talked about above, except that by default multiple databases can share the same resources (memory, storage space, processing power) through multiple tenancies. Here the different resources are referred to as a pool. This model is very useful when we have databases with resource requirements varying with time as it helps allocate and deallocate the resource as per our needs thus reducing costs and helping us be quick and efficient. It enables us to use resources available in the created pool and then release them once processing is complete.

Creating Azure SQL Database

Note: In order to create an Azure SQL database one must be having an active Azure subscription as it is a pre-requisite which one can avail via 12 month subscription. Assuming here you are having, so proceeding forward. 

After you have signed in to your account follow the simple steps to create your Azure SQL database.

Step 1: Navigate to Azure Portal


Step 2: Once, in the Azure Portal click on + ‘Create a resource’ option from the upper left corner and search for Azure SQL. 


Step 3: Select create in the resulting Azure SQL page. 

Step 4: Review all the Azure SQL options that are available, and then in the SQL databases title, ensure a single database is selected and select create.


Step 5: A created SQL database page will be popped up. Fill in the necessary information as follows:

  • Subscription: Select your Azure subscription in which you wish to create the resource. 
  • Resource group: Choose the resource group where you wish to create the resource or create a new one by clicking on create new option and entering the name of your choice.


  • Database name: Enter the name you wish to give to the database. 
  • Server: Select create new option and create a new server with a unique name in any location. Use SQL authentication and specify your name as the server admin login and a suitably complex password (for security)


Want to use SQL elastic pool? : Choose whether you wish to use SQL elastic pool or not. 

Compute + Storage: Choose or leave unchanged. 

Backup storage redundancy: Choose locally-redundant backup storage. 


Step 6: Next click on ‘Next’: Networking and on the Networking page you can configure the networking settings. For now, in the Network connectivity section select Public endpoint. Then select Yes for both options in the Firewall rules section to allow access to the database server from Azure services and our current client IP address. 


Step 7: Next select ‘Next’: Security option to configure the security for the database. For now, set the Enable Microsoft Defender for SQL option to Not now.


Step 8: Next select Next : Additional Settings option to configure some additional settings for the database. For now, set the use existing data option to Sample. 

Step 9: Finally, select Review + create and review the different configurations of the database. 


Step 10: If everything is fine select Create to create an Azure SQL database.

Step 11: Wait for deployment to complete and go to the resource that was deployed.


Querying using Azure SQL Database

Step 1: Go to the Azure SQL database resource that was deployed. 


Step 2: In the pane on the left side of the page, select the Query editor and then sign in using the administrator login and password we had specified for our server. 


Note: If you receive an error message stating that the client IP address isn’t allowed, select the Allowlist IP link at the end of the message to allow access and try to sign in again.

Step 3: Expand the Tables folder to see the tables in the database. 

Step 4: In the Query 1 pane that appears, enter the following SQL code:

SELECT * FROM [SalesLT].[SalesOrderHeader]

Step 5: Select the Run option above the query to run it and view the results, which will include all the columns for all rows in the table as shown below: 

Step 6: This way we can run all our SQL queries. Close the query editor pane which will discard our edits.


This is how we can create Azure SQL database resources and use it in our cloud applications.

Why Azure SQL database? 

Azure SQL database gives us the best option for low-cost development with minimal administration required to get started with our cloud application designing and development. It supports most of the core database-level capabilities of SQL servers. Though some of the features dependent on on-premises applications may not be available here.

The scalability feature ensures that we can increase the resources available to us at a given time to carry out our tasks without performing a costly manual upgrade instantly. 
It has an availability of 99.995% as it supports point-in-time restore, enabling us to recover a database to the state it was in at any point in the past. It also replicates the databases to different regions to provide us with more resilience and disaster recovery. It provides us with fully automated backups, updates, and recovery to ensure that we are always running the latest and most secure version of the service. 

It continuously monitors our database for suspicious activities and provides immediate security alerts on SQL injection attacks, potential vulnerabilities, and anomalous database access patterns. Threat Detection alerts provide details of the suspicious activity and recommend action on how to investigate and mitigate the threat.

Some of the Often Use Cases are as Follows: 

  1. New cloud projects where the application design should accommodate any required changes to our applications.
  2. When we need our cloud applications to use the latest SQL server features. 
  3. When we need our cloud applications to have high availability.
  4. When we need our cloud applications to update resource allocation quickly with time-based on demand and requirement.

Deleting Databases in AzureSQL:

Simple and Easy-to-Understand Examples:

There are different ways to delete a database in Azure SQL. In this article, we will discuss two methods:

Method 1: Delete a Database using Azure Portal

Step 1: Log in to the Azure Portal using your credentials.

Step 2: Navigate to the Azure SQL instance that contains the database you want to delete.

Step 3: Click on the “Databases” option on the left-hand side of the page.

Step 4: Select the database you want to delete from the list of databases.

Step 5: Click on the “Delete” button located at the top of the page.

Step 6: Confirm the deletion by clicking on the “Yes” button.

Method 2: Delete a Database using Azure CLI

Step 1: Open Azure CLI on your computer.

Step 2: Login to your Azure account using the command “az login”.

Step 3: Select the subscription that contains the Azure SQL instance by using the command “az account set –subscription <subscription name>”.

Step 4: Delete the database using the command “az sql db delete –resource-group <resource group name> –server <server name> –name <database name>”.

Step 5: Confirm the deletion by typing “y” and pressing Enter.


In conclusion, deleting a database in Azure SQL is a straightforward process that can be done using either the Azure portal or Azure CLI. Before you delete a database, make sure you have backed up the data and that you have the necessary permissions. Azure SQL is a powerful platform that allows users to manage their data in the cloud, and deleting a database is just one of the many tasks that can be performed using Azure SQL.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads