title: Load Connection String from Config File in Azure Functions
body: <p>In my Azure Function I am using a Library which establishes a connection to an SQL server via the ConnectionString from the ConfigurationManager like this:</p>
  
  <pre><code>var cs = System.Configuration.ConfigurationManager.ConnectionStrings["DbConString"].ConnectionString;
  DbConnection connection = new SqlConnection(cs);
  </code></pre>
  
  <p>Now when i set the connection string DbConString in the portal via the Application Settings everything is working fine. But for local development I use the azure-functions-cli and unfortunately I have no idea where i should place the connection string to have it loaded correctly via the ConfigurationManager. </p>
  
  <p>I've tried to place it in the appsettings.json file but without success. </p>
  
  <p>Edit:
  My appsettings.json currently looks like this:</p>
  
  <pre><code>{
    "IsEncrypted": false,
    "Values": {
      "AzureWebJobsStorage": "",
      "AzureWebJobsDashboard": "",
      "MyServiceBusReader": "Endpoint=sb://xxxx=",
      "DbConStr1": "data source=(localdb)\\MSSQLLocalDB;initial catalog=MyDb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework",
      "ConnectionStrings": {
        "DbConStr2": "data source=(localdb)\\MS..." 
      } 
    }
  }
  </code></pre>
  
  <p>But I am not able to access "DbConStr1" via the ConfigurationManager. 
  Adding "DbConStr2" within "ConnectionStrings" like described <a href="https://blogs.msdn.microsoft.com/cjaliaga/2016/08/10/working-with-azure-app-services-application-settings-and-connection-strings-in-asp-net-core/" rel="noreferrer">here</a> leads to a compilation error. Maybe because I am not using .NET Core?</p>
  
  <p>Edit2:
  I messed up the nesting of "ConnectionStrings". It has to be on the same nesting level as "Values":</p>
  
  <pre><code>{
    "IsEncrypted": false,
    "Values": {
      "AzureWebJobsStorage": "",
      "AzureWebJobsDashboard": "",
      "MyServiceBusReader": "Endpoint=sb://xxxx="
    },
    "ConnectionStrings": {
      "DbConStr": "data source=(localdb)\\MS..." 
    }
  }
  </code></pre>