Equivalent to web.config transformations for appsettings.json

Jo 1 Reputation point
2021-12-17T19:28:31.813+00:00

I have 3 App Registrations:
DevWebsite
TestWebsite
Website

We have a Release pipeline set up in Dev Ops for the website with 3 stages: Dev, Test and Production. They are set up as an IIS Deployment job with 2 tasks: IIS Web App Manage and IIS Web App Deploy.

Our existing ASP.NET websites are deployed in this way using web config transformations to ensure the Dev and Test stages point to our Dev and Test websites and databases. This works perfectly for the websites using web.config files.

However, I have a new .NET Core MVC app, set up for release in the same way but it uses appsettings.json instead of web.config and I can't find a way of doing the transformation for Dev and Test stages without commiting the appsettings.json file each time I want to more it through the release stages which is not ideal. Is there an equivalent transformation process for the appsettings.json files and if so, how do I set that up?

Microsoft Entra
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,481 Reputation points
    2021-12-19T09:30:48.55+00:00

    Hi,

    Usually choosing the appropriate appsetting.json is done by setting an environment variable. More info in below article:

    https://stackoverflow.com/questions/46364293/automatically-set-appsettings-json-for-dev-and-release-environments-in-asp-net-c

    Hope this helps!

    1 person found this answer helpful.

  2. Jo 1 Reputation point
    2021-12-25T20:13:16.767+00:00

    In case anyone else struggles with this - the answer to the question of an alternative to the web config transformation using appsettings.json for an IIS deployment on Azure would appear to be this article: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic#json-variable-substitution

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.