Azure-webjobs-sdk: 3.0.0 rc1 breaking changes against beta5

Created on 19 Sep 2018  路  10Comments  路  Source: Azure/azure-webjobs-sdk

Microsoft.Azure.WebHosts.JobHostConfiguration vanished between 3.0.0-beta5 and 3.0.0-rc1

Repro steps

var configuration = new JobHostConfiguration(#####);

Expected behavior

Compiles

Actual behavior

Type does not exist in Microsoft.Azure.WebHosts.Host assembly

Known workarounds

Not known to me.. Added question to SO. Please update with answer if any.

Related information

https://stackoverflow.com/questions/52383479/what-is-the-replacement-for-microsoft-azure-webhosts-jobhostconfiguration

Most helpful comment

@ranouf You also need to add Microsoft.Azure.WebJobs.Extensions.Storage

<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />

All 10 comments

See code sample in repository https://github.com/Azure/azure-webjobs-sdk/tree/dev/sample/SampleHost

Only thing I can't get to work is dependency injection. Only the defaults (like ILogger, IHost etc) are available and it looks like nothing is done with ConfigureServices delegate. But that's an other issue.

Reading the sample I still can't figure how to feed the fluent chain in HostBuilder with all the info from the code sample on SO :

  • hubName

  • iotHubConnectionString

  • storageContainerName

  • storageConnectionString

  • consumerGroupName

Could you provide an example using these input parameters.

Here's the code sample from SO for convienience:

c# var processorHost = new EventProcessorHost(hubName, consumerGroupName, iotHubConnectionString, storageConnectionString,storageContainerName); processorHost.RegisterEventProcessorAsync<LoggingEventProcessor>().Wait(); var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddEventProcessorHost(hubName, processorHost); var configuration = new JobHostConfiguration(storageConnectionString); configuration.UseEventHub(eventHubConfig); var host = new JobHost(configuration); host.RunAndBlock();

@noontz You can check my reply on issue 1903 and the SO link you mentioned.

This may put you on the right path while the docs are updated.

Not a single warning about this code break?
How can we rely on this services?

@superjulius
As commented to @GuidoNeele: Please supply a working code example matching the prerequisites in the example. It is in no way trivial to supply the 5 keys correctly with the new approach, although it might be cleaner.

@noontz It is not trivial but it is not overly complicated either. V3.0 was just released and we are all excited about it but we may have to wait a bit for MS to get the docs updated before we jump into it or it means that we have to dig into the source code to find our way.

I am not using EventHubs today but searching the code and test, I found that you should be able to do that thru the AddEventHubs extension methods (available in Microsoft.Azure.WebJobs.Extensions.EventHubs package)

var builder = new HostBuilder()
                .ConfigureWebJobs(b =>
                {
                    b.AddAzureStorageCoreServices()
                    .AddAzureStorage()
                    .AddEventHubs(eventHubOptions => {
                        var hubName = "hubName";
                        var iotHubConnectionString = "iotHubConnectionString";
                        var storageContainerName = "storageContainerName";
                        var storageConnectionString = "storageConnectionString";
                        var consumerGroupName = "consumerGroupName";

                        var processorHost = new EventProcessorHost(hubName, consumerGroupName, iotHubConnectionString, storageConnectionString, storageContainerName);
                        eventHubOptions.AddEventProcessorHost("eventHubName", processorHost);
                    })

BTW- also answered you on SO

@superjulius Sure: trivial is relative, and thx for the effort.
I dug into the repos to find the origin of AddAzureStorageCoreServices(this IWebJobsBuilder builder), but the latest (2.2.0 preview2-35157) Microsoft.Extensions.Hosting packet does not seem to contain the implementing RuntimeStorageWebJobsBuilderExtensions class?
Seems like more than the documentation lacks behind

Hi,

I upgraded from 3.0.0-beta5 to 3.0.0.
@superjulius I dont succeed to make your exemple work, AddAzureStorage doesnt exists.
Do you need to add another package than these ones?:

PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.0" 
PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.0"

@ranouf You also need to add Microsoft.Azure.WebJobs.Extensions.Storage

<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />

Thanks @superjulius!

Was this page helpful?
0 / 5 - 0 ratings