I found a workaround to the above scenario regarding the TimerTrigger. In the ConfigureHostConfiguration we can use the AddInMemoryCollection to set the connectionString "AzureWebJobsStorage".
Dictionary<string, string> connectionStrings =
new Dictionary<string, string>
{
{ "AzureWebJobsStorage", ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ConnectionString},
};
builder.ConfigureHostConfiguration(config =>
{
config.AddInMemoryCollection(connectionStrings);
});
Sadly this will not work on ServiceBusTriggers. But with ServiceBusTriggers we have an ServiceBusOptions that is not empty and can therefore be used.
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddServiceBus(options =>
{
options.MessageHandlerOptions.AutoComplete = false;
options.ConnectionString =
ConfigurationManager.ConnectionStrings["AzureWebJobsServiceBus"].ConnectionString;
});
b.AddTimers();
});