从azure-webjobs-sdk-samples(1.0.0-rc1)运行BlobOperations示例时 (https://github.com/Azure/azure-webjobs-sdk-samples/tree/master/BasicSamples/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连接字符串。
我在&#39;真实&#39;中遇到了同样的问题。即将投入生产的项目。
这是一个错误,还是我做错了什么?
答案 0 :(得分:2)
BlobTrigger并不像队列那样即时。 SDK扫描blob容器以检测新blob或是否更新了现有blob,然后触发侦听这些blob的函数。扫描可能需要几秒到几分钟,具体取决于容器的大小。如果您的应用程序需要即时处理,那么您应该使用队列然后绑定到blob。您可以将blob信息(如容器名称和blob名称)作为队列消息放入,然后使用SDK模型绑定功能绑定到Blob属性。
答案 1 :(得分:1)
我遇到了同样的问题,但发现触发器适用于通过Azure Storage Explorer上传的文件,但从Visual Studio上传时从不起作用。引擎盖下可能会有一些奇怪的东西,但我能看到的唯一区别是Visual Studio正在分配正确的mime类型,其中Azure Storage Explorer默认为application / octet-stream。我们只测试了MP4文件,如果这有任何区别的话。
在使用Azure Storage Explorer和Visual Studio进行进一步测试的同时,我们注意到它似乎不是100%可靠,并且也错过了从Azure Storage Explorer上传的内容。
我不知道问题可能与另一个答案中描述的nuget包问题有关。
答案 2 :(得分: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”(已删除的包文件夹,在项目文件中编辑了hintpaths,重新启动VS)我无法复制问题:BlobTrigger拾取了我上传到“输入”容器的文件,就像它应该... ...