.NET/C# SDK installation

2 minute read

Control feature rollout for certain user segments of your application with feature flags. To start using feature management in the platform, follow the instructions below to install the SDK and deploy a feature flag.

These same instructions are available in the platform UI. Select Installation from the left pane to use.

To install the SDK:

  1. Select Feature management  Installation.

  2. Select an Environment from the options, or create an environment by completing the following:

    1. Select CREATE ENVIRONMENT.

    2. Enter an Environment name.

    3. (Optional) Enter a Description.

    4. (Optional) Select Approvers if you want to have a manual approval required before deployment.

    5. (Optional) Enter any Properties you want to associate with the environment. For more information, refer to properties configuration and properties in an environment.

    6. Select SUBMIT.

  3. Select .NET/C# from the language options.

  4. Select a type of platform from the options.

  5. Add the ROX package to your application by running the shell commands appropriate for your CLI or package manager, listed in the following table:

    Table 1. Commands to add the ROX package to your application
    Type of platform Command to run

    CLI

    dotnet add package rox-server

    Package manager

    Install-Package rox-server

  6. Add the following code to your .NET/C# application:

    Your SDK key is a unique environment identifier. During SDK installation, the SDK key is displayed within the Rox.setup call.
    using Io.Rollout.Rox.Server; using Io.Rollout.Rox.Core.Entities; using Io.Rollout.Rox.Server.Flags; using System; using System.Threading.Tasks; namespace dotnet { // Create a Roxflag in the Flag continer class public class Flags : IRoxContainer { public RoxFlag enableTutorial = new RoxFlag(false); public RoxString titleColors = new RoxString("White", new String[] {"White", "Blue", "Green"}); public RoxInt titleSize = new RoxInt(12, new int[] {12, 14, 18}); public RoxDouble specialNumbers = new RoxDouble(3.14, new double[] { 2.71, 0.577 }); } class Program { static async Task Main(string[] args) { Flags flags = new Flags(); // Register the flag container Rox.Register("", flags); var options = new RoxOptions(new RoxOptions.RoxOptionsBuilder {}); // Set the environment key await Rox.Setup("<your-SDK-key>", options);(1) // Boolean flag example Console.WriteLine("enableTutorial " + flags.enableTutorial.IsEnabled()); // string flag example Console.WriteLine("titleColors value is " + flags.titleColors.GetValue()); // int flag example Console.WriteLine("titleSize value is " + flags.titleSize.GetValue()); // double flag example Console.WriteLine("specialNumbers value is " + flags.specialNumbers.GetValue()); } }
    1 The platform provides the unique SDK key for your environment at the <your-SDK-key> location within the Rox.setup call.
  7. Run your application and then select TEST INTEGRATION to confirm a successful connection.

After running the application, a default flag is automatically added to your feature flag list.

You have installed an SDK and created flags in your application.

Refer to the SDK reference for more information.