liveBook · Manning

Appsettings.Production.json

As explained in Building Web APIs with ASP.NET Core

An ASP.NET Core configuration file that stores settings specific to the production environment and overrides corresponding values in appsettings.json.

appsettings.Production.json holds settings specific to an ASP.NET Core production environment. It overrides corresponding values in appsettings.json, which supplies the defaults. Development settings can instead come from appsettings.Development.json and a developer’s private secrets.json. section 12.1.4 section 12.3.7

Create the production file on the server during deployment, not in the shared Visual Studio project. Keeping it out of the project reduces the risk of private settings reaching a public repository or an unprotected device. section 12.1.4

For the MyBGList API deployed to a Windows VM:

  • Create the production database, including the login and user needed by its connection string. Give the production login a different password from the development login. section 12.3.6
  • On the VM, create appsettings.Production.json in C:\inetpub\MyBGList, the IIS website’s physical directory where the API artifacts are deployed. section 12.3.7
  • Use the keys from the local secrets.json as a starting point. Replace ConnectionStrings:DefaultConnection with values for the production database, including its production credentials. section 12.3.7
  • Save the file and check that its name ends in .json, not .json.txt—a possible mistake when using Notepad. section 12.3.7

The sample setup leaves the Azure Application Insights connection string and Redis configuration unchanged for simplicity. If those services are used, give development and production separate instances rather than treating the sample values as a production plan. section 12.3.7

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Walks through server-side creation, connection-string changes, and a filename check; stops before publishing and deploying the API.
Examples
Uses a MyBGList production database and an appsettings.Production.json file created in C:\inetpub\MyBGList.
What it assumes
Assumes existing appsettings.json and local secrets.json files, an IIS website directory, and a production database with a login and user.
What you can do after
Operate/configure it by creating a server-side production file with the correct database connection and .json extension.
How it connects
Connects environment-specific configuration to secrets.json, database connection strings, production credentials, and IIS deployment.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.