webjob 错误,从 Azure 存储加载文件时

webjob error, when load file from Azure storage

我在 webapp 中发布了一个 web 作业,运行ning 连续从 Azure blob 读取文件并将数据导入数据库。 但是从 AZure 加载文件时出现问题,问题不是第一次发生,下面是错误消息:

The remote server returned an error: (404) Not Found. at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.DownloadRangeToStream(Stream target, Nullable1 offset, Nullable`1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.DownloadToStream(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) at BankSearch.FileImporter.Services.FileImportService.d__16.MoveNext()

错误发生在下面的行中

try
{
    await fileBlob.DownloadToStreamAsync(fileStream, null, blobRequestOptions, null);
    fileStream.Position = 0;
}
catch (StorageException e)
{
    // Exception Handling & Logging
    logger.Error(
            "failed to load the file from Azure blob, file name : >{filename}, error : {error}, {error2}",
            fileToProcess.FileName, e.Message, e.StackTrace);
    //await SendMappingFailedEmail(fileToProcess, failedColumns);
    //return null;
}

得到这个错误:

  1. 将网络作业发布到 Azure 网络应用。
  2. 运行 webjob 从 blob 中读取 file1,工作正常。
  3. 运行webjob从blob中读取file2,抛出上面的异常
  4. 再次发布 web 作业,运行 从 blob 读取文件 2 的 web 作业,工作正常。
  5. 运行 webjob 从 blob 中读取 file3,抛出相同的异常。

任何人都可以帮我找出 webjob 有什么问题吗? 可以从 webjob 访问 blob 中的文件。

我发现了问题,不同的文件存储在不同的 blob 中,需要在读取新文件之前初始化云 blob 容器