Azure 存储将 Blob 解析为 Table

Azure Storage Parse Blob into Table

我是 WebJobs 的新手,我正在为一些看似微不足道的事情而苦苦挣扎。我有一个名为 "mydatastorage" 的存储帐户和一个名为 "mydatacontainer" 的容器。我已经在网上搜索了一个星期,现在正在尝试执行以下基本场景:

我有大量 html 文件的 blob(已存储在 Azure 中)。我编写了一些代码,可以使用 html 字符串并将其转换为 TableEntity。然后我想将 TableEntity 保存到 table "mydatatable"。看来我可以使用 [Table] 属性来简化将我的实体保存到 table 的过程,或者在方法调用中手动将其保存到 table。我的问题只是让方法签名正确,然后如何让 blob 进入该方法。我对 [Blob][BlobTrigger] 等所有属性和 ICollector<T> 等类型以及使用它们的正确方法(以及何时)感到有些困惑。如果有人知道解释与此类似情况的教程,我很想知道。

试试 this page for information on using BlobTrigger. All our up-to-date documentation on the WebJobs SDK can be found on this main [resources page}(http://azure.microsoft.com/en-us/documentation/articles/websites-webjobs-resources).

这是一个为您指明正确方向的示例。您可以设置 BlobTrigger 在添加 blob 时触发,并使用 TableAttribute 绑定到输出 table。 ICollector<T> 绑定将为您添加的任何实例添加 table 个实体。您可以在上述资源链接中找到有关 Table 绑定的更多选项。希望这有帮助。

public static void ImportHtmlBlob(
    [BlobTrigger("input/{name}")] Stream input,
    string name,
    [Table("yourtable")] ICollector<YourTableType> output)
{
    ...
}