1

从 azure-webjobs-sdk-samples (1.0.0-rc1) ( https://github.com/Azure/azure-webjobs-sdk-samples/tree/master/BasicSamples/BlobOperations ) 运行 BlobOperations 示例时,我有以下问题。

当 WebJob 启动时,BlobTriggers 运行良好:

Job host started
Executing: 'Functions.BlobNameFromQueueMessage' because New queue message 
    detected on 'persons'.
Executing: 'Functions.BlobToBlob' because New blob detected: 
    input/BlobOperations.txt
Executing: 'Functions.BlobTrigger' because New blob detected: 
    output/BlobOperations.txt

但是当我将新文件添加到“输入”(或“输出”)容器时,即使等待超过 10 分钟,也没有任何反应。

当我重新启动 WebJob 时,我上传的文件确实会被 BlobTrigger 拾取!

这是样本中的(未更改的)BlobTrigger:

public static void BlobToBlob([BlobTrigger("input/{name}")] TextReader input, 
    [Blob("output/{name}")] out string output)
{
    output = input.ReadToEnd();
}

这些示例使用的是最新版本的 Azure Webjobs SDK:

<packages>
  <package id="Microsoft.Azure.WebJobs" version="1.0.0-rc1" targetFramework="net45" />
  <package id="Microsoft.Azure.WebJobs.Core" version="1.0.0-rc1" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net45" />
  <package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net45" />
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.0" targetFramework="net45" />
  <package id="WindowsAzure.Storage" version="4.0.1" targetFramework="net45" />
</packages>

我没有更改示例的代码,除了包的位置(我的位于共享位置 - D:\Development\Nuget.Packages)以及 AzureWebJobsDashboard 和 AzureWebJobsStorage 连接字符串。

在即将投入生产的“真实”项目中,我遇到了同样的问题。

这是一个错误,还是我做错了什么?

4

3 回答 3

2

BlobTrigger 不像队列那样即时。SDK 扫描 blob 容器以检测新 blob 或现有 blob 是否已更新,然后触发侦听这些 blob 的函数。扫描可能需要几秒钟到几分钟不等,具体取决于容器的大小。如果您的应用程序需要即时处理,那么您应该使用队列,然后绑定到 blob。您可以将容器名称、blob 名称等 blob 信息作为队列消息,然后使用 SDK 模型绑定功能绑定到 Blob 属性。

于 2014-10-08T14:56:07.610 回答
1

我遇到了同样的问题,但发现触发器适用于通过 Azure 存储资源管理器上传的文件,但从 Visual Studio 上传时永远不会起作用。引擎盖下可能会发生一些奇怪的事情,但我能看到的唯一区别是 Visual Studio 正在分配正确的 mime 类型,其中 Azure 存储资源管理器默认为 application/octet-stream。我们只测试了 MP4 文件,如果这有什么不同的话。

在使用 Azure 存储资源管理器和 Visual Studio 进行进一步测试时,我们注意到它似乎不是 100% 可靠,并且还错过了从 Azure 存储资源管理器上传的内容。

我看不出这个问题可能与另一个答案中描述的 nuget 包问题有关。

于 2015-02-12T16:15:11.803 回答
0

我找到了问题的原因:当我不使用共享的 NuGet 包位置(在我的情况下为“D:\Development\Nuget.Packages”)时,一切正常!默认位置是解决方案目录根目录中的“packages”目录。

我假设共享包文件夹中存在旧版本的包(如“Microsoft.Azure.WebJobs.0.5.0-beta”和“Microsoft.Azure.WebJobs.Core.0.5.0-beta”)是原因我的问题,即使我还没有实际测试过。有谁想要我,请告诉我。

更新:我想在下面的评论中回答 Pranav Rastogi 的问题,但是当我将我的项目恢复为使用“D:\Development\Nuget.Packages”(删除包文件夹,在项目文件中编辑提示路径,重新启动 VS)时,我无法复制问题:BlobTrigger 拾取了我上传到“输入”容器的文件,就像它应该做的那样......

于 2014-10-10T07:39:05.510 回答