본문으로 건너뛰기
Skillpedia
데이터베이스48k · #3919

azure-cosmos-rust

하는 일

Rust로 작성된 프로그램이 Azure Cosmos DB NoSQL 데이터베이스와 상호작용하도록 해 주는 도구입니다. 그 안에 저장된 정보를 만들고, 읽고, 수정하고, 삭제할 수 있습니다.

사용하는 경우

  • ✓Rust 프로그램이 데이터를 저장하거나 불러와야 할 때.
  • ✓분산 데이터베이스의 정보를 관리할 때.
  • ✓Cosmos DB의 데이터에 기본 작업(생성, 읽기, 수정, 삭제)을 수행할 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-cosmos-rust/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-cosmos-rust/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Rust를 사용해 Cosmos DB 컨테이너에 새 항목을 만들려면 어떻게 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

Rust 프로그램은 특별한 라이브러리(SDK)를 사용해 Azure Cosmos DB에 연결합니다. 데이터의 구조를 정의하고, 원하는 작업을 수행하도록 데이터베이스에 명령을 보냅니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Azure Cosmos DB SDK for Rust

Client library for Azure Cosmos DB NoSQL API — globally distributed, multi-model database.

The examples below require a reviewed compatible crate set and replacement of every resource placeholder. Do not use production data for demonstration writes.

Installation

cargo add azure_data_cosmos@=0.37.1 azure_identity@=1.0.0 azure_core@=1.1.0

Environment Variables

export COSMOS_ENDPOINT="https://<account>.documents.azure.com:443/"
export COSMOS_DATABASE="mydb"
export COSMOS_CONTAINER="mycontainer"

Authentication

use azure_identity::DeveloperToolsCredential;
use azure_data_cosmos::{AccountEndpoint, AccountReference, CosmosClient, RoutingStrategy};

let credential = DeveloperToolsCredential::new(None)?;
let endpoint: AccountEndpoint = "https://<account>.documents.azure.com/".parse()?;
let account = AccountReference::with_credential(endpoint, credential.clone());
let client = CosmosClient::builder()
    .build(account, RoutingStrategy::ProximityTo("East US".into()))
    .await?;

Client Hierarchy

Client Purpose Get From
CosmosClient Account-level operations Direct instantiation
DatabaseClient Database operations client.database_client()
ContainerClient Container/item operations database.container_client()

Core Workflow

Get Database and Container Clients

let database = client.database_client("myDatabase");
let container = database.container_client("myContainer", None).await?;

Create Item

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
struct Item {
    pub id: String,
    pub partition_key: String,
    pub value: String,
}

let item = Item {
    id: "1".into(),
    partition_key: "partition1".into(),
    value: "hello".into(),
};

container.create_item("partition1", "1", item, None).await?;

Read Item

let response = container.read_item("partition1", "1", None).await?;
let item: Item = response.into_model()?;

Replace Item

let mut item: Item = container.read_item("partition1", "1", None).await?.into_model()?;
item.value = "updated".into();

container.replace_item("partition1", "1", item, None).await?;

Patch Item

// Explicit preview opt-in: cargo add azure_data_cosmos@=0.37.1 --features preview_patch
use azure_data_cosmos::models::{PatchInstructions, PatchOperation};

let patch = PatchInstructions::from(vec![
    PatchOperation::set("/value", serde_json::json!("newValue")),
]);
let patched: Item = container.patch_item("partition1", "1", patch, None)
    .await?.into_model()?;

Delete Item

container.delete_item("partition1", "1", None).await?;

The reviewed current API uses an async builder/container initialization and a separate explicit item ID. Preview PATCH is not a production-ready guarantee; review its selected strategy, conflict/retry behavior and request-unit cost. Official crate reference.

Key Auth (Optional)

Enable key-based authentication with feature flag:

cargo add azure_data_cosmos@=0.37.1 --features key_auth

Best Practices

  1. Always specify partition key — required for point reads and writes
  2. Use into_model()? — to deserialize responses into your types
  3. Derive Serialize and Deserialize — for all document types
  4. Use Entra ID auth — prefer DeveloperToolsCredential over key auth
  5. Reuse client instances — clients are thread-safe and reusable

The reviewed example set uses azure_data_cosmos 0.37.1 and compatible Azure core/credential crates. Record and commit Cargo.lock; source/API review is not a compiler or live-service test.

Reference Links

Resource Link
API Reference https://docs.rs/azure_data_cosmos
Source Code https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/cosmos/azure_data_cosmos
crates.io https://crates.io/crates/azure_data_cosmos

When to Use

Use when a Rust application needs Cosmos DB NoSQL item CRUD, partition-key point reads, container access or explicitly opted-in preview patching.

Limitations

…

자주 묻는 질문

Cosmos DB의 ‘컨테이너’는 무엇인가요?

전통적인 데이터베이스의 표와 비슷하다고 생각하면 됩니다. 항목(데이터 행)을 저장하는 곳입니다.

‘CRUD’는 무엇을 뜻하나요?

Create(생성), Read(읽기), Update(수정), Delete(삭제)의 약자로, 기본적인 데이터 조작 작업입니다.

이걸 쓰려면 데이터베이스를 많이 알아야 하나요?

데이터베이스가 어떻게 작동하는지 기본적으로 알고 있으면 도움이 되지만, 이 라이브러리가 복잡한 상호작용의 많은 부분을 단순하게 해 줍니다.

상세 정보

작성자의 원본 설명

Azure Cosmos DB SDK for Rust (NoSQL API). Use for document CRUD, queries, containers, and globally distributed data.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#3919
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬