Sdk v3 is already released on nuget. Unfortunately documentation has not been updated, neither in Microsoft docs nor in github readme .md
Where can we find guidance? This version introduced severe changes that prevent previous code (and current doc code) to compile
Regards
I agree, I noticed the nuget package was released for v3 but no docs about the breaking changes is easy to find
Yes you guys are right - we're behind on doc updates. We're hoping to get some updated docs/wiki content out soon.
In the mean time, there is the sample app https://github.com/Azure/azure-webjobs-sdk/blob/dev/sample/SampleHost/Program.cs which shows new way to start a JobHost.
The sample app does not show how to set up and configure timer based jobs.
The SDK sample referenced above just shows usage of the core extensions in that repo. For some of the other extensions, you can see their usage in the Extensions repo sample here. Specifically, you can see the builder.AddTimers() call here and that method takes an overload allowing you to specify a TimersOptions.
Thanks, that is helpful!
What happened to where you configure connection strings?
I had code like this:
config.StorageConnectionString = cfg["AzureWebJobsStorage"];
config.DashboardConnectionString = cfg["AzureWebJobsDashboard"];
I have a QueueTrigger and want to set the connection string for where to read from
I also need to set where to log to for the dashboard?
One more: in my code, I was injecting an IServiceScopeFactory into my web methods class (the one that has the timer methods to call). But now this class only takes a default constructor, so I can't inject anything. If I need to inject into my methods, with a scope that is the same as that of the timer trigger, how do I do that?
public async Task TripDepartureTimerAsync(
[TimerTrigger("0 */10 * * * *", RunOnStartup = true)]
TimerInfo timerInfo,
TextWriter log)
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var ttp = scope.ServiceProvider.GetRequiredService<ITimedTaskProcessor>();
await ttp.CheckLateDeparturesAsync();
}
}
One more issue - my webjob has a continuous method (ProcessMethod) below... so that await never returns and I don't get to host.RunAsync...
var host = builder.Build();
using (host)
{
var jobHost = (JobHost)host.Services.GetService<IJobHost>();
await jobHost.CallAsync(typeof(WebJobsMethods).GetMethod("ProcessMethod"));
await host.RunAsync();
}
If I remove the await, it works... but the compiler warns me. Is there a better pattern now for a continous jobloop?
One more: in my code, I was injecting an IServiceScopeFactory into my web methods class (the one that has the timer methods to call). But now this class only takes a default constructor, so I can't inject anything. If I need to inject into my methods, with a scope that is the same as that of the timer trigger, how do I do that?
public async Task TripDepartureTimerAsync( [TimerTrigger("0 */10 * * * *", RunOnStartup = true)] TimerInfo timerInfo, TextWriter log) { using (var scope = _serviceScopeFactory.CreateScope()) { var ttp = scope.ServiceProvider.GetRequiredService<ITimedTaskProcessor>(); await ttp.CheckLateDeparturesAsync(); } }
You need to set up an IJobActivator - referenced in #1917 (workaround in #1915) for the time being to inject your dependencies.
Any news on this?
I too have the same question as @johnkwaters
What happened to where you configure connection strings?
I had code like this:config.StorageConnectionString = cfg["AzureWebJobsStorage"];
config.DashboardConnectionString = cfg["AzureWebJobsDashboard"];
Where does one set these connection strings now? I've tried looking at the SampleHost sample code but don't see these anywhere.
@mathewc Any estimate on when the docs or wiki will be ready? I had everything working perfectly before the update to core, now I am completely lost and confused; even partially completed docs would be better than nothing.
What about my question about the continuous job - is there a pattern?
var builder = new HostBuilder()
.UseEnvironment(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"))
.ConfigureAppConfiguration((context, config) =>
{
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: false, reloadOnChange: true);
// Load in Azure Key Vault Secrets
var builtConfig = config.Build();
config.AddAzureKeyVault(
$"https://{builtConfig["AzureAdAuthentication:VaultName"]}.vault.azure.net/",
builtConfig["AzureAdAuthentication:ClientId"],
builtConfig["AzureAdAuthentication:ClientSecret"]);
builtConfig = config.Build();
// Setup Web Job Specific Secrets to be setup as in memory objects so Web Jobs SDK can pick them up
Dictionary<string, string> azureWebJobsSecrets = new Dictionary<string, string>();
azureWebJobsSecrets["AzureWebJobsStorage"] = builtConfig["JobStorage"];
azureWebJobsSecrets["AzureWebJobsDashboard"] = builtConfig["DashboardStorage"];
// Add in Memory Collection to allow for Web Jobs SDK to pick up required configs
config.AddInMemoryCollection(azureWebJobsSecrets);
})
.ConfigureLogging((context, logging) =>
{
logging.AddConfiguration(context.Configuration.GetSection("Logging"));
logging.AddConsole();
string appInsightsKey = context.Configuration["InstrumentationKey"];
if (!string.IsNullOrEmpty(appInsightsKey))
{
logging.AddApplicationInsights(o => o.InstrumentationKey = appInsightsKey);
}
})
.ConfigureWebJobs((context) =>
{
context.AddTimers();
context.AddDashboardLogging();
context.AddAzureStorageCoreServices();
})
.UseConsoleLifetime();
var host = builder.Build();
using (host)
{
host.RunAsync().Wait();
}
This is how I had setup the everything for my app in WebJobs SDK 3.0. After some digging through the code i figured out how to load in the webjobs specific information. I used key vault here to build a inmemory configuration object that web jobs could use, so didn't have to put any secrets in my appsettings during deployment. It will also work if you just have the appsettings within your appsettings.json file as this:
{
// Other Settings
"AzureWebJobsStorage": "connectionstring",
"AzureWebJobsDashboard": "connectionstring"
}
So ultimately it seems you just need two config settings with the same names as before, AzureWebJobsStorage and AzureWebJobsDashboard, that you can pull from wherever you want. And then you need to add context.AddDashoardLogging and context.AddAzureStorageCoreServices. Right?
Correct. I currently have 2 web jobs on separate apps tied to one of my storage accounts which doesn't seem to be working. This I believe is a user error on my part and I plan to resolve this today.
AzureStorageCoreServices is the method for the storage account used by WebJobs/Functions to acquire blob leases in table storage to support singletons or timers or any lease based extension for its core functionality. I believe this was mentioned (Breaking Changes) where they separated table storage core services from other table storage extensions, to support independent versioning.
Looks like context.AddDashboardLogging; is obsolete now.
i still haven't seen a pattern for how to call a continuous job - this was present in 2.0. What's the replacement?
3 weeks ago sdk 3.0 was released. No guidance or samples are available, so this sdk is from my point of view unusable.
Do you have any target date to release them?
Almost every OS project have at least a Readme instructing users how they must use it ... this is very frustrating coming from Microsoft
Upgraded to 3.x from the 1.x template that ships with the "latest" azure web jobs sdk for visual studio 2017, and QueueTrigger and JobHostConfiguration just disappeared from the earth. Sigh..
I think it was a mistake to update the project template to use net 4.7.1 yet keep the 1.x webjobs code. If you guys had left the project at 4.5 or something beneath netstandard 2.0, then the upgrade path would have limited us to 2.x and kept the template code functional.
What happened to where you configure connection strings?
I had code like this:config.StorageConnectionString = cfg["AzureWebJobsStorage"];
config.DashboardConnectionString = cfg["AzureWebJobsDashboard"];I have a QueueTrigger and want to set the connection string for where to read from
I also need to set where to log to for the dashboard?
I was having an issue with the AzureWebJobsServiceBus connection string, but after some digging in the source:

I found that they had changed the connection string name to just ServiceBus. Maybe they followed the same pattern for AzureWebJobsStorage->Storage & AzureWebJobsDashboard->Dashboard.
Any news on this, looking to upgrade but can't find any docs?
More than 3 months later we are still missing some guidance
If using .NET Framework and added appsettings.json to your project, don't forget to mark this file as "Copy always" or "Copy if newer". If the JSON file is not copied to the app folder (for example, bin/Debug), it will not load your settings.
There's any host.RunAsync in WebJobApi
@tuanfred yes, there is.
var host = builder.Build();
using (host)
{
await host.RunAsync();
}
+1 to this; some of documentation on the Wiki on Git Hub still has examples for items and classes removed in SDK 2.2 and earlier. There are different guides across the multiple places documentation exists that only work on certain versions of the SDK and it is not documented which one it applies to.
Looking through the source code there are multiple unit tests that return Task.Completed and do not test anything. The examples and unit tests seem to have a wide number gaps in functionality, I have been unable to find many tests or examples around setting up the various hosts.
Typically not having to deal with lack of documentation like this is why I have choosen to work a Microsoft stack. Its a huge risk for enterprise adoption when breaking changes are so frequent; which I understand with the core framework maturing this will happen but without some documentation it makes this very difficult.
Have they made everybody working there redundant?! There is absolutely nobody even bothering to reply to any of the issues here or in other posts in so many month. This is just ridiculous and very frustrating.
@batizar This is currently being worked on and should be released imminently. See https://github.com/MicrosoftDocs/azure-docs/issues/22181 for details
No one is there to help us, there's really a problem of documentation of Webjob SDK 3 (with .Net standard 2.0) . All documentation of Webjob are outdated like :
https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to
https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started
https://github.com/Azure/azure-webjobs-sdk/wiki
https://github.com/Azure/azure-webjobs-sdk-samples
By the way, i see some other documentation not about WebJob, but exactly about how to host a job as background here :
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-2.2
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-2.2#timed-background-tasks
My need is to have a webjob with a timer and run in continuous and i stay always with the version of Webjob SDK 3.0.0-beta5
i found this interessing article, this may help others https://dotnetcoretutorials.com/2018/12/05/azure-webjobs-in-net-core-part-5/
@ggailey777 has a couple PRs updating https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/app-service/webjobs-sdk-get-started.md and https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/app-service/webjobs-sdk-how-to.md for v3.x. Those updates should be published live soon.
From then on, the standard feedback links on the doc can be used to provide feedback, and issues for doc can be created in the docs repo: https://github.com/MicrosoftDocs/azure-docs/issues rather than this repo.
We'll wait for the doc to go live before closing this issue.
Thank you for the answer. I feel sorry that new API do not accept to set AzureWebJobsStorage by code and force us to use appsetting. This's a regression feature from 2.x. I do not use AppSetting but yaml config.
This's a blocking feature for me and i have to stay with a beta version of WebJob SDK 3.x
New doc is now live:
For any further issues, use the feedback links on the doc, and issues for doc can be created in the docs repo: https://github.com/MicrosoftDocs/azure-docs/issues rather than this repo.
Here is an full example including
https://gist.github.com/cyptus/1c4d5d2c0f848cd577a7464738625eb1/
Just a comment to whose that rewrite this part of config management for WebJob SDK. You write a public library, you should not force users to have a config file with a specified config name. This's anti patttern. Netcore use dependancy injection as defaut behavior, and dependancy injection is to reduce dependancy, not to create a strong dependancy. Please let it possible to inject configuration like all other dependancies of a service
Imagine if you use this behavior for all configuration dependancies (bus, sql server, cosmos db, storage, ..... ) and if you have multiple connectionstrings for each service ....
Most helpful comment
3 weeks ago sdk 3.0 was released. No guidance or samples are available, so this sdk is from my point of view unusable.
Do you have any target date to release them?
Almost every OS project have at least a Readme instructing users how they must use it ... this is very frustrating coming from Microsoft