I am using an azure function that is gonna save multiple xml files with different names to the same blob container. I want to use data from other binding for format the name.
Blob binding:
[Blob("outbound/", FileAccess.Write, Connection =
Settings.InbundBlobConnectionString)] Stream outboundBlob
Is there a way I can manipulate the blob path using code?
We could use imperative binding pattern . In function method signature, add Binder binder
, remove Blob input binding and try code below.
string myBlobName = "valueGotFromOtherBinding";
var attributes = new Attribute[]
{
new BlobAttribute($"outbound/{myBlobName}", FileAccess.Write),
new StorageAccountAttribute(Settings.InbundBlobConnectionString)
};
using (var writer = await binder.BindAsync<TextWriter>(attributes))
{
await writer.WriteAsync("Conetent");
}
In the case when the blobName value is in the Trigger binding JSON payload (for instance in the message/request body), you can use a POCO object, see the following:
[QueueTrigger("myQueueName", Connection = "mySTORAGE")] POCO item,
[Blob("outbound/{blobName}", FileAccess.Write, Connection = Settings.InbundBlobConnectionString)] Stream outboundBlob
…
public class POCO
{
// ...
public string blobName { get; set;}
}
Here's the doc .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.