Prior to Beta-8
We could set MaxPollingInterval, BatchSize, etc from the JobHostConfiguration object.
ex.
var configuration = new JobHostConfiguration();
configuration.Queues.MaxPollingInterval = TimeSpan.FromSeconds(5);
configuration.Queues.VisibilityTimeout = TimeSpan.FromMinutes(1);
configuration.Queues.BatchSize = 10;
configuration.Queues.MaxDequeueCount = 3;
But with the new HostBuilder() object, I am unable to locate properties for these. How can I go about configuration this in beta-8
Everything else works so far.
Thanks
Im also looking for a solution for this because i need to set the queuenameresolver? Did you find out how to set the Queueoptions?
I have not tried it out yet but searching the source code, I think that you could do this in the appSettings file with a key like "AzureWebJobs:Extensions:Queues:BatchSize"
You can check the unit test method ConfigureOptions_AppliesValuesCorrectly_Queues
Else try looking at the class QueueOptions, which should be configurable directly on the QueueTrigger attribute
@1zias01 @vertical-codes I am starting to dig into the new SDK and below is how I managed to specify options and to hook a QueueNameResolver with 3.0 simply using DI
Note that there is supposedly a DefaultNameResolver which should be registered with ConfigureWebJobs but it did not seem to work for me.
```C#
public static async Task Main(string[] args)
{
var builder = new HostBuilder()
.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices().AddAzureStorage();
})
.ConfigureAppConfiguration(b =>
{
...
})
.ConfigureLogging((context, b) =>
{
...
});
builder.ConfigureServices((services) => {
services.AddSingleton
services.Configure
{
//maximum number of queue messages that are picked up simultaneously to be executed in parallel (default is 16)
options.BatchSize = 2;
//Maximum number of retries before a queue message is sent to a poison queue (default is 5)
options.MaxDequeueCount = 3;
//maximum wait time before polling again when a queue is empty (default is 1 minute).
options.MaxPollingInterval = System.TimeSpan.FromSeconds(60);
});
});
var host = builder.Build();
using (host)
{
await host.RunAsync();
}
}
public class QueueNameResolver : INameResolver
{
private readonly IConfiguration _configuration;
public QueueNameResolver(IConfiguration configuration)
{
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
}
public string Resolve(string name)
{
// implement your logic
return name;
}
}
```
I did the same exact thing implementing INameResolver. I stumbled upon it since I had it wired up in DI from before. So I second that answer. And thanks for the reply!
Looks like you guys helped answer the question, thanks :) There is also an overload on AddAzureStorage that allows you to specify the configure delegate inline for QueuesOptions.
I upgraded from 3.0.0-beta5 to 3.0.0.
@superjulius _QueuesOptions_ is not available, where did you find it?
@ranouf This is available in Microsoft.Azure.WebJobs.Extensions.Storage nuget package
I installed the nuget package Microsoft.Azure.WebJobs.Extensions.Storage version v3.0.1, yet it complains it can't find the following extensionfunctions:
.AddAzureStorageCoreServices()
.AddAzureStorage()
.AddServiceBus()
.AddEventHubs();
.AddCommandLine(args);
.AddConsole();
Edit: Fixed it with using the most basic solution, restarting Visual Studio... You have to be kidding me.
Most helpful comment
@1zias01 @vertical-codes I am starting to dig into the new SDK and below is how I managed to specify options and to hook a QueueNameResolver with 3.0 simply using DI
Note that there is supposedly a DefaultNameResolver which should be registered with ConfigureWebJobs but it did not seem to work for me.
```C#
public static async Task Main(string[] args)
{
var builder = new HostBuilder()
.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices().AddAzureStorage();
})
.ConfigureAppConfiguration(b =>
{
...
})
.ConfigureLogging((context, b) =>
{
...
});
builder.ConfigureServices((services) => {();(options =>
services.AddSingleton
services.Configure
{
//maximum number of queue messages that are picked up simultaneously to be executed in parallel (default is 16)
options.BatchSize = 2;
//Maximum number of retries before a queue message is sent to a poison queue (default is 5)
options.MaxDequeueCount = 3;
//maximum wait time before polling again when a queue is empty (default is 1 minute).
options.MaxPollingInterval = System.TimeSpan.FromSeconds(60);
});
});
var host = builder.Build();
using (host)
{
await host.RunAsync();
}
}
public class QueueNameResolver : INameResolver
{
private readonly IConfiguration _configuration;
public QueueNameResolver(IConfiguration configuration)
{
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
}
public string Resolve(string name)
{
// implement your logic
return name;
}
}
```