To use Tablestore SDK for .NET to initiate a request, you must configure access credentials. Alibaba Cloud services use access credentials to verify identity information and access permissions. You can select different types of access credentials based on your authentication and authorization requirements.
Prerequisites
Tablestore SDK for .NET is installed. For more information, see Install Tablestore SDK for .NET.
Access credentials
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, you can delete or disable the access credentials 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, you can use an AccessKey pair of your Alibaba Cloud account or a RAM user. For more information about how to obtain an AccessKey pair, see Use AccessKey pairs of RAM users to initiate requests.
An Alibaba Cloud account has full permissions on resources within the account. AccessKey pair leaks of an Alibaba Cloud account pose critical threats to the system. Therefore, we recommend that you use the AccessKey pair of a RAM user that is granted permissions based on the principle of least privilege.
Use the AccessKey pair to specify environment variables.
Mac OSX, Linux, and Unix
export OTS_AK_ENV=<OTS_AK_ENV> export OTS_SK_ENV=<OTS_SK_ENV>
Windows
Open Command Prompt and run the following commands as the administrator:
setx OTS_AK_ENV <OTS_AK_ENV> /m setx OTS_SK_ENV <OTS_SK_ENV> /m
NoteAfter 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.
Use environment variables to pass credentials.
// Obtain access credentials from environment variables. var AccessKeyId = Environment.GetEnvironmentVariable("OTS_AK_ENV"); var AccessKeySecret = Environment.GetEnvironmentVariable("OTS_SK_ENV");
What to do next
After the credential provider is initialized, you need to use the credential provider to create an OTSClient instance. For more information, see Initialize the OTSClient instance.