pavithra rox
pavithra rox

Reputation: 1086

How to get the url of blob from azure blob trigger

i am using azure blob triggers to identify when a container get updated. the trigger works fine. but it only returns the blob file as it is (like base 64 string). but how do i get the url for the blob file in this trigger.

function.js

{
  "disabled": false,
  "bindings": [
      {
          "name": "readText",
          "type": "blobTrigger",
          "direction": "in",
          "path": "pngs/{name}",
          "connection":"STORAGEConnectionString"
      }
  ]
}

index.js

context.log('Node.js Blob trigger function processed', context.bindings);

Upvotes: 6

Views: 3210

Answers (2)

AliMola
AliMola

Reputation: 578

You have to use context.bindingData:

  • To get your {name} variable do this:

context.bindingData.name;

  • To get full path (in your case 'pngs/{name}') do this:

context.bindingData.blobTrigger;

  • To get your blob uri do this:

context.bindingData.uri;

Hope it helps.

Upvotes: 2

you could actually use this format for the URIs for your blobs:

https://storagesample.blob.core.windows.net/mycontainer/blob1.txt https://storagesample.blob.core.windows.net/mycontainer/photos/myphoto.jpg

More information can be found here

Upvotes: 0

Related Questions