Nafis Islam
Nafis Islam

Reputation: 1509

How to dynamically set blob name to store in Blob storage in azure function nodejs?

I have a activity function that should store message in Blob storage.I can overwrite a file in blob storage but i need to store data in different name.how to do that? Azure function doesn't support dynamic binding in nodejs.

function.json

Upvotes: 3

Views: 1668

Answers (1)

Jerry Liu
Jerry Liu

Reputation: 17790

Find one workaround, see whether it's useful.

Along with blob output binding, there's an activity trigger to receive message msg, we can put self-defined blob name in msg for blob binding path to consume.

In your orchestrator function which calls Activity function

yield context.df.callActivity("YourActivity", {'body':'messagecontent','blobName':'myblob'});

Then Activity function code should be modified

context.bindings.myOutputBlob = context.bindings.msg.body;

And its function.json can use blobName as expected

{
  "bindings": [
    {
      "name": "msg",
      "type": "activityTrigger",
      "direction": "in"
    },
    {
      "name":"myOutputBlob",
      "direction": "out",
      "type": "blob",
      "connection": "AzureWebJobsStorage",
      "path": "azureblob/{blobName}"
    }
  ],
  "disabled": false
}

Upvotes: 2

Related Questions