question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to set AzureWebJobsDashboard and AzureWebJobsStorage from KeyVault

See original GitHub issue

Description

I want to set the connection string for AzureWebJobsStorage from Key Vault instead of picking from appSettings.json > connectionStrings > AzureWebJobsStorage.

I don’t want to load this from Azure Cloud Configuration either.

Repro steps

I tried using the InMemory configuration and Environment.SetEnvironmentVariable to provide the connection strings as below:

  1. InMemory configuration

var builder = new HostBuilder() `` .ConfigureHostConfiguration(b => { b.AddInMemoryCollection(new Dictionary<string, string> { { “ConnectionStrings:AzureWebJobsDashboard”, storageConnString}, { “ConnectionStrings:AzureWebJobsStorage”, storageConnString}, }); })


2. Setting Environment Variable

Environment.SetEnvironmentVariable(“AzureWebJobsDashboard”, storageConnString); Environment.SetEnvironmentVariable(“AzureWebJobsStorage”, storageConnString);


#### Actual behavior
I get the following error if I do not add the config key "AzureWebJobsDashboard" in appSettings.json, or set it as empty/null.
`ArgumentNullException: Value cannot be null. (Parameter 'connectionString')`



Provide any related information 

* Package version
* Links to source

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
abhishek-msftcommented, Feb 19, 2021

Yes,I used the solution by @mohsinonxrm above.

1reaction
abhishek-msftcommented, Oct 22, 2020

Looks neat!

Get Outlook for Androidhttps://aka.ms/ghei36


From: mohsinonxrm notifications@github.com Sent: Thursday, October 22, 2020 7:34:41 AM To: Azure/azure-webjobs-sdk azure-webjobs-sdk@noreply.github.com Cc: Abhishek Kumar Mishra Abhishek.Mishra@microsoft.com; Mention mention@noreply.github.com Subject: Re: [Azure/azure-webjobs-sdk] Not able to set AzureWebJobsDashboard and AzureWebJobsStorage from KeyVault (#2523)

@abmis-mihttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fabmis-mi&data=04|01|Abhishek.Mishra%40microsoft.com|f18572cca84444da2fc908d8762ed70e|72f988bf86f141af91ab2d7cd011db47|0|0|637389290843047108|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|1000&sdata=5hLuQgcaqwBIefWXXma5xskcX0YVDoV0PX1VHoGTUW4%3D&reserved=0 , here’s how I got it to work `builder.ConfigureHostConfiguration(configuration => { configuration.AddJsonFile(“appsettings.json”, false); var builtConfig = configuration.Build();

        var azureServiceTokenProvider = new AzureServiceTokenProvider();
        var keyVaultClient = new KeyVaultClient(
            new KeyVaultClient.AuthenticationCallback(
                azureServiceTokenProvider.KeyVaultTokenCallback));

        var kvUrl = $"https://{builtConfig.GetValue<string>("KeyVaultName")}.vault.azure.net/";

        if (!string.IsNullOrEmpty(kvUrl))
        {
            configuration.AddAzureKeyVault(new AzureKeyVaultConfigurationOptions { Client = keyVaultClient, Vault = kvUrl });
        }
    });`

That’s it!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-webjobs-sdk%2Fissues%2F2523%23issuecomment-714174280&data=04|01|Abhishek.Mishra%40microsoft.com|f18572cca84444da2fc908d8762ed70e|72f988bf86f141af91ab2d7cd011db47|0|0|637389290843057043|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|1000&sdata=JFl%2B0DOCPXpSWxQyifXYrDZ7aj57K5h3p3oGEl%2FOn%2B0%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAPXYRWVOGVV2REAMUUJSV5LSL6HLTANCNFSM4OCYF3NQ&data=04|01|Abhishek.Mishra%40microsoft.com|f18572cca84444da2fc908d8762ed70e|72f988bf86f141af91ab2d7cd011db47|0|0|637389290843057043|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|1000&sdata=XptNVckma4FzWnwzl1PWutcj3HEvT0YR1lzQsMlkOvY%3D&reserved=0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get AzureWebJobsDashboard through KeyVault
I have tried to do this but am not able to get a definite solution for this. Is there any way to do...
Read more >
AzureWebJobsStorage, the secret you don't need in your ...
A solution could be to store the AzureWebJobsStorage secret value in an Azure Key Vault and use a Key Vault reference to link...
Read more >
Value of AzureWebJobsStorage app setting is invalid. ...
In this article. This event occurs when the value of the AzureWebJobsStorage app setting is set to either an invalid Azure Storage account...
Read more >
App settings reference for Azure Functions
Reference documentation for the Azure Functions app settings or environment variables used to configure functions apps.
Read more >
Working with Azure Key Vault References in Azure App ...
You can easily determine the current, valid secret version to use by checking the Key Vault in question: As I said to a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found