DEV Community

Henry
Henry

Posted on

How to link your Blob file storage to Azure SQL database

Step 1: Login to Azure portal and search for storage accounts

Image description

**First we need to create a Blob file storage before we link it to our SQL database.

Step 2 : Create a file storage **

Image description
Select your subscription
Create a resource group or add from an existing one you have created before.
Create a storage account name
Select a region and ensure performance is set at “Standard”
Select Redundancy to Geo-redundant storage then click “Create”

Image description
_Leave other tabs as default, the main goal to create a file storage that can be sent to SQL database.
_

Image description
Once you click on resources, the below page shows, click on containers to create a file storage.

Image description
Step 3: Create a container to store our files such as excel files, csv or other files that can be used to store data.
Select “container access level” and click create.

Image description

Image description

Step 4: click on the container and upload any csv file or any file used to create, store dataset from your computer, then click “upload”.

Image description

Image description

Image description
**

Now we have BLOB storage container with a CSV file in it. Now let’s create an SQL database

**
Step 5 : Go to the Home page of the portal and search “SQL database” and click Create

Image description

Image description
Select Subscription and resource group( if you have created one before) in this case you can select the same resource group used to create the BLOB storage for this SQL database to ensure you have all resources for the activity in the same resource group.
Create a Database name and select a server or create a server
Ensure the storage redundancy is “geo-redundant storage” similar to the BLOB storage, leave other tabs has default and click “create”

Image description

Image description

Image description

Image description
Once your SQL Database has been deployed, go to the resource page of the database. And click “Query editor.
Enter your login details you created while creating your SQL database.

Image description

Image description

**_

Now we are going to create table heads of CSV file in the blob storage into this tables folder in the database for us to link the dataset later.

_**

Image description

Image description

Image description
**

Now save the query as “dataset” and congratulations, you have create a SQL database

**

Image description

**

Congratulations you have successfully created A Blob storage and A SQL database.

**
**

_Now lets link the storage file to the Database, _

**
Step 6: Go back home, and create “Data Factory” and create.
Select subscription, resource group such as the one for the data storage and SQL database.

Image description

Image description
Once you create and deploy, click on the resource for it and “launch studio”

Image description
This will open up a new-tab on your browser

Image description

Image description

Image description
**_

Now we need to provide a link service that will enable us link the Blob storage to our SQL database

_**

Image description
_Under Data store tab, search for “Azure Blob Storage” _

Image description

Image description
As usual, follow the details of subscriptions and under the storage account select the name of the blob storage file we created in azure earlier.

Image description
once it is done, click “create”

Image description

Now let’s repeat the process for SQL database,

Image description

Image description

Select the required information has shown in the screenshot below, and click create.

Image description

**_

Now we have created the linking services for both the blob storage and Sql database, let’s go back to the pipeline2

_**

Image description

Image description

Image description

Image description
_From the above select “Delimited text” which represents “CSV” file format stored in the blob storage in azure portal. _

Image description

Image description

_
select “dataset” and click ok _

Image description

**_

Let’s create same dataset for the SQL Table

_**

Image description

Image description

Image description

Image description

Image description
**_

Now Go back to “pipeline2” and select “Move and transform”

_**

Image description
_Move and drag “copy data to the open space next to it _

Image description

_Click on “Source” – Source is the source of the data which we want to connect the data from which is the “Blob storage”. _

Image description

**_

Now we click on “Sink”, sink is the sql table headers we created with the sql syntax called “orders”

_**

Image description
**_

Now click on “Mapping” – to map both files together

_**

Image description

Image description
Confirm that dataset types from the source (Blob storage) is the same to destination (Sql database)
After that, confirm the tables “dataset and xsqltable1” are shown above then click “debug”.

Image description

Image description

Once the “Debug is complete”, and its succeeded as shown above CONGRATULATIONS, YOU HAVE SUCCESSFULLY LINKED YOUR BLOB STORAGE TO YOUR SQL DATABASE.
**_

Now go back to azure portal, check the SQL database query d.bo.dataset
_**

Image description

Image description

Image description
**_

Let’s compare the table previously
Before
_**

Image description

**_

After

_**

Image description

**_

CONGRATULATIONS, YOU HAVE SUCCESSFULLY LOADED YOUR BLOB CSV DATASET TO THE SQL DATABAS

_**

Top comments (0)