User Manual

Configuration Management for Different Environments

6/10/26
Configuration Management for Different Environments

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.

Configuration Management Based on Environment Differences

Step 1: Define Your Environments

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.

Step 2: Configure the appsettings.json File

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”
}

Step 3: Create a C# Function That Reads Data Based on Environment Information

You can create a custom C# function to dynamically read data from different environments in your application.

  1. Log in to the Kuika platform.
  2. Open the project you’ll be working on from the Apps screen.
  3. Go to the Datasources module from the top menu.
  1. Click the Create a Function card.
  2. In the list that opens, select the C# Functions option under the Development heading.
  1. Click the edit (pencil) icon at the top of the editor that opens to give the function a name.
  2. Type the following code into the editor:
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; }
}
}
  1. Click the Create button in the upper-right corner to create the function.
You can get AI support while creating your C# functions using Kuika AI in the editor’s right panel, and you can test your code in the Test Console area at the bottom.

Step 4: Automatic Data Usage Based on Environment Information

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.

Step 5: Ease of Deployment

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.

No items found.

Glossary

No items found.

Alt Başlıklar