azure web jobs dashboard is not working when configuring storage connection strings from code

Guy Berman 1 Reputation point Microsoft Employee
2021-05-11T11:57:57.29+00:00

Hey, I am from Azure Monitor team.
Our service is built on top of Azure Web app (API + Web jobs).
So far we configuere AzureWebJobsDashboard & AzureWebJobsStorage in app settings, by deploying them as connection strings settings of the web app, or setting them directly in app settings, and it worked. Means, we were able to see web jobs logs in the Microsoft Azure WebJobs.
Now, since we are trying to avoid secret maintanance, we are trying to configuere those connection strings from JobHostConfiguration, setting the 'StorageConnectionString' & 'DashboardConnectionString' properties with the connection strings, as explained in several docs.
When doing this, we are unable to see the web jobs dashbloard anymore. To be more accurate -
If we remove the 'AzureWebJobsDashboard' & 'AzureWebJobsStorage' app settings and settings the connection string from code in the JobHostConfiguration object, the webjobs dashboard experience is broken and we see the following error:

Make sure that you are setting a connection string named AzureWebJobsDashboard in your Microsoft Azure Website configuration by using the following format DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY pointing to the Microsoft Azure Storage account where the Microsoft Azure WebJobs Runtime logs are stored.

Please visit the article about configuring connection strings for more information on how you can configure connection strings in your Microsoft Azure Website.

The configuration is not properly set for the Microsoft Azure WebJobs Dashboard.
In your Microsoft Azure Website configuration you must set a connection string named AzureWebJobsDashboard by using the following format DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY pointing to the Microsoft Azure Storage account where the Microsoft Azure WebJobs Runtime logs are stored.

Please visit the article about configuring connection strings for more information on how you can configure connection strings in your Microsoft Azure Website.

Any idea how can we solve this without settings those connection strings in the app settings? is it an SDK issue?

SDK version: Microsoft.Azure.WebJobs 2.3.0

The code of setting up the JobHostConfiguration

public static JobHost CreateDefaultServiceBusJobHost(ITracer tracer,
                                                     Dictionary<string, string> queueLogicalToActualNames,
                                                     string serviceBusConnectionString,
                                                     string logsStorageAccountConnectionString,
                                                     int maxConcurrentCalls,
                                                     bool shouldUseTimers = false)
{
    if (_tracer != null)
    {
        throw new InvalidOperationException("Cannot create JobHost twice in the same process");
    }

    _tracer = tracer;

    JobHostConfiguration hostConfig = new JobHostConfiguration
    {
        // Add a name resolver so that queue name can be set from configuration
        NameResolver = new QueueNameResolver(queueLogicalToActualNames),
        StorageClientFactory = new ReliableStorageClientFactory(),
        StorageConnectionString = logsStorageAccountConnectionString,
        DashboardConnectionString = logsStorageAccountConnectionString
    };

    ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration
    {
        ConnectionString = serviceBusConnectionString,
        MessageOptions = new OnMessageOptions
        {
            AutoComplete = true,
            AutoRenewTimeout = TimeSpan.FromMinutes(25),
            MaxConcurrentCalls = maxConcurrentCalls
        }
    };
    serviceBusConfig.MessageOptions.ExceptionReceived += OnExceptionReceived;

    // Add a custom messaging provider for wrapping the MessageProcessor class with traces
    serviceBusConfig.MessagingProvider = new CustomMessagingProvider(serviceBusConfig, _tracer);

    hostConfig.UseServiceBus(serviceBusConfig);
    if (shouldUseTimers)
    {
        hostConfig.UseTimers();
    }

    // add core extension registration for enabling binding of the ExecutionContext
    hostConfig.UseCore();

    var host = new JobHost(hostConfig);

    return host;
}

would appriciate any help

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,829 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 25,476 Reputation points Microsoft Employee
    2021-05-14T00:40:06.25+00:00

    @Guy Berman , If you're using 2.x, there shouldn't be any issues.

    If you set logsStorageAccountConnectionString to UseDevelopmentStorage=true, does it still not save?