I participate to websites developments in asp.net core on visual studio. We have created a website, which should be divided in multiple instances. I have only one code and one publishing profile for this code (I don't want to have multiples publishing profiles, only one parameter change).
All of these websites share the same database connection, client.json and web.config. I differentiate all of these websites by their Instances. I don't want to put this instance in the client.json because it is shared. All these websites are supported by one application pool. I don’t know if it is a good idea, we have followed this procedure for helps maintainability (only one pool to restart in case of updates for example).
The solution I have found is to add an environment variable to each of this websites into iis (see Publish to IIS, setting Environment Variable). As said by NickAb, I override my client.json with the value of added to the environment variable (system.webServer/aspNetCore
into Configuration editor
on iis). It works.
My problem is: I have one code for multiples websites published on multiples servers. I don't want to do this update for each websites and servers manually!
I have developed a middleware, which create and maintain websites on multiple servers in C# using Microsoft.Web.Administration
.
Therefore, I search how to add an environment variable to these websites using this library.
I have already tried this way: Environment Variables
Two issues:
- I have IIS 10 and 8 (this solution only works for iis 10 apparently)
- The code works (I mean, I have no exception), but I cannot see the result in the websites system.webServer/aspNetCore
Configuraton editor
in iis.
Is this solution the good one? If it is, what have I missed?
Thank you in advance for your help.