diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/TestHelpers.cs b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/TestHelpers.cs
index 03aa87472d95..aa323077d94b 100644
--- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/TestHelpers.cs
+++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/TestHelpers.cs
@@ -29,9 +29,9 @@ public static class TestHelpers
/// Delegate used to configure the target extension.
/// Set of test configuration values to apply.
///
- public static TOptions GetConfiguredOptions(Action configure, Dictionary configValues) where TOptions : class, new()
+ public static TOptions GetConfiguredOptions(Action configure, Dictionary configValues, string env = default) where TOptions : class, new()
{
- IHost host = new HostBuilder()
+ IHostBuilder hostBuilder = new HostBuilder()
.ConfigureDefaultTestHost(b =>
{
configure(b);
@@ -39,8 +39,14 @@ public static class TestHelpers
.ConfigureAppConfiguration(cb =>
{
cb.AddInMemoryCollection(configValues);
- })
- .Build();
+ });
+
+ if (env != default)
+ {
+ hostBuilder.UseEnvironment(env);
+ }
+
+ IHost host = hostBuilder.Build();
TOptions options = host.Services.GetRequiredService>().Value;
return options;
diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md
index 8ab3d3ec87b2..c20a695f4db8 100644
--- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md
+++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md
@@ -1,6 +1,7 @@
# Release History
## 5.0.0-beta.5 (Unreleased)
+- QueuesOptions.MaxPollingInterval other than default is now honored in "Development" environment.
## 5.0.0-beta.4 (2021-05-18)
diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/src/StorageQueuesWebJobsBuilderExtensions.cs b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/src/StorageQueuesWebJobsBuilderExtensions.cs
index 2841be5345fc..50af1d956e67 100644
--- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/src/StorageQueuesWebJobsBuilderExtensions.cs
+++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/src/StorageQueuesWebJobsBuilderExtensions.cs
@@ -55,7 +55,7 @@ public static IWebJobsBuilder AddAzureStorageQueues(this IWebJobsBuilder builder
builder.Services.AddOptions()
.Configure((options, env) =>
{
- if (env.IsDevelopment())
+ if (env.IsDevelopment() && options.MaxPollingInterval == QueuePollingIntervals.DefaultMaximum)
{
options.MaxPollingInterval = TimeSpan.FromSeconds(2);
}
diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/StorageQueuesWebJobsBuilderExtensionsTests.cs b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/StorageQueuesWebJobsBuilderExtensionsTests.cs
index 1784a992a37e..661f45819337 100644
--- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/StorageQueuesWebJobsBuilderExtensionsTests.cs
+++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/StorageQueuesWebJobsBuilderExtensionsTests.cs
@@ -61,5 +61,37 @@ public void ConfigureOptions_AppliesValuesCorrectly_Queues()
Assert.AreEqual(10, options.MaxDequeueCount);
Assert.AreEqual(TimeSpan.FromSeconds(15), options.VisibilityTimeout);
}
+
+ [Test]
+ public void ConfigureOptions_SetsPollingIntervalToTwoSecondsInDevelopment()
+ {
+ var values = new Dictionary
+ {
+ };
+
+ QueuesOptions options = TestHelpers.GetConfiguredOptions(b =>
+ {
+ b.AddAzureStorageQueues();
+ }, values, env: "Development");
+
+ Assert.AreEqual(TimeSpan.FromSeconds(2), options.MaxPollingInterval);
+ }
+
+ [Test]
+ public void ConfigureOptions_HonorsExplicitlySetPollingIntervalInDevelopment()
+ {
+ string extensionPath = "AzureWebJobs:Extensions:Queues";
+ var values = new Dictionary
+ {
+ { $"{extensionPath}:MaxPollingInterval", "00:00:42" },
+ };
+
+ QueuesOptions options = TestHelpers.GetConfiguredOptions(b =>
+ {
+ b.AddAzureStorageQueues();
+ }, values, env: "Development");
+
+ Assert.AreEqual(TimeSpan.FromSeconds(42), options.MaxPollingInterval);
+ }
}
}