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 yourAzure portal
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.
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
Click Review and Create and if your validation is passed, go ahead and click Create.
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.
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.
- To configure the Compute and Storage, click on it and select Basic for the Service tier and click apply
- 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.
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
Click on the configure access, scroll down the page and under the firewall rules, select add your client IPV4 address and save
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.
This will open another window for you to either download or launch Azure Data studio if you already have it installed
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.
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
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
Top comments (0)