Denis D
Denis D

Reputation: 23

webjob error, when load file from Azure storage

I have a web job published in a webapp, running Continuous to read file from Azure blob and import data into database. but have problem when load file from AZure, the issue is not happen in the first time, below is the error message:

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()

error happen in the line below

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;
}

to get this error:

  1. publish the webjob to AZure web app.
  2. run webjob to read file1 from blob, works fine.
  3. run webjob to read file2 from blob, throw the exception above.
  4. publish the webjob again, run web job to read file 2 from blob, works fine.
  5. run webjob to read file3 from blob, throw the same exception.

can anyone help me to find what's wrong with the webjob? the file from the blob is accessible from webjob.

Upvotes: 0

Views: 410

Answers (1)

Denis D
Denis D

Reputation: 23

I found the issue , the different file are stored in different blob, and need to Initialize the cloud blob container before read new files

Upvotes: 1

Related Questions