通用 Azure 函数 - 动态连接

Generic Azure Functions - Dynamic Connections

我想创建并托管一个 azure 函数,它将作为输入 "azure-storage-account-name" 和 "path" 以及 运行 一些通用逻辑,然后是 return 已处理的列表在 that 路径的 that 存储帐户中的 blob。我有 20 个存储帐户,我想在同一个订阅中编写单个 azure 函数,以便在所有帐户中都具有列表功能

我浏览了 Azure 函数文档,无法确定这在当前产品中是否可行。任何指针都会有所帮助

如果您有正确的凭据,您可以使用 Azure Storage REST API to get a list of containers

您可以使用 Azure Functions 的命令式绑定功能。这是示例代码:

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, Binder binder, TraceWriter log)
{
    var attributes = new Attribute[]
    {
        new StorageAccountAttribute("your account"),
        new BlobAttribute("your folder name")
    };

    var directory = await binder.BindAsync<CloudBlobDirectory>(attributes);
    log.Info(directory.ListBlobs().Count().ToString());

    return new HttpResponseMessage(HttpStatusCode.OK);
}