All Products
Search
Document Center

Tablestore:Configure access credentials

Last Updated:Mar 17, 2025

To use Tablestore SDK for .NET to initiate a request to access Tablestore, you must configure access credentials. Alibaba Cloud services use access credentials to verify identity information and access permissions.

Prerequisites

Tablestore SDK for .NET is installed. For more information, see Install Tablestore SDK for .NET.

Access credentials

Important
  • We recommend that you change your access credentials every three months to ensure the security of your Alibaba Cloud account.

  • If access credentials are leaked or no longer used, delete or disable the access credentials at the earliest opportunity to reduce security risks.

If your application is deployed in a secure and stable environment that is not vulnerable to external attacks and requires long-term access to Tablestore by using Tablestore SDK for .NET, you can use an AccessKey pair of your Alibaba Cloud account or a RAM user. For information about how to obtain an AccessKey pair, see Use the AccessKey pair of a RAM user to access Tablestore.

Warning

An Alibaba Cloud account has full permissions on resources within the account. Leaks of the Alibaba Cloud account AccessKey pair pose critical security threats. Therefore, we recommend that you use the AccessKey pair of a RAM user that is granted the minimum required permissions to access Tablestore.

  1. Configure environment variables for an AccessKey pair.

    Mac OSX/Linux/Unix
    # Specify the AccessKey ID.
    export TABLESTORE_ACCESS_KEY_ID=your_access_key_id
    # Specify the AccessKey secret.
    export TABLESTORE_ACCESS_KEY_SECRET=your_access_key_secret
    Windows

    Run the command prompt as an administrator and run the following commands:

    # Specify the AccessKey ID.
    setx TABLESTORE_ACCESS_KEY_ID your_access_key_id /m
    # Specify the AccessKey secret.
    setx TABLESTORE_ACCESS_KEY_SECRET your_access_key_secret /m
    Note

    After you specify the environment variables, you may need to restart the relevant services or development tools such as Integrated Development Environment (IDE) to ensure that the new settings are applied as expected.

  2. Use environment variables to pass credentials.

    // Obtain access credentials from environment variables. 
    var AccessKeyId = Environment.GetEnvironmentVariable("TABLESTORE_ACCESS_KEY_ID");
    var AccessKeySecret = Environment.GetEnvironmentVariable("TABLESTORE_ACCESS_KEY_SECRET");

What to do next

After you initialize a credential provider, you must use the credential provider to create an OTSClient instance. For more information, see Initialize a Tablestore client.