azure-resource-manager-cosmosdb-dotnet
Skill này làm gì
Đoạn mã này giúp tạo và quản lý tài nguyên Azure Cosmos DB bằng ngôn ngữ lập trình .NET. Bạn có thể thiết lập tài khoản, cơ sở dữ liệu và container, cũng như điều chỉnh hiệu suất.
Khi nào nên dùng
- ✓Khi tạo một tài khoản Azure Cosmos DB mới cho ứng dụng.
- ✓Khi thiết lập cơ sở dữ liệu và container để lưu dữ liệu.
- ✓Khi tinh chỉnh hiệu suất (thông lượng) của tài nguyên Cosmos DB.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-resource-manager-cosmosdb-dotnet/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm sao để tạo một tài khoản Azure Cosmos DB với một cơ sở dữ liệu và một container bằng .NET?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ dùng Azure Resource Manager SDK cho .NET, kết nối với tài khoản Azure của bạn. Bạn định nghĩa chi tiết tài nguyên (như tên, vị trí và cài đặt) trong mã, rồi SDK tạo chúng trên Azure.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Bundled upstream support
Supporting files are included at skill-relative paths. See UPSTREAM-NOTICE.md for their pinned sources, licenses, hashes, and import changes.
Azure.ResourceManager.CosmosDB (.NET)
Management plane SDK for provisioning and managing Azure Cosmos DB resources via Azure Resource Manager.
⚠️ Management vs Data Plane
- This SDK (Azure.ResourceManager.CosmosDB): Create accounts, databases, containers, configure throughput, manage RBAC
- Data Plane SDK (Microsoft.Azure.Cosmos): CRUD operations on documents, queries, stored procedures execution
Installation
dotnet add package Azure.ResourceManager.CosmosDB
dotnet add package Azure.Identity
Current Versions: Stable v1.4.0, Preview v1.4.0-beta.13
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id>
# For service principal auth (optional)
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_SECRET=<client-secret>
Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.CosmosDB;
// Always use DefaultAzureCredential
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);
// Get subscription
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var subscription = armClient.GetSubscriptionResource(
new ResourceIdentifier($"/subscriptions/{subscriptionId}"));
Resource Hierarchy
ArmClient
└── SubscriptionResource
└── ResourceGroupResource
└── CosmosDBAccountResource
├── CosmosDBSqlDatabaseResource
│ └── CosmosDBSqlContainerResource
│ ├── CosmosDBSqlStoredProcedureResource
│ ├── CosmosDBSqlTriggerResource
│ └── CosmosDBSqlUserDefinedFunctionResource
├── CassandraKeyspaceResource
├── GremlinDatabaseResource
├── MongoDBDatabaseResource
└── CosmosDBTableResource
Core Workflow
1. Create Cosmos DB Account
using Azure.ResourceManager.CosmosDB;
using Azure.ResourceManager.CosmosDB.Models;
// Get resource group
var resourceGroup = await subscription
.GetResourceGroupAsync("my-resource-group");
// Define account
var accountData = new CosmosDBAccountCreateOrUpdateContent(
location: AzureLocation.EastUS,
locations: new[]
{
new CosmosDBAccountLocation
{
LocationName = AzureLocation.EastUS,
FailoverPriority = 0,
IsZoneRedundant = false
}
})
{
Kind = CosmosDBAccountKind.GlobalDocumentDB,
ConsistencyPolicy = new ConsistencyPolicy(DefaultConsistencyLevel.Session),
EnableAutomaticFailover = true
};
// Create account (long-running operation)
var accountCollection = resourceGroup.Value.GetCosmosDBAccounts();
var operation = await accountCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-cosmos-account",
accountData);
CosmosDBAccountResource account = operation.Value;
2. Create SQL Database
var databaseData = new CosmosDBSqlDatabaseCreateOrUpdateContent(
new CosmosDBSqlDatabaseResourceInfo("my-database"));
var databaseCollection = account.GetCosmosDBSqlDatabases();
var dbOperation = await databaseCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-database",
databaseData);
CosmosDBSqlDatabaseResource database = dbOperation.Value;
3. Create SQL Container
var containerData = new CosmosDBSqlContainerCreateOrUpdateContent(
new CosmosDBSqlContainerResourceInfo("my-container")
{
PartitionKey = new CosmosDBContainerPartitionKey
{
Paths = { "/partitionKey" },
Kind = CosmosDBPartitionKind.Hash
},
IndexingPolicy = new CosmosDBIndexingPolicy
{
Automatic = true,
IndexingMode = CosmosDBIndexingMode.Consistent
},
DefaultTtl = 86400 // 24 hours
});
var containerCollection = database.GetCosmosDBSqlContainers();
var containerOperation = await containerCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-container",
containerData);
CosmosDBSqlContainerResource container = containerOperation.Value;
4. Configure Throughput
// Manual throughput
var throughputData = new ThroughputSettingsUpdateData(
new ThroughputSettingsResourceInfo
{
Throughput = 400
…
Câu hỏi thường gặp
Khác biệt giữa SDK này và Data Plane SDK là gì?
SDK này (Management Plane) dùng để tạo và quản lý hạ tầng Cosmos DB (tài khoản, cơ sở dữ liệu, container). Data Plane SDK (Microsoft.Azure.Cosmos) dùng để tương tác với dữ liệu bên trong các container (thêm, đọc, sửa, xóa và truy vấn).
Làm sao để thiết lập xác thực?
Bạn có thể dùng `DefaultAzureCredential`, công cụ thử nhiều phương thức xác thực, bao gồm biến môi trường cho thông tin service principal hoặc managed identity.
“Thông lượng” (throughput) là gì?
Thông lượng là khả năng xử lý của cơ sở dữ liệu, đo bằng Request Units (RU/s). Bạn có thể đặt thủ công hoặc dùng autoscale để Azure tự điều chỉnh theo nhu cầu.
Chi tiết
Mô tả gốc của tác giả
Azure Resource Manager SDK for Cosmos DB in .NET.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #3973
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
discrawl
394kCho phép agent của bạn tìm kiếm và tóm tắt kho lưu trữ tin nhắn Discord trên máy, kiểm tra độ mới của dữ liệu và đọc tin nhắn trực tiếp.
clickhouse-io
280kGiúp agent của bạn tối ưu truy vấn và schema trong ClickHouse theo thực hành tốt nhất cho phân tích dữ liệu hiệu năng cao khi truy vấn chậm.
scientific-db-pubmed-database
280kGiúp agent của bạn tìm bài báo khoa học trong lĩnh vực y sinh. Hữu ích cho nghiên cứu cần thông tin y khoa cụ thể.