How you can Deal with Configuration for More than one Environments in Console App Carrier? – Deployment Pipeline

Anna Kopteva profile picture

@annakoptevaAnna Kopteva

I paintings as a Instrument Engineer in MTS Virtual at the SSO challenge. Love programming and corgi!

Initiatives develop – once in a while quicker than we predict. We all know that handbook paintings takes extra time. I will display how I automatic the provider deployment procedure after problems brought about by way of including the take a look at atmosphere. Our staff has advanced a provider for processing messages from Kafka. This can be a console application that subscribes to subjects, and when messages seem towards every of them, a processing set of rules is achieved.

Right through the primary iterations, the deployment used to be rather easy: we submit the provider in the community, replica construct information to the server, create a docker symbol, and get started the provider in a container.

We lived like this till the take a look at staff joined us and deployed in a trying out atmosphere. The appsettings.json configuration report on this atmosphere used to be other. Subsequently, we confronted any other chore – solving the configuration report manually. At this degree, the human issue intervened; once in a while, we forgot to edit the report, which ended in mistakes and lack of time.

After we were given uninterested in it, we determined to name DevOps to lend a hand. Then again, it nonetheless took time. Subsequently I got here up with an concept and carried out a snappy resolution for dealing with a couple of environments. Listed below are the main points:

Preliminary Prerequisites

Our provider is a console application, and we did not have out-of-the-box answers as equipped within the ASP.NET Core internet application.

The application is introduced from the docker container.

Setup Console App

Smartly, let’s have a look at find out how to use multi-configuration in a console application. First, let’s create information for our environments Checking out and building:


There is not any default nesting in console programs. Subsequently, open the .csproj challenge report and upload:

<ItemGroup> <Content material Come with="appsettings.json"> <CopyToOutputDirectory>At all times</CopyToOutputDirectory> </Content material> <Content material Come with="appsettings.Dev.json;appsettings.Checking out.json;"> <DependentUpon>appsettings.json</DependentUpon> <CopyToOutputDirectory>At all times</CopyToOutputDirectory> </Content material>

It appears a lot better, proper? In a while, I connect information with the call of the advance atmosphere that seemed within the appsettings.json report: