JobHostConfiguration gone?
See original GitHub issueI have been using WebJobs in a dotnet core project, so I have code like this:
class Program
{
static void Main(string[] args)
{
var loggerFactory = new LoggerFactory();
using (loggerFactory)
{
IServiceCollection serviceCollection = new ServiceCollection();
var cfg = ConfigureServices(serviceCollection, loggerFactory);
var config = new JobHostConfiguration();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(10);
config.Queues.BatchSize = 1;
config.JobActivator = new ServiceJobActivator(serviceCollection);
config.UseTimers();
config.LoggerFactory = loggerFactory;
var host = new JobHost(config);
host.CallAsync(typeof(WebJobsMethods).GetMethod("ProcessMethod"));
host.RunAndBlock();
}
}
This is deployed along with a netcore webapi to an Azure App Service. This code doesn’t compile any more due to JobHostConfiguration being gone… but it probably goes way deeper than that!
Maybe the approach is completely different now? Where do I find the new pattern? Including configuring DI? My webjobs has a continuous job, some timer triggers, and a queuetrigger, configures DI, uses application insights, and logs.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:29 (12 by maintainers)
Top Results From Across the Web
c# - New Azure WebJob Project - JobHostConfiguration ...
JobHostConfiguration is now missing. JobHost constructor now has two parameters, including a new IJobHostContextFactory?
Read more >C# – New Azure WebJob Project – JobHostConfiguration ...
JobHostConfiguration is now missing. JobHost constructor now has two parameters, including a new IJobHostContextFactory? RunAndBlock is missing. It is now ' ...
Read more >How to use the WebJobs SDK - Azure App Service
The JobHostConfiguration class has a UseDevelopmentSettings method that enables development mode. The following example shows how to use ...
Read more >Converting Azure WebJobs to .NET Core
This blog post will walk you through steps we did for migration for one our web jobs over to .NET Core. As seen...
Read more >Solution to "can't be invoked from Azure WebJobs SDK. Is it ...
Is it missing Azure WebJobs SDK attributes? I got this error when I was creating an on-demand WebJob. It should have take a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Microsoft.Azure.WebJobs 3.0.1 was released last night & I tried upgrading from 3.0.0-beta5. I see that JobHostConfiguration is missing RunAndBlock() is missing from JobHost QueueTrigger Attribute is missing.
What are the equivalents for these?
The sample here shows the new host configuration process for a continuous WebJob. That sample doesn’t add/use all possible extensions, it’s meant as a starting point/sample. More notes to answer various questions added above:
config.UseXXX
extension methods migrated toIHostBuilder
builder.AddXXX
methods. As in the sample herebuilder.AddXXX
methods to be present in your solution, you have to add the relevant nuget package for the extension you’re trying to use. E.g.:builder.AddAzureStorage()
. You’ll also generally want to callbuilder.AddAzureStorageCoreServices()
to register the storage based implementations of various system services (singleton blob lease management, etc.). This was a big change from v2 - all the Azure Storage bindings used to be baked into the core WebJobs package. We’ve moved them out into their own extension package.builder.AddServiceBus()
. Note that there was an package rename here to standardize our extension package naming. The package used to be called Microsoft.Azure.WebJobs.ServiceBus - don’t use that one in v3.builder.AddTimers()
. To use timers, you also need to callbuilder.AddAzureStorageCoreServices()
because timers rely on blob leases behind the scenesbuilder.AddApplicationInsights()
as in the sample here.host.RunAndBlock()
is gone - the new pattern is shown in the sample I linked to above (here). I.e. callawait host.RunAsync()
from your async main method after building the host