title: Why is Azure app service not reliably reading my connection strings when I am using the production (base app service) slot
body: <p>I have an ASP.NET Core 2.1 API that I am deploying to an Azure App Service. I use Azure SQL Server for my backing databases.</p>
  
  <p>Below is a screenshot of the App Service (base) Application Settings blade. This shows the .Net Framework version set to 4.7.</p>
  
  <p><a href="https://i.stack.imgur.com/rXeyi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rXeyi.png" alt="enter image description here"></a></p>
  
  <p>I have the App Service set up with deployment slots. </p>
  
  <p>For each deployment slot, I have connection strings in the Application Settings blade with values specific to that slots databases (I have 3 different databases for each slot and I have 3 slots). </p>
  
  <p>The QA and DEV slots have been working just fine for several months, however, we are now rolling the API out to beta sites using the Production slot (App Service base) and it seems that the connection strings in the Production slot for the App Service are not being reliable read. Specifically, it appears that the 2nd and 3rd connection string are not being reliably read. </p>
  
  <p>Here is a screenshot of the App Service -->Application Setting blade showing the Connection Strings;</p>
  
  <p><a href="https://i.stack.imgur.com/Ka9vm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ka9vm.png" alt="enter image description here"></a>  </p>
  
  <p>As you can see, I have Slot Settings checked for each. The HangfireDbConnectioinString always fails to be read and the UspsReferenceDbConnectionString seems to be flaky, but that may be because the Hangfire database is not getting set up and throws an exception. </p>
  
  <p>I use this same setup for the QA and DEV slots and they work OK. This issue is only happening with the Production slot (base App Service) settings. </p>
  
  <p>If I include the actual connection strings in my AppSettings.json file of my API and redeploy that to the Production slot, the API is able to access the databases correctly. Of course this is not a desirable solution because it puts my connection strings in source control. </p>
  
  <p>In case it matters, here is a screenshot of the base App Service Extensions blade.</p>
  
  <p><a href="https://i.stack.imgur.com/GfF9U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GfF9U.png" alt="enter image description here"></a></p>
  
  <p>Below is the section of code in my Startup.cs that is setting up the databases.</p>
  
  <pre><code>    protected virtual void ConfigureDatabase(IServiceCollection services)
      {
  
          var sqlTransientErrors = new List&lt;int&gt;() { 10928, 10929, 10053, 10054, 10060, 40197, 40540, 40613, 40143, 64 };
  
          // Configure DBContexts with resilient SQL connections to SQL Server
          services.AddDbContext&lt;ManifestContext&gt;(options =&gt;
          {
              options.UseSqlServer(Configuration.GetConnectionString("ManifestDbConnectionString"),
                  sqlOptions =&gt;
                  {
                      sqlOptions.EnableRetryOnFailure(5, TimeSpan.FromSeconds(30),
                          sqlTransientErrors);
                      sqlOptions.CommandTimeout(Convert.ToInt32(Configuration["DbSettings:ManifestDbCommandTimeout"]));
                  });
          });
  
          services.AddDbContext&lt;UspsReferenceContext&gt;(options =&gt;
          {
              options.UseSqlServer(Configuration.GetConnectionString("UspsReferenceDbConnectionString"),
                  sqlOptions =&gt;
                  {
                      sqlOptions.EnableRetryOnFailure(5, TimeSpan.FromSeconds(30), sqlTransientErrors);
                      sqlOptions.CommandTimeout(Convert.ToInt32(Configuration["DbSettings:UspsReferenceDbCommandTimeout"]));
                  });
          });
  
          // Hangfire persistence store for background tasks
          services.AddHangfire(configuration =&gt;
              configuration.UseSqlServerStorage(Configuration.GetConnectionString("HangfireDbConnectionString")));
  
  
      }
  </code></pre>
  
  <p>As you can see, I am using Configuration.GetConnectionString("HangfireDbConnectionString") to retrieve the connection string from Configuration.</p>
  
  <p>Any ideas?</p>