Reputation: 1140
I have defined a out binding to store file in blobstorage:
function.json:
{
"type": "blob",
"direction": "out",
"name": "outputBlob",
"path": "outcontainer/{outname}",
"connection": "storagevoyager_STORAGE"
}
Now i try to specify the "outname" in python code:
outputBlob.outname = "test.txt"
outname = "test.txt"
outputBlob.set(fileobj)
System.Private.CoreLib: Exception while executing function: Functions..Microsoft.Azure.WebJobs.Host: No value for named parameter 'outname'.
So how can i define the outname in my code ? I can't find any good reference.
Do i need to update enviroment variables? Also with {rand-guid} it will work.
Upvotes: 3
Views: 2683
Reputation: 409
If you are using a trigger like HttpTrigger, you can actually set the {outname} if you pass outname as a param in your http request! if you are using any other triggers like service bus if you pass in the json message. You could just set the input and output binding path with the json value from the trigger json data. take a look at this JSON payloads i tried this and it works in python
Upvotes: 1
Reputation: 1140
Seems its impossible to change the variable with Python, in C# its possible to change.
To use it in python i am using python sdk and connect manually to my storage:
from azure.storage.blob import BlockBlobService
blob_service_client = BlockBlobService(account_name="storageacc", account_key="acckey")
blob_service_client.create_container(container_name)
blob_service_client.create_blob_from_bytes(container_name="container_name", blob_name="filename.txt", blob=b"blob")
Upvotes: 4
Reputation: 23111
If you want to change the output blob name with the code, it is impossible. If you want to dynamically create output blob name, you can use the binding expression {rand-guid}
in function.json to implement it.
For example
{
"type": "blob",
"direction": "out",
"name": "outputBlob",
"path": "outcontainer/{rand-guid}.txt",
"connection": "storagevoyager_STORAGE"
}
For more details, please refer to the document
Upvotes: 0