Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Blob Trigger. Configure Blob Path in Configuration Files

I am using Blob trigger in my project to process the content of files.

I am using Azure Blob Trigger to initiate the process of a file execution.

[FunctionName("FunctionImportCatalogue")]
public static void Run([BlobTrigger("importcontainer/{name}", Connection = "StorageConnection")]Stream myBlob, string name, TraceWriter log)
{}

Depending on where the code is published the blobcontainer should change accordingly. I mean I want the "importcontainer" to be configured in config files. Can I do that?

like image 472
sham Avatar asked Dec 24 '22 07:12

sham


1 Answers

As far as I know, you could configure it in the local.settings.json. Add the code below to the Values in the file, my sample container named 'workitems'.

"importcontainer": "workitems"

Then change the code below in the .cs file.

public static void Run([BlobTrigger("%importcontainer%/{name}", Connection = "StorageConnection")]Stream myBlob, string name, TraceWriter log)

Then publish the Function to Azure, you should set importcontainer in the Application settings in the portal like screenshot below, because the setting will be used.

enter image description here

Run the function and add a blob to the container, it works fine on my side.

enter image description here

like image 129
Joy Wang Avatar answered Feb 17 '23 16:02

Joy Wang