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がスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
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
- Always specify partition key — required for point reads and writes
- Use
into_model()?— to deserialize responses into your types - Derive
SerializeandDeserialize— for all document types - Use Entra ID auth — prefer
DeveloperToolsCredentialover key auth - 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」とは何ですか?
CRUDは、Create(作成)、Read(読み取り)、Update(更新)、Delete(削除)の頭文字で、データを扱う基本的な操作のことです。
このツールを使うには、データベースについて詳しい知識が必要ですか?
データベースの基本的な仕組みを理解しておくと役立ちますが、このライブラリが複雑なやり取りの多くを簡単にしてくれます。
詳細
作者による元の説明
Azure Cosmos DB SDK for Rust (NoSQL API). Use for document CRUD, queries, containers, and globally distributed data.
人気
- GitHubのスター
- 48k
- ランキング
- #3919
- ライセンス
- MIT
- 更新日
- 2026/10/15
コメント
- …
このリポジトリの他のスキル
00-andruia-consultant
48kエージェントがAIプロジェクトの立ち上げや改善を支援します。コードを分析し、ツールを提案し、スペイン語で行動計画を作成します。
007
48kエージェントがセキュリティ監査と脅威モデリングを行えるようにします。攻撃や脆弱性からプロジェクトを守るのに役立ちます。
10-andruia-skill-smith
48kエージェントがAIツールの作成や改善を支援します。ツールの動作を定義し、ドキュメントを書き、構造を検証します。
20-andruia-niche-intelligence
48kエージェントが特定の業界に関する要約を作成できるようにします。信頼できる情報源を使って、プロジェクトの背景、ルール、利用パターン、リスクを把握するのに役立ちます。
似ているスキル
discrawl
394k保存済みのローカルなDiscordメッセージのアーカイブを検索して要約し、その新しさを確認し、ダイレクトメッセージを読めるようエージェントを支援します。
clickhouse-io
280kエージェントがClickHouseデータベースのクエリとスキーマを最適化できるようにします。高性能な分析処理向けのベストプラクティスを適用します。分析クエリが遅すぎるときに使います。
scientific-db-pubmed-database
280kエージェントが生物医学分野の科学論文を検索するのに役立ちます。特定の医療情報が必要な研究に便利です。