How to link your Blob file storage to Azure SQL database
Published: 2024-06-03 18:27:23

**[Step 1: Login to Azure portal and search for storage accounts](url)**

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

## **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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlq8ot91x7k73mhoggk2.png)
**_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bxghimfvn22ytxc5mu6f.png)
**_Leave other tabs as default, the main goal to create a file storage that can be sent to SQL database.
_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vdshhk3x0nqgb6lyw59y.png)
**_Once you click on resources, the below page shows, click on containers to create a file storage._**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u23yrxp0styx922i1cw3.png)
**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7fnaoq8d22ibdhha0ga.png)

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

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzlf62gc13itylbxxw76.png)

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

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

## _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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ke4pjggzg9zhmf7apxq1.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2sc18vh7f77ab6evf60r.png)
**_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwbd8gdaq5y0kf5n1e0d.png)

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ox7pgy3ze16txw85frii.png)
**_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7m3wosc7q5ek2e8t44rz.png)

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

**_

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aook0vto8t6wqp6rrtnm.png)

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

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

## _Now save the query as “dataset” and congratulations, you have create a SQL database_
**

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

**

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5jnxyfnuybjjy39ub9y.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9l8dszhulpi2zhn4dkao.png)
**Once you create and deploy, click on the resource for it and “launch studio”**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w75a892khvpe19pae50v.png)
**This will open up a new-tab on your browser** 

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

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

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0775238sd0eqmcxv5kc.png)
**_Under Data store tab, search for “Azure Blob Storage” _**

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mwelvr953qpitrrul7nc.png)
**_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0trtgivmweava6kp0y54.png)
**_once it is done, click “create”_**

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

## **_Now let’s repeat the process for SQL database,_**

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

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

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

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

**_

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


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

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gp12tu4l2k3gd56iavyd.png)
**_From the above select “Delimited text” which represents “CSV” file format stored in the blob storage in azure portal. _**

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

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

**_
select “dataset” and click ok _**


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

**_

## Let’s create same dataset for the SQL Table 
_**

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

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

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

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

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

## Now Go back to “pipeline2” and select “Move and transform” 
_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmtfuldh33wxjgblbqhu.png)
**_Move and drag “copy data to the open space next to it _**

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

**_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i2poaufu1x0qijxne01c.png)

**_

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

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

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/29nldy78l1apybi7bdm8.png)
**_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wpnahm64rlsiaixwrd5.png)

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

**_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n979vtql31719dui12a1.png)

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

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

## 
Let’s compare the table previously 
Before 
_**

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

**_

## After 
_**


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

**_

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