This question is related to: .NET Core console application, how to configure appSettings per environment?
Question How do I make a WinForms application environment-aware based on the different subscriptions that we have setup?
Context
I am finding very little documentation and examples on how to handle the deployment of Winforms applications to an Azure VM across multiple subscriptions. For example, if I deploy the Winforms application to a subscription that is marked as development, then it should use both the security groups and the SQL Server that is tied to the Development
subscription. Rinse and repeat for UAT
and Production
.
Currently, we have a WinForms application that has multiple appsettings.<env>.json
files for development, UAT, and production. We are using SlowCheetah
to transform the appsettings.json
file based on what the Configuration Manager says. This appears to be tied to the buildConfiguration
parameter in the MsBuild
pipeline task. We have different environment values in the appsettings files for the SQL Server connection string and security groups.
The application it intended to be deployed through a virtual machine and the environments are subscription-specific. How do we configure each subscription to contain the corresponding environment name and then pass that to the application on runtime? Would we still use SlowCheetah
and set the environment through the buildConfiguration
parameter in the MsBuild
task, or would we do something else?
It seems like we can either go that route or we can use the Environment Variables route, but I don't see how the environment variable can be set for a virtual machine in Azure. Any help, documentation, or examples that I can pursue is greatly appreciated!
Note: for a web-application, this seems pretty straight-forward. Just setup the ASPNETCORE_ENVIRONMENT
variable in both the project and in the Configuration within the App Service
on Azure.