How to trigger blob function on Azure Storage in Node.js
Tags: node, javascript, azure, programming
Published: 2022-10-16 08:53:36

> I was working on a scenario in which I need to create a node.js application having a Azure Function App function which will trigger when ever a particular container of a particular storage app get file/s or any change in uploaded files.

Let create all these from scratch

## Extensions
1. first you need to install some Azure extensions

![20](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32tyntfj76ccbd3kkp2c.PNG)

These extensions will help you later in application
## Create Storage & Function app
2. now got to the Azure icon on left sidebar and create a function using plus icon

![1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/42sgdn3wlan54gqzdert.png)
3. Select language

![2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qa7akabgsxt7tgzulsgr.png)
4. Select Azure Blob Storage Trigger

![3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zq7xwqd8wc5oa8fwhavr.png)
5. Set name for function 

![4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o20o9bs0l7po2xcbilay.png)
6. Select storage from where you will upload file. if you hasn't create a storage let create first.

![5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vykgg3gwynad4ewege0z.png)
7. Creating Storage on Azure dashboard

![6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrn9qmw7y4bymyuhs5ky.png)
8. Set name for storage and you will get this output

![7](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8tdzow0pum7wakxcbqwn.png)
9. We need to create function app also in Azure dashboard so let create it that one first

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

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

![10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izdmpx8krxleer0emnce.png)
10. Now let continue with creating function, after creating function in VS code you will get this file structure

![11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3d94yeffsma7vhnzxr34.png)

11. Now lets upload the function to our Azure dashboard Function App.
12.Right click on the local function folder and click on deploy to function app

![12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jayrc5soupx9vpzydq7n.png)

![13](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u41wte11idq7qky14bjn.png)
13. You can check/verify that the local workplace function is up on Azure dashboard 

![14](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqa52t8114900abtjeg6.png)
14. In **local.setting.json** file you will find object having some key values, to add the value of key **AzureWebJobStorage **you need the connection string.
![15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v9x6p00t1ygj8fd36doz.png)
15. Go to storage app account you created earlier and go to access key option in left menu. Copy connection string and past in **local.setting.json** file object

![16](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/acv7g48xryoiszp0xhm5.png)
Their will be a file name **function.json** in folder which you created for function app that file will have config about from which container the function will connect and trigger whenever the file upload/update.

![17](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fhbzoxb6isqkjh1ul0e.png)
16. Let create a container in our storage app while creating a container **name** will be same as we define in function app **funcion.json** file **path key**

![18](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zzq5p2jxjecgec1bcpfl.png)

lastly open the VS code terminal and run the command **func host start**. After start the server go to the container in Azure dashboard and try to upload a file in it. After upload successful you will get the output on function terminal which you can check on VS code terminal 

![19](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/krjo8r19ydjr28sv6w3k.png)

Follow for more https://linktr.ee/zaahmed