Blog

  • Home
  • Blog
  • How to Manipulate Environment Variables in C#

How to Manipulate Environment Variables in C#

11 March 2024
In an application like a CRM, it is quite common to have configuration variables for different reasons. Whether it is URLs that point to other application or secret APIs or key ... The uses are diverse.
Fortunately Microsoft knows how to respond with the right solutions to problems, and the acceleration of the pace of releases allows us to benefit from new features much more often.

In this article, I would like to present to you how to read and define the values of environmental variables from a plugin C#.

In fact, the environment variable feature does not come in a single table, but in two tables :

  • Environment Variable Definition
  • Environment Variable Value

When you create a new Environment Vaiable in your solution, this actualy creates the environment variable Définition. Which can be deployed later with you solution. If you want to maintain different values for all environments the definition is enought to be imported in the solutions. You probably won't need to deploy the values.

The code below will help you initiate and set the variable values in the target environment.

cookie
Cookies Consent

We use our own and third-party cookies to personalize content and to analyze web traffic.

Reject all