How to get the url of blob from azure blob trigger
Asked Answered
D

2

6

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);
Dishonorable answered 26/1, 2018 at 16:57 Comment(5)
What do you mean by "blob file as a binary string"?Troll
@Troll base64 encoded string. not the url of the imageDishonorable
Have not tried azure or azure-storage. What is "url for the blob file"? Did you not have to make a request to a URL to get the base64 string?Troll
@Troll in a antoher function i am saving the image in azure blob storage. and i have created a blob trigger so that every time someone insert a image to azure blob storage my trigger get fires. inside the trigger function i need the url not the bob file.. that is the problemDishonorable
Aren't you triggering on the same path anyway? Why do you have to pass in the URL? You could just form it yourself, since you know the storage account, and you know the container and blob name.Proletarian
P
2

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.

Pepperandsalt answered 1/7, 2019 at 9:22 Comment(0)
A
0

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

Apothecary answered 30/1, 2018 at 21:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.