Skip to main content

.NET Quick Start

Preparations

  1. Have a Tencent Cloud account;
  2. Create a CloudBase environment and obtain the Environment ID
  3. Install .NET Core.

Step 1: Enable Anonymous Login

In the Environment Settings page, click "Login Methods", and then enable anonymous login:

Step 2: Create a .NET Core Project

dotnet new console -o Demo
cd Demo

Step 3: Add CloudBase Sdk Dependency

dotnet add package TencentCloudBase

Step 4: Initialize the Environment and Invoke Anonymous Login

using System;
using System.Threading.Tasks;
using CloudBase;

namespace Demo {
class Program {
static void Main(string[] args) {
// Initialize CloudBase
CloudBaseApp app = CloudBaseApp.Init(
// Fill in your CloudBase env
"your-env-id",
// Set the network request timeout
3000
);

// Get the login state
AuthState state = await app.Auth.GetAuthStateAsync();

// Invoke anonymous login
if (state == null) {
state = await app.Auth.SignInAnonymouslyAsync();
}
}
}
}

After successful login, you can access and utilize various resources of Cloud Development. For details, please refer to the CloudBase SDK documentation.