How can I pass parameter to the BlobOutput? I need to generate blob name at runtime. Is there a declarative way to do so? Here you can see that I need to set parameter "name" value.
[BlobOutput("container/{name}", Connection = "AzureWebJobsStorage")]
public static object Run([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req, out string name,
FunctionContext executionContext)
{...}
I played with execution context but with no luck.
I don't think you can get the blob name like this from http trigger. I can think of below options.
Use Queue or blob triggered function. With that you'll get the blob name dynamically from the trigger data itself. For example,
public static void Run(
[BlobTrigger("sample-images/{name}")] Stream image,
[Blob("sample-images-md/{name}", FileAccess.Write)] Stream imageSmall)
{
Use system binding expression to form output blob name.
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "blobname")] HttpRequest req,
[Blob("sourcefolder/output{DateTime.UtcNow}", FileAccess.Write, Connection = "AzureWebJobsStorage")] Stream blobStream,
ILogger log)
{
Remove the output binding altogether and create a blob client in the function itself. That will give you full control over blob name or anything else you need. If you have multiple functions in your application, its better to create a singleton service and have this connection object there.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments