[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Registry](../../index.md) > [Step-by-step guides](../index.md) > Managing artifacts > NuGet artifact > Setting up NuGet

# Setting up NuGet

1. Create the following environment variables depending on the authentication method:
   
   {% list tabs group=registry_auth %}
   
   - IAM token {#iam-token}
   
     1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) for the [Yandex account](../../../iam/operations/iam-token/create.md) or [service account](../../../iam/operations/iam-token/create-for-sa.md) you are going to use for authentication.
     1. Create the `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` environment variables:
   
         ```bash
         export REGISTRY_USERNAME="iam"
         export REGISTRY_PASSWORD="<IAM_token>"
         ```
   
         Where:
   
         * `REGISTRY_USERNAME`: Authentication method.
         * `REGISTRY_PASSWORD`: Body of the previously obtained IAM token.
   
     {% note info %}
   
     The IAM token's [lifetime](../../../iam/concepts/authorization/iam-token.md#lifetime) is limited to 12 hours.
   
     {% endnote %}
   
   - API key {#api-key}
   
     1. [Create](../../../iam/operations/authentication/manage-api-keys.md#create-api-key) an API key for the [service account](../../../iam/concepts/users/service-accounts.md) you are going to use for authentication.
     1. Create the `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` environment variables:
   
         ```bash
         export REGISTRY_USERNAME="api_key"
         export REGISTRY_PASSWORD="<API_key>"
         ```
   
         Where:
   
         * `REGISTRY_USERNAME`: Authentication method.
         * `REGISTRY_PASSWORD`: Body of the previously created [API key](../../../iam/concepts/authorization/api-key.md).
   
     {% note info %}
   
     The API key maximum [lifetime](../../../iam/concepts/authorization/api-key.md#scoped-api-keys) is set manually when you create the key.
   
     {% endnote %}
   
   {% endlist %}
1. Set up the [NuGet](../../concepts/artifacts/nuget.md) configuration file:

    {% list tabs %}

    - dotnet CLI

      To edit the NuGet configuration file using the [dotnet CLI](https://learn.microsoft.com/en-us/nuget/reference/dotnet-commands), run this command:

      ```bash
      dotnet nuget add source "https://registry.yandexcloud.net/nuget/v3/<registry_ID>/index.json" \
        -n "cloud-registry" \
        -u %REGISTRY_USERNAME% \
        -p %REGISTRY_PASSWORD% \
        --store-password-in-clear-text --protocol-version 3
      ```

    - NuGet CLI

      To edit the NuGet configuration file using the [NuGet CLI](https://learn.microsoft.com/en-us/nuget/reference/nuget-exe-cli-reference), run the `nuget.exe` file with the following parameters:

      ```
      nuget sources add -Name "cloud-registry" \
        -Source "https://registry.yandexcloud.net/nuget/v3/<registry_ID>/index.json" \
        -Username "%REGISTRY_USERNAME%" \
        -Password "%REGISTRY_PASSWORD%" \
        -StorePasswordInClearText -ProtocolVersion 3
      ```

    - Manually

      1. Open the NuGet [configuration file](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#config-file-locations-and-uses):

          {% note info %}

          When using the dotnet CLI, the configuration file is located at `~/.nuget/NuGet/NuGet.Config`, while for the NuGet CLI, at `~/.config/NuGet/NuGet.Config`.

          {% endnote %}

      1. Update the configuration in the file as follows:

          ```xml
          <?xml version="1.0" encoding="utf-8"?>
          <configuration>
            <packageSources>
              <add key="cloud-registry" value="https://registry.yandexcloud.net/nuget/v3/<registry_ID>/index.json" protocolVersion="3" />
            </packageSources>

            <packageSourceCredentials>
              <cloud-registry>
                <add key="Username" value="%REGISTRY_USERNAME%" />
                <add key="ClearTextPassword" value="%REGISTRY_PASSWORD%" />
              </cloud-registry>
            </packageSourceCredentials>
          </configuration>
          ```

    {% endlist %}