Reputation: 1923
So what is the best way to move a blog that triggered an azure function between "sub folders" in blob container. I know that Azure function blob containers are flat, so the thing i call sub folder to keep the context simple is in fact prefixes in the blob URI.
But lets say my function app fetches a blob ("my blob") from my blob inbound "sub folder".
public void Run([BlobTrigger("%InbloundBlobStoragePath%/{name}", Connection = "ConnectionString")] Stream myBlob, string name, ILogger log)
{
//... Function Logic...
}
What is best practice here? I would guess it would involve to change the prefix of "myBlob", save it with a new prefix, and delete the original one?
Upvotes: 0
Views: 821
Reputation: 1923
Well in my case i think i was on the right track, this worked for me:
First declaring the "BlobContainerClient" in my constructor:
private BlobContainerClient _blobContainerClient;
public Function()
{
_blobContainerClient = new BlobContainerClient(ConnectionString, BlobStorageContainer);
}
And then just uploading the "myBlob" stream with a new "{prefix}/" + name, there after delete the old blob using its original name and prefix as shown below.
_blobContainerClient.UploadBlob("processed/" + name, myBlob);
_blobContainerClient.DeleteBlob("inbound/" + name);
Upvotes: 0