During the application development process, you need to manage different IP addresses or endpoints for various environments, such as test, development, and production. Each environment may have its own unique settings and endpoint information. On the Kuika platform, you can automate this management using configuration files. In this tutorial, you’ll learn about configuration management for different environments and how to read data from the appsettings.json file.
If your application needs to run in test, development, and production environments, you can use different IP addresses or endpoints for these environments. Automating environment-specific settings eliminates the need to make manual changes with every deployment.
You can store IP addresses or endpoints for each environment in the appsettings.json file. Use the same key in the appsettings.json file for each environment and change only the value based on the environment. For example:
Test environment:
“MySettings”: {
“testVar”: “https://test-api.example.com”
}
Development environment:
“MySettings”: {
‘testVar’: “https://dev-api.example.com”
}
Production environment:
“MySettings”: {
‘testVar’: “https://api.example.com”
}
You can create a custom C# function to dynamically read data from different environments in your application.


using Kuika.Common.Attributes;
using Kuika.Common.Enums;
using Newtonsoft.Json;
using System;
using System.Text.Json.Serialization;
namespace Kuika.ThirdPartyApisCollection
{
public class GetVariableClass
{
public static string GetVariable()
{
var variable = ConfigurationHelper.GetEnvinronmentOrAppSettings<MySettings>(“testVar”);
return variable.TestVar;
}
}
[KSettingSectionName(“MySettings”)]
public class MySettings
{
[JsonProperty(‘testVar’)]
[JsonPropertyName(“testVar”)]
public string TestVar { get; set; }
}
}
The GetVariable() function reads the MySettings section in the appsettings.json file of the environment where the application is running and returns the relevant IP or endpoint value.
Thanks to this setup, you don’t need to manually change IP or endpoint information for different environments before each deployment. The application automatically uses the correct settings based on the environment it’s running in.
In this tutorial, you learned how to manage configurations for different environments on the Kuika platform and how to read data from the appsettings.json file.