英文:
Moving blob that triggered Azure function from "sub folder" to "sub folder"
问题
将触发 Azure 函数的博客从 Blob 容器的“子文件夹”移动到另一个子文件夹的最佳方法是什么?我知道 Azure 函数的 Blob 容器是扁平的,所以我所说的子文件夹实际上是 Blob URI 中的前缀,为了保持上下文简单。
但是假设我的函数应用从我的 Blob 入站“子文件夹”中获取一个名为“my blob”的 Blob。
在这种情况下,最佳做法是什么?我猜想它可能涉及更改“myBlob”的前缀,使用新的前缀保存它,并删除原始的前缀?
英文:
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?
答案1
得分: 0
在我的情况下,我认为我走在了正确的轨道上,这对我起作用:
首先在我的构造函数中声明“BlobContainerClient”:
private BlobContainerClient _blobContainerClient;
public Function()
{
_blobContainerClient = new BlobContainerClient(ConnectionString, BlobStorageContainer);
}
然后,只需使用新的“{prefix}/” + name上传“myBlob”流,然后使用原始名称和前缀删除旧的blob,如下所示:
_blobContainerClient.UploadBlob("processed/" + name, myBlob);
_blobContainerClient.DeleteBlob("inbound/" + name);
英文:
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);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论