Configuration
/

Configuration Management for Different Environments

Configuration Management for Different Environments

During the application development process, different IP addresses or endpoints need to be managed for different environments such as test, development and production. Each environment may have its own settings and endpoint information. For example, different IPs such as “testservis” in the development environment and “prodservis” in the production environment can be used. Instead of manually changing this information in every release, it is possible to automatically make these settings according to the environment information. On the Kuika platform, you can utilize configuration files to make this management more effective and eliminate manual changes. In this training content, you will learn how to manage configuration management for different environments and how to read data from appsetting.json file.

How to Manage Configuration for Different Environments?

You can use the “appsetting.json” file provided by Kuika to manage endpoints for different environments. In this file, you can keep different data for each environment and use these settings dynamically while your application is running.

Step 1: Define Your Environments

If your application runs in different environments, such as test, development and production environments, you may need to use different IP addresses or endpoints for these environments. It is important to automate environment-based settings to reduce this manual process.

Step 2: Configure the Appsetting.json File
On the Kuika platform you can use the “appsettings.json” file to store the endpoint or Ip addresses for each environment. By keeping different data for each environment, your application can use these settings without the need for manual changes.

For example, you can keep data for test, development and production environments in the following format.

  "MySettings": {    "TestVar": "Test Environment",    "DevVar": "Development Environment",    "ProdVar": "Production Environment" 

Your app automatically uses this data according to the ambient conditions. This way, you don't need to make manual changes with each new release.

Step 3: Reading Data Based on Environment Information
You can use the following “Custom C#” code structure to dynamically read data from different environments into your application.
You can follow the steps below to use the C# data source:

  1. After logging in to the Kuika platform, open the project you will work on from the “Apps” screen.
  2. Go to the “Datasources” module.
  1. To add a new data source to the application you are developing, click on the “+” icon next to the “Sources” title on the left side of the Data Sources module.
  1. Select “C#” (1) as the Data Sources data source type and enter a name (2).
  2. Then click on the “CREATE” (3) button.
  3. From the screen that opens, you can read data in the following format for test, development and production environments. For example, you can use the Custom C# code example below.

In this code structure, you can use the correct endpoint by pulling the information of the environment your application is running in from the “appsetting.json” file. This eliminates the need for manual processing.

using Kuika.Common.Attributes; using Kuika.Common.Enums; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Text.Json.Serialization; using System.Threading.Tasks; using RestSharp; using System.Data; using Microsoft.Data.SqlClient; using System.Linq; using Kuika.Common.Helpers; ‍namespace Kuika.ThirdPartyApisCollection {     public class GetVariableClass     {         public static string GetVariable()         {             var variable = ConfigurationHelper.GetEnvinronmentOrAppSettings<MySettings>("testVar"); //appsettings.json züerinden veri okuma. ‍            return variable.TestVar;         }     }     [KSettingSectionName("MySettings")] //appsettings.json içerisinde tutacağınız ana objenin ismi      public class MySettings     {         [JsonProperty("testVar")] //appsettings.json üzerinde tuttuğunuz ana objenin içerisindeki değişkenin ismi         [JsonPropertyName("testVar")]         [DefaultValue(null)]         public string TestVar { get; set; } //değişken değeri     } }

Step 4: Automatic Data Usage Based on Environment Information

You can use the code above to determine which environment your application is running in and use the relevant settings. The “Get Variable ()” function reads the data in “appsettings.json” and gets the required IP and endpoint value according to the environment in which the application is running.

Step 5: Streamlining the Publishing Process
With this structure, you do not have to manually change IP or endpoint information for different environments before each broadcast. The application automatically uses the correct settings based on the environment information.
In this guide, you have learned step by step how to manage configuration management for different environments and how to read data from appsettings.json file on Kuika platform. 

No items found.

İlişkili diğer içerikler

No items found.

Sözlük

No items found.

Alt Başlıklar