title: How to configure Azure App Service application settings for ASP.NET Core 3.1?
body: <p>This ASP.NET Core 3.1 application works fine on the local machine, but when hosted in Azure App Service it does not use the configuration variables set under "Application settings".</p>
  
  <p>The following variables have been created inside of the App Service configuration with the same values set in <code>appsettings.json</code>:</p>
  
  <ul>
  <li>SearchServiceName</li>
  <li>SearchServiceQueryApiKey</li>
  </ul>
  
  <p>How can the controller file method below be changed to use the <code>appsettings.json</code> file locally, and the Azure App service configuration settings in the cloud? <code>appsettings.json</code> is not being included in the repository in Azure DevOps that is built and deployed to Azure App Service.</p>
  
  <h3>Controller file method:</h3>
  
  <p>private void InitSearch()</p>
  
  <pre><code>{
      // Create a configuration using the appsettings file.
      _builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
      _configuration = _builder.Build();
  
      // Pull the values from the appsettings.json file.
      string searchServiceName = _configuration["SearchServiceName"];
      string queryApiKey = _configuration["SearchServiceQueryApiKey"];
  
      // Create a service and index client.
      _serviceClient = new SearchServiceClient(searchServiceName, new SearchCredentials(queryApiKey));
      _indexClient = _serviceClient.Indexes.GetClient("example-index");
  }
  </code></pre>
  
  <h3>appsettings.json</h3>
  
  <pre><code>{
    "SearchServiceName": "example-search-service",
    "SearchServiceQueryApiKey": "example-query-api-key",
    "Logging": {
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Information"
      }
    },
    "AllowedHosts": "*"
  }
  </code></pre>