In .Net Core Read appsettings value within an enqueued or recurring job

Tags: #<Tag:0x00007f234e8d1ad0> #<Tag:0x00007f234e8d1a08>

We have been using hangfire for all our background tasks and have a scenario where we would need to read certain values from the appsettings.json file to continue with the job process. Since the HttpContext object is not available, we are not able to get the values from there.

Is there a way to read the appsettings.json file during the execution of the recurring or enqueued job?

Thanks much in advance.

You can just pass required configuration value as a job argument, or inject IConfiguration service in job class constructor and access it from the job method.