[英]Get Multiple Files From Blob Storage With Azure Function Bindings
Is there a way to get multiple files from azure function bindings without knowing the file or folder names in advance?有没有办法在不事先知道文件或文件夹名称的情况下从 azure function 绑定中获取多个文件? For a different function I have this:
对于不同的 function 我有这个:
public async Task<Activity> GetActivity([ActivityTrigger] Activity activity,
[Blob("activities/migration/{activity.Id}", FileAccess.Read)] Stream activityBlob,
ILogger log)
{
}
And this will get the file from the migration folder based on the id within activity class.这将根据活动 class 中的 id 从迁移文件夹中获取文件。
But for another function there will be a large amount of files some within folders, the ids will not be known in advance.但是对于另一个function,文件夹内的一些文件会有大量文件,ids不会提前知道。 So this cannot be passed as a parameter to access the blob.
所以这不能作为参数传递来访问 blob。
My questions is, is there a 'get all' or 'get recursively' for these bindings?我的问题是,这些绑定是否有“全部获取”或“递归获取”? Something that will get all files and folders within a container?
可以在容器中获取所有文件和文件夹的东西?
If not through bindings perhaps through code?如果不是通过绑定,也许是通过代码?
Its not possible through a blob input binding,but you can use a dynamic input binding to get all the files from a container.please refer below code:-它不可能通过 blob 输入绑定,但您可以使用动态输入绑定从容器中获取所有文件。请参考以下代码:-
public async Task<Activity> Run(
[ActivityTrigger] Activity activity,
IBinder binder,
ILogger log)
{
var blobs= await binder.BindAsync<IEnumerable<CloudBlockBlob>>(new BlobAttribute(blobPath: $"activities/migration")
{
Connection = "AzureWebJobsStorage"
});
}
This will give you a list of all blobs in a container then probably you can proceed further with your operations,Another way would be to use the ListBlobsSegmentedAsync method on a container reference in the code.这将为您提供容器中所有 blob 的列表,然后您可能可以进一步进行操作,另一种方法是在代码中的容器引用上使用ListBlobsSegmentedAsync方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.