Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
335 stars 103 forks source link

Blob Output Binding: Setting file name within the function #1205

Closed pietz closed 1 year ago

pietz commented 1 year ago

Is your question related to a specific version? If so, please specify:

I believe the issue (or missing feature) is related to the V1 and V2 python programming model.

What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)

Blob Output Binding

Question

How can I set the name of the blob output file within the function?

Setting the name of the blob output file seems to be able in two ways:

  1. static name in the path -> why does this even exist?
  2. dynamic name in the path, which needs to reference a name from the trigger or input

But how can I define the name of the output file within the function?

I'm using this endpoint as a HTTP upload endpoint. I want to choose the file name based on the md5 hash of the file to avoid collisions and check if a file already exists. How can I do that?

bhagyshricompany commented 1 year ago

Thanks for informing. You can refer this document: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-output?tabs=python-v2%2Cin-process&pivots=programming-language-python Azure Blob storage input binding for Azure Functions | Microsoft Learn In the function.json file, the queueTrigger metadata property is used to specify the blob name in the path properties  

azure-storage-blob

https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

bhagyshricompany commented 1 year ago

Hope you got the answer other wise you can raise the new req.

miztiik commented 1 year ago

@pietz - Did you manage to get it working?

pietz commented 1 year ago

After reading a bit more into the topic, I came to the conclusion that the bindings are basically useless if you want to do serious interaction with other resources. Except for trigger bindings, don't use binding. Just use the cosmos or blob clients.

Honestly, the bindings are a good idea for the first 10s but afterwards they are both worth your time. I wish it was different.

miztiik commented 1 year ago

@pietz Thanks for taking to respond. You have pretty much confirmed my findings. I am refactoring to using SDK to interact with the resources and retain the triggers.