This document provides instructions for working with .NET and the CommandK CLI. It explains how to run your .NET application and manage secrets effectively using the CommandK CLI.


Before you begin the integration process, make sure you have the following:

  1. API Access Token: To authenticate your .NET application with CommandK, you'll need an API access token. If you haven't obtained one yet, refer to this link for instructions on how to acquire it.

Integration Steps

Follow these steps to integrate CommandK with your .NET application:

Step 1: Create a .NET Application

If you haven't already created a .NET application, you can set up a new project using the .NET CLI or any other preferred method. Here, we'll use the .NET CLI for demonstration:

  1. Create a new .NET project using the following command:

    dotnet new console -n my-dotnet-app

    Replace my-dotnet-app with your desired project name.

  2. Navigate to the project directory:

    cd my-dotnet-app

Step 2: Access Secrets in Your .NET Application

Inside your .NET application, you can access secrets as environment variables. Open the Program.cs file in your project directory and add the following code snippet:

using System;

namespace my_dotnet_app
    class Program
        static void Main(string[] args)
            // Environment variable for CommandK secret key
            string commandkSecretKey = Environment.GetEnvironmentVariable("COMMANDK_SECRET_KEY");

            Console.WriteLine($"CommandK Secret Key: {commandkSecretKey}");

            // Your application logic here...

In this code, COMMANDK_SECRET_KEY is the environment variable that will store your secret.

Running Your .NET Application

To run your .NET application with the CommandK CLI, you can use the following command:

$ cmdk run <application-name> --environment development -- dotnet run

Replace <application-name> with the actual name of your .NET application. This command will execute your .NET application, running it with the .NET runtime.

By following these instructions, you can seamlessly integrate the CommandK CLI with your .NET application, making it easy to manage secrets and run your application securely.