imranmomin/Hangfire.AzureDocumentDB

Trying to access Azure Storage inside a BackgroundJob

Closed this issue · 3 comments

I'm using Hangfire in my .net core API with Azure DB. I had successfully connected and was execute sample jobs. I have a method which connects to Azure Storage and fetches a file from Blob and then update data in Cosmos DB.

When I call the method without the Hangfire it is executing fine, but when I call the same method inside the BackgroundJob.Enqueue I get an error stating that the Blob storage was not found. Its Microsoft.AzureStorage Exception.

I'm not sure if I'm missing something that needs to be added. Can you please help me out with the same.

Hey @Naveenjersy

It would be cool to have some sample code.
Actually we are using Hangfire jobs to rename containers in blob storage (aka copy and delete).

Hi @erikpaperik

I figured out that my issue of 'Blob storage was not found' was because it was using incorrect Dependency for the blob initializer.

Do you want me to post my code of how I use Azure Storage inside hangfire jobs?

Hi @Naveenjersy

great to hear that you got it working!

Since your issue was not actually related to the AzureDocumentDB storage implementation but DI configuration in general I think it's not necessary to post it here.

If you can nail it down to some lines you are welcome to share it ;-)