feat: Add Official Microsoft & Gemini Skills (845+ Total)
🚀 Impact Significantly expands the capabilities of **Antigravity Awesome Skills** by integrating official skill collections from **Microsoft** and **Google Gemini**. This update increases the total skill count to **845+**, making the library even more comprehensive for AI coding assistants. ✨ Key Changes 1. New Official Skills - **Microsoft Skills**: Added a massive collection of official skills from [microsoft/skills](https://github.com/microsoft/skills). - Includes Azure, .NET, Python, TypeScript, and Semantic Kernel skills. - Preserves the original directory structure under `skills/official/microsoft/`. - Includes plugin skills from the `.github/plugins` directory. - **Gemini Skills**: Added official Gemini API development skills under `skills/gemini-api-dev/`. 2. New Scripts & Tooling - **`scripts/sync_microsoft_skills.py`**: A robust synchronization script that: - Clones the official Microsoft repository. - Preserves the original directory heirarchy. - Handles symlinks and plugin locations. - Generates attribution metadata. - **`scripts/tests/inspect_microsoft_repo.py`**: Debug tool to inspect the remote repository structure. - **`scripts/tests/test_comprehensive_coverage.py`**: Verification script to ensure 100% of skills are captured during sync. 3. Core Improvements - **`scripts/generate_index.py`**: Enhanced frontmatter parsing to safely handle unquoted values containing `@` symbols and commas (fixing issues with some Microsoft skill descriptions). - **`package.json`**: Added `sync:microsoft` and `sync:all-official` scripts for easy maintenance. 4. Documentation - Updated `README.md` to reflect the new skill counts (845+) and added Microsoft/Gemini to the provider list. - Updated `CATALOG.md` and `skills_index.json` with the new skills. 🧪 Verification - Ran `scripts/tests/test_comprehensive_coverage.py` to verify all Microsoft skills are detected. - Validated `generate_index.py` fixes by successfully indexing the new skills.
This commit is contained in:
135
skills/official/microsoft/rust/data/azure-cosmos-rust/SKILL.md
Normal file
135
skills/official/microsoft/rust/data/azure-cosmos-rust/SKILL.md
Normal file
@@ -0,0 +1,135 @@
|
||||
---
|
||||
name: azure-cosmos-rust
|
||||
description: |
|
||||
Azure Cosmos DB SDK for Rust (NoSQL API). Use for document CRUD, queries, containers, and globally distributed data.
|
||||
Triggers: "cosmos db rust", "CosmosClient rust", "container", "document rust", "NoSQL rust", "partition key".
|
||||
package: azure_data_cosmos
|
||||
---
|
||||
|
||||
# Azure Cosmos DB SDK for Rust
|
||||
|
||||
Client library for Azure Cosmos DB NoSQL API — globally distributed, multi-model database.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
cargo add azure_data_cosmos azure_identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
COSMOS_ENDPOINT=https://<account>.documents.azure.com:443/
|
||||
COSMOS_DATABASE=mydb
|
||||
COSMOS_CONTAINER=mycontainer
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```rust
|
||||
use azure_identity::DeveloperToolsCredential;
|
||||
use azure_data_cosmos::CosmosClient;
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let client = CosmosClient::new(
|
||||
"https://<account>.documents.azure.com:443/",
|
||||
credential.clone(),
|
||||
None,
|
||||
)?;
|
||||
```
|
||||
|
||||
## 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
|
||||
|
||||
```rust
|
||||
let database = client.database_client("myDatabase");
|
||||
let container = database.container_client("myContainer");
|
||||
```
|
||||
|
||||
### Create Item
|
||||
|
||||
```rust
|
||||
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", item, None).await?;
|
||||
```
|
||||
|
||||
### Read Item
|
||||
|
||||
```rust
|
||||
let response = container.read_item("partition1", "1", None).await?;
|
||||
let item: Item = response.into_model()?;
|
||||
```
|
||||
|
||||
### Replace Item
|
||||
|
||||
```rust
|
||||
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
|
||||
|
||||
```rust
|
||||
use azure_data_cosmos::models::PatchDocument;
|
||||
|
||||
let patch = PatchDocument::default()
|
||||
.with_add("/newField", "newValue")?
|
||||
.with_remove("/oldField")?;
|
||||
|
||||
container.patch_item("partition1", "1", patch, None).await?;
|
||||
```
|
||||
|
||||
### Delete Item
|
||||
|
||||
```rust
|
||||
container.delete_item("partition1", "1", None).await?;
|
||||
```
|
||||
|
||||
## Key Auth (Optional)
|
||||
|
||||
Enable key-based authentication with feature flag:
|
||||
|
||||
```sh
|
||||
cargo add azure_data_cosmos --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
|
||||
|
||||
## 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 |
|
||||
@@ -0,0 +1,132 @@
|
||||
---
|
||||
name: azure-storage-blob-rust
|
||||
description: |
|
||||
Azure Blob Storage SDK for Rust. Use for uploading, downloading, and managing blobs and containers.
|
||||
Triggers: "blob storage rust", "BlobClient rust", "upload blob rust", "download blob rust", "container rust".
|
||||
package: azure_storage_blob
|
||||
---
|
||||
|
||||
# Azure Blob Storage SDK for Rust
|
||||
|
||||
Client library for Azure Blob Storage — Microsoft's object storage solution for the cloud.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
cargo add azure_storage_blob azure_identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
AZURE_STORAGE_ACCOUNT_NAME=<storage-account-name>
|
||||
# Endpoint: https://<account>.blob.core.windows.net/
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```rust
|
||||
use azure_identity::DeveloperToolsCredential;
|
||||
use azure_storage_blob::{BlobClient, BlobClientOptions};
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let blob_client = BlobClient::new(
|
||||
"https://<account>.blob.core.windows.net/",
|
||||
"container-name",
|
||||
"blob-name",
|
||||
Some(credential),
|
||||
Some(BlobClientOptions::default()),
|
||||
)?;
|
||||
```
|
||||
|
||||
## Client Types
|
||||
|
||||
| Client | Purpose |
|
||||
|--------|---------|
|
||||
| `BlobServiceClient` | Account-level operations, list containers |
|
||||
| `BlobContainerClient` | Container operations, list blobs |
|
||||
| `BlobClient` | Individual blob operations |
|
||||
|
||||
## Core Operations
|
||||
|
||||
### Upload Blob
|
||||
|
||||
```rust
|
||||
use azure_core::http::RequestContent;
|
||||
|
||||
let data = b"hello world";
|
||||
blob_client
|
||||
.upload(
|
||||
RequestContent::from(data.to_vec()),
|
||||
false, // overwrite
|
||||
u64::try_from(data.len())?,
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
### Download Blob
|
||||
|
||||
```rust
|
||||
let response = blob_client.download(None).await?;
|
||||
let content = response.into_body().collect_bytes().await?;
|
||||
println!("Content: {:?}", content);
|
||||
```
|
||||
|
||||
### Get Blob Properties
|
||||
|
||||
```rust
|
||||
let properties = blob_client.get_properties(None).await?;
|
||||
println!("Content-Length: {:?}", properties.content_length);
|
||||
```
|
||||
|
||||
### Delete Blob
|
||||
|
||||
```rust
|
||||
blob_client.delete(None).await?;
|
||||
```
|
||||
|
||||
## Container Operations
|
||||
|
||||
```rust
|
||||
use azure_storage_blob::BlobContainerClient;
|
||||
|
||||
let container_client = BlobContainerClient::new(
|
||||
"https://<account>.blob.core.windows.net/",
|
||||
"container-name",
|
||||
Some(credential),
|
||||
None,
|
||||
)?;
|
||||
|
||||
// Create container
|
||||
container_client.create(None).await?;
|
||||
|
||||
// List blobs
|
||||
let mut pager = container_client.list_blobs(None)?;
|
||||
while let Some(blob) = pager.try_next().await? {
|
||||
println!("Blob: {}", blob.name);
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use Entra ID auth** — `DeveloperToolsCredential` for dev, `ManagedIdentityCredential` for production
|
||||
2. **Specify content length** — required for uploads
|
||||
3. **Use `RequestContent::from()`** — to wrap upload data
|
||||
4. **Handle async operations** — use `tokio` runtime
|
||||
5. **Check RBAC permissions** — ensure "Storage Blob Data Contributor" role
|
||||
|
||||
## RBAC Permissions
|
||||
|
||||
For Entra ID auth, assign one of these roles:
|
||||
- `Storage Blob Data Reader` — read-only
|
||||
- `Storage Blob Data Contributor` — read/write
|
||||
- `Storage Blob Data Owner` — full access including RBAC
|
||||
|
||||
## Reference Links
|
||||
|
||||
| Resource | Link |
|
||||
|----------|------|
|
||||
| API Reference | https://docs.rs/azure_storage_blob |
|
||||
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/storage/azure_storage_blob |
|
||||
| crates.io | https://crates.io/crates/azure_storage_blob |
|
||||
@@ -0,0 +1,115 @@
|
||||
---
|
||||
name: azure-identity-rust
|
||||
description: |
|
||||
Azure Identity SDK for Rust authentication. Use for DeveloperToolsCredential, ManagedIdentityCredential, ClientSecretCredential, and token-based authentication.
|
||||
Triggers: "azure-identity", "DeveloperToolsCredential", "authentication rust", "managed identity rust", "credential rust".
|
||||
package: azure_identity
|
||||
---
|
||||
|
||||
# Azure Identity SDK for Rust
|
||||
|
||||
Authentication library for Azure SDK clients using Microsoft Entra ID (formerly Azure AD).
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
cargo add azure_identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
# Service Principal (for production/CI)
|
||||
AZURE_TENANT_ID=<your-tenant-id>
|
||||
AZURE_CLIENT_ID=<your-client-id>
|
||||
AZURE_CLIENT_SECRET=<your-client-secret>
|
||||
|
||||
# User-assigned Managed Identity (optional)
|
||||
AZURE_CLIENT_ID=<managed-identity-client-id>
|
||||
```
|
||||
|
||||
## DeveloperToolsCredential
|
||||
|
||||
The recommended credential for local development. Tries developer tools in order (Azure CLI, Azure Developer CLI):
|
||||
|
||||
```rust
|
||||
use azure_identity::DeveloperToolsCredential;
|
||||
use azure_security_keyvault_secrets::SecretClient;
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let client = SecretClient::new(
|
||||
"https://my-vault.vault.azure.net/",
|
||||
credential.clone(),
|
||||
None,
|
||||
)?;
|
||||
```
|
||||
|
||||
### Credential Chain Order
|
||||
|
||||
| Order | Credential | Environment |
|
||||
|-------|-----------|-------------|
|
||||
| 1 | AzureCliCredential | `az login` |
|
||||
| 2 | AzureDeveloperCliCredential | `azd auth login` |
|
||||
|
||||
## Credential Types
|
||||
|
||||
| Credential | Usage |
|
||||
|------------|-------|
|
||||
| `DeveloperToolsCredential` | Local development - tries CLI tools |
|
||||
| `ManagedIdentityCredential` | Azure VMs, App Service, Functions, AKS |
|
||||
| `WorkloadIdentityCredential` | Kubernetes workload identity |
|
||||
| `ClientSecretCredential` | Service principal with secret |
|
||||
| `ClientCertificateCredential` | Service principal with certificate |
|
||||
| `AzureCliCredential` | Direct Azure CLI auth |
|
||||
| `AzureDeveloperCliCredential` | Direct azd CLI auth |
|
||||
| `AzurePipelinesCredential` | Azure Pipelines service connection |
|
||||
| `ClientAssertionCredential` | Custom assertions (federated identity) |
|
||||
|
||||
## ManagedIdentityCredential
|
||||
|
||||
For Azure-hosted resources:
|
||||
|
||||
```rust
|
||||
use azure_identity::ManagedIdentityCredential;
|
||||
|
||||
// System-assigned managed identity
|
||||
let credential = ManagedIdentityCredential::new(None)?;
|
||||
|
||||
// User-assigned managed identity
|
||||
let options = ManagedIdentityCredentialOptions {
|
||||
client_id: Some("<user-assigned-mi-client-id>".into()),
|
||||
..Default::default()
|
||||
};
|
||||
let credential = ManagedIdentityCredential::new(Some(options))?;
|
||||
```
|
||||
|
||||
## ClientSecretCredential
|
||||
|
||||
For service principal with secret:
|
||||
|
||||
```rust
|
||||
use azure_identity::ClientSecretCredential;
|
||||
|
||||
let credential = ClientSecretCredential::new(
|
||||
"<tenant-id>".into(),
|
||||
"<client-id>".into(),
|
||||
"<client-secret>".into(),
|
||||
None,
|
||||
)?;
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use `DeveloperToolsCredential` for local dev** — automatically picks up Azure CLI
|
||||
2. **Use `ManagedIdentityCredential` in production** — no secrets to manage
|
||||
3. **Clone credentials** — credentials are `Arc`-wrapped and cheap to clone
|
||||
4. **Reuse credential instances** — same credential can be used with multiple clients
|
||||
5. **Use `tokio` feature** — `cargo add azure_identity --features tokio`
|
||||
|
||||
## Reference Links
|
||||
|
||||
| Resource | Link |
|
||||
|----------|------|
|
||||
| API Reference | https://docs.rs/azure_identity |
|
||||
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/identity/azure_identity |
|
||||
| crates.io | https://crates.io/crates/azure_identity |
|
||||
@@ -0,0 +1,177 @@
|
||||
---
|
||||
name: azure-keyvault-certificates-rust
|
||||
description: |
|
||||
Azure Key Vault Certificates SDK for Rust. Use for creating, importing, and managing certificates.
|
||||
Triggers: "keyvault certificates rust", "CertificateClient rust", "create certificate rust", "import certificate rust".
|
||||
package: azure_security_keyvault_certificates
|
||||
---
|
||||
|
||||
# Azure Key Vault Certificates SDK for Rust
|
||||
|
||||
Client library for Azure Key Vault Certificates — secure storage and management of certificates.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
cargo add azure_security_keyvault_certificates azure_identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
AZURE_KEYVAULT_URL=https://<vault-name>.vault.azure.net/
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```rust
|
||||
use azure_identity::DeveloperToolsCredential;
|
||||
use azure_security_keyvault_certificates::CertificateClient;
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let client = CertificateClient::new(
|
||||
"https://<vault-name>.vault.azure.net/",
|
||||
credential.clone(),
|
||||
None,
|
||||
)?;
|
||||
```
|
||||
|
||||
## Core Operations
|
||||
|
||||
### Get Certificate
|
||||
|
||||
```rust
|
||||
use azure_core::base64;
|
||||
|
||||
let certificate = client
|
||||
.get_certificate("certificate-name", None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
|
||||
println!(
|
||||
"Thumbprint: {:?}",
|
||||
certificate.x509_thumbprint.map(base64::encode_url_safe)
|
||||
);
|
||||
```
|
||||
|
||||
### Create Certificate
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_certificates::models::{
|
||||
CreateCertificateParameters, CertificatePolicy,
|
||||
IssuerParameters, X509CertificateProperties,
|
||||
};
|
||||
|
||||
let policy = CertificatePolicy {
|
||||
issuer_parameters: Some(IssuerParameters {
|
||||
name: Some("Self".into()),
|
||||
..Default::default()
|
||||
}),
|
||||
x509_certificate_properties: Some(X509CertificateProperties {
|
||||
subject: Some("CN=example.com".into()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let params = CreateCertificateParameters {
|
||||
certificate_policy: Some(policy),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let operation = client
|
||||
.create_certificate("cert-name", params.try_into()?, None)
|
||||
.await?;
|
||||
```
|
||||
|
||||
### Import Certificate
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_certificates::models::ImportCertificateParameters;
|
||||
|
||||
let params = ImportCertificateParameters {
|
||||
base64_encoded_certificate: Some(base64_cert_data),
|
||||
password: Some("optional-password".into()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let certificate = client
|
||||
.import_certificate("cert-name", params.try_into()?, None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
```
|
||||
|
||||
### Delete Certificate
|
||||
|
||||
```rust
|
||||
client.delete_certificate("certificate-name", None).await?;
|
||||
```
|
||||
|
||||
### List Certificates
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_certificates::ResourceExt;
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut pager = client.list_certificate_properties(None)?.into_stream();
|
||||
while let Some(cert) = pager.try_next().await? {
|
||||
let name = cert.resource_id()?.name;
|
||||
println!("Certificate: {}", name);
|
||||
}
|
||||
```
|
||||
|
||||
### Get Certificate Policy
|
||||
|
||||
```rust
|
||||
let policy = client
|
||||
.get_certificate_policy("certificate-name", None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
```
|
||||
|
||||
### Update Certificate Policy
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_certificates::models::UpdateCertificatePolicyParameters;
|
||||
|
||||
let params = UpdateCertificatePolicyParameters {
|
||||
// Update policy properties
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
client
|
||||
.update_certificate_policy("cert-name", params.try_into()?, None)
|
||||
.await?;
|
||||
```
|
||||
|
||||
## Certificate Lifecycle
|
||||
|
||||
1. **Create** — generates new certificate with policy
|
||||
2. **Import** — import existing PFX/PEM certificate
|
||||
3. **Get** — retrieve certificate (public key only)
|
||||
4. **Update** — modify certificate properties
|
||||
5. **Delete** — soft delete (recoverable)
|
||||
6. **Purge** — permanent deletion
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use Entra ID auth** — `DeveloperToolsCredential` for dev
|
||||
2. **Use managed certificates** — auto-renewal with supported issuers
|
||||
3. **Set proper validity period** — balance security and maintenance
|
||||
4. **Use certificate policies** — define renewal and key properties
|
||||
5. **Monitor expiration** — set up alerts for expiring certificates
|
||||
6. **Enable soft delete** — required for production vaults
|
||||
|
||||
## RBAC Permissions
|
||||
|
||||
Assign these Key Vault roles:
|
||||
- `Key Vault Certificates Officer` — full CRUD on certificates
|
||||
- `Key Vault Reader` — read certificate metadata
|
||||
|
||||
## Reference Links
|
||||
|
||||
| Resource | Link |
|
||||
|----------|------|
|
||||
| API Reference | https://docs.rs/azure_security_keyvault_certificates |
|
||||
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/keyvault/azure_security_keyvault_certificates |
|
||||
| crates.io | https://crates.io/crates/azure_security_keyvault_certificates |
|
||||
@@ -0,0 +1,167 @@
|
||||
---
|
||||
name: azure-keyvault-keys-rust
|
||||
description: |
|
||||
Azure Key Vault Keys SDK for Rust. Use for creating, managing, and using cryptographic keys.
|
||||
Triggers: "keyvault keys rust", "KeyClient rust", "create key rust", "encrypt rust", "sign rust".
|
||||
package: azure_security_keyvault_keys
|
||||
---
|
||||
|
||||
# Azure Key Vault Keys SDK for Rust
|
||||
|
||||
Client library for Azure Key Vault Keys — secure storage and management of cryptographic keys.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
cargo add azure_security_keyvault_keys azure_identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
AZURE_KEYVAULT_URL=https://<vault-name>.vault.azure.net/
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```rust
|
||||
use azure_identity::DeveloperToolsCredential;
|
||||
use azure_security_keyvault_keys::KeyClient;
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let client = KeyClient::new(
|
||||
"https://<vault-name>.vault.azure.net/",
|
||||
credential.clone(),
|
||||
None,
|
||||
)?;
|
||||
```
|
||||
|
||||
## Key Types
|
||||
|
||||
| Type | Description |
|
||||
|------|-------------|
|
||||
| RSA | RSA keys (2048, 3072, 4096 bits) |
|
||||
| EC | Elliptic curve keys (P-256, P-384, P-521) |
|
||||
| RSA-HSM | HSM-protected RSA keys |
|
||||
| EC-HSM | HSM-protected EC keys |
|
||||
|
||||
## Core Operations
|
||||
|
||||
### Get Key
|
||||
|
||||
```rust
|
||||
let key = client
|
||||
.get_key("key-name", None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
|
||||
println!("Key ID: {:?}", key.key.as_ref().map(|k| &k.kid));
|
||||
```
|
||||
|
||||
### Create Key
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_keys::models::{CreateKeyParameters, KeyType};
|
||||
|
||||
let params = CreateKeyParameters {
|
||||
kty: KeyType::Rsa,
|
||||
key_size: Some(2048),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let key = client
|
||||
.create_key("key-name", params.try_into()?, None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
```
|
||||
|
||||
### Create EC Key
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_keys::models::{CreateKeyParameters, KeyType, CurveName};
|
||||
|
||||
let params = CreateKeyParameters {
|
||||
kty: KeyType::Ec,
|
||||
curve: Some(CurveName::P256),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let key = client
|
||||
.create_key("ec-key", params.try_into()?, None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
```
|
||||
|
||||
### Delete Key
|
||||
|
||||
```rust
|
||||
client.delete_key("key-name", None).await?;
|
||||
```
|
||||
|
||||
### List Keys
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_keys::ResourceExt;
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut pager = client.list_key_properties(None)?.into_stream();
|
||||
while let Some(key) = pager.try_next().await? {
|
||||
let name = key.resource_id()?.name;
|
||||
println!("Key: {}", name);
|
||||
}
|
||||
```
|
||||
|
||||
### Backup Key
|
||||
|
||||
```rust
|
||||
let backup = client.backup_key("key-name", None).await?;
|
||||
// Store backup.value safely
|
||||
```
|
||||
|
||||
### Restore Key
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_keys::models::RestoreKeyParameters;
|
||||
|
||||
let params = RestoreKeyParameters {
|
||||
key_bundle_backup: backup_bytes,
|
||||
};
|
||||
|
||||
client.restore_key(params.try_into()?, None).await?;
|
||||
```
|
||||
|
||||
## Cryptographic Operations
|
||||
|
||||
Key Vault can perform crypto operations without exposing the private key:
|
||||
|
||||
```rust
|
||||
// For cryptographic operations, use the key's operations
|
||||
// Available operations depend on key type and permissions:
|
||||
// - encrypt/decrypt (RSA)
|
||||
// - sign/verify (RSA, EC)
|
||||
// - wrapKey/unwrapKey (RSA)
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use Entra ID auth** — `DeveloperToolsCredential` for dev, `ManagedIdentityCredential` for production
|
||||
2. **Use HSM keys for sensitive workloads** — hardware-protected keys
|
||||
3. **Use EC for signing** — more efficient than RSA
|
||||
4. **Use RSA for encryption** — when encrypting data
|
||||
5. **Backup keys** — for disaster recovery
|
||||
6. **Enable soft delete** — required for production vaults
|
||||
7. **Use key rotation** — create new versions periodically
|
||||
|
||||
## RBAC Permissions
|
||||
|
||||
Assign these Key Vault roles:
|
||||
- `Key Vault Crypto User` — use keys for crypto operations
|
||||
- `Key Vault Crypto Officer` — full CRUD on keys
|
||||
|
||||
## Reference Links
|
||||
|
||||
| Resource | Link |
|
||||
|----------|------|
|
||||
| API Reference | https://docs.rs/azure_security_keyvault_keys |
|
||||
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/keyvault/azure_security_keyvault_keys |
|
||||
| crates.io | https://crates.io/crates/azure_security_keyvault_keys |
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
name: azure-keyvault-secrets-rust
|
||||
description: |
|
||||
Azure Key Vault Secrets SDK for Rust. Use for storing and retrieving secrets, passwords, and API keys.
|
||||
Triggers: "keyvault secrets rust", "SecretClient rust", "get secret rust", "set secret rust".
|
||||
package: azure_security_keyvault_secrets
|
||||
---
|
||||
|
||||
# Azure Key Vault Secrets SDK for Rust
|
||||
|
||||
Client library for Azure Key Vault Secrets — secure storage for passwords, API keys, and other secrets.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
cargo add azure_security_keyvault_secrets azure_identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
AZURE_KEYVAULT_URL=https://<vault-name>.vault.azure.net/
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```rust
|
||||
use azure_identity::DeveloperToolsCredential;
|
||||
use azure_security_keyvault_secrets::SecretClient;
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let client = SecretClient::new(
|
||||
"https://<vault-name>.vault.azure.net/",
|
||||
credential.clone(),
|
||||
None,
|
||||
)?;
|
||||
```
|
||||
|
||||
## Core Operations
|
||||
|
||||
### Get Secret
|
||||
|
||||
```rust
|
||||
let secret = client
|
||||
.get_secret("secret-name", None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
|
||||
println!("Secret value: {:?}", secret.value);
|
||||
```
|
||||
|
||||
### Set Secret
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_secrets::models::SetSecretParameters;
|
||||
|
||||
let params = SetSecretParameters {
|
||||
value: Some("secret-value".into()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let secret = client
|
||||
.set_secret("secret-name", params.try_into()?, None)
|
||||
.await?
|
||||
.into_model()?;
|
||||
```
|
||||
|
||||
### Update Secret Properties
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_secrets::models::UpdateSecretPropertiesParameters;
|
||||
use std::collections::HashMap;
|
||||
|
||||
let params = UpdateSecretPropertiesParameters {
|
||||
content_type: Some("text/plain".into()),
|
||||
tags: Some(HashMap::from([("env".into(), "prod".into())])),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
client
|
||||
.update_secret_properties("secret-name", params.try_into()?, None)
|
||||
.await?;
|
||||
```
|
||||
|
||||
### Delete Secret
|
||||
|
||||
```rust
|
||||
client.delete_secret("secret-name", None).await?;
|
||||
```
|
||||
|
||||
### List Secrets
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_secrets::ResourceExt;
|
||||
use futures::TryStreamExt;
|
||||
|
||||
let mut pager = client.list_secret_properties(None)?.into_stream();
|
||||
while let Some(secret) = pager.try_next().await? {
|
||||
let name = secret.resource_id()?.name;
|
||||
println!("Secret: {}", name);
|
||||
}
|
||||
```
|
||||
|
||||
### Get Specific Version
|
||||
|
||||
```rust
|
||||
use azure_security_keyvault_secrets::models::SecretClientGetSecretOptions;
|
||||
|
||||
let options = SecretClientGetSecretOptions {
|
||||
secret_version: Some("version-id".into()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let secret = client
|
||||
.get_secret("secret-name", Some(options))
|
||||
.await?
|
||||
.into_model()?;
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use Entra ID auth** — `DeveloperToolsCredential` for dev, `ManagedIdentityCredential` for production
|
||||
2. **Use `into_model()?`** — to deserialize responses
|
||||
3. **Use `ResourceExt` trait** — for extracting names from IDs
|
||||
4. **Handle soft delete** — deleted secrets can be recovered within retention period
|
||||
5. **Set content type** — helps identify secret format
|
||||
6. **Use tags** — for organizing and filtering secrets
|
||||
7. **Version secrets** — new values create new versions automatically
|
||||
|
||||
## RBAC Permissions
|
||||
|
||||
Assign these Key Vault roles:
|
||||
- `Key Vault Secrets User` — get and list
|
||||
- `Key Vault Secrets Officer` — full CRUD
|
||||
|
||||
## Reference Links
|
||||
|
||||
| Resource | Link |
|
||||
|----------|------|
|
||||
| API Reference | https://docs.rs/azure_security_keyvault_secrets |
|
||||
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/keyvault/azure_security_keyvault_secrets |
|
||||
| crates.io | https://crates.io/crates/azure_security_keyvault_secrets |
|
||||
@@ -0,0 +1,127 @@
|
||||
---
|
||||
name: azure-eventhub-rust
|
||||
description: |
|
||||
Azure Event Hubs SDK for Rust. Use for sending and receiving events, streaming data ingestion.
|
||||
Triggers: "event hubs rust", "ProducerClient rust", "ConsumerClient rust", "send event rust", "streaming rust".
|
||||
package: azure_messaging_eventhubs
|
||||
---
|
||||
|
||||
# Azure Event Hubs SDK for Rust
|
||||
|
||||
Client library for Azure Event Hubs — big data streaming platform and event ingestion service.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
cargo add azure_messaging_eventhubs azure_identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
EVENTHUBS_HOST=<namespace>.servicebus.windows.net
|
||||
EVENTHUB_NAME=<eventhub-name>
|
||||
```
|
||||
|
||||
## Key Concepts
|
||||
|
||||
- **Namespace** — container for Event Hubs
|
||||
- **Event Hub** — stream of events partitioned for parallel processing
|
||||
- **Partition** — ordered sequence of events
|
||||
- **Producer** — sends events to Event Hub
|
||||
- **Consumer** — receives events from partitions
|
||||
|
||||
## Producer Client
|
||||
|
||||
### Create Producer
|
||||
|
||||
```rust
|
||||
use azure_identity::DeveloperToolsCredential;
|
||||
use azure_messaging_eventhubs::ProducerClient;
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let producer = ProducerClient::builder()
|
||||
.open("<namespace>.servicebus.windows.net", "eventhub-name", credential.clone())
|
||||
.await?;
|
||||
```
|
||||
|
||||
### Send Single Event
|
||||
|
||||
```rust
|
||||
producer.send_event(vec![1, 2, 3, 4], None).await?;
|
||||
```
|
||||
|
||||
### Send Batch
|
||||
|
||||
```rust
|
||||
let batch = producer.create_batch(None).await?;
|
||||
batch.try_add_event_data(b"event 1".to_vec(), None)?;
|
||||
batch.try_add_event_data(b"event 2".to_vec(), None)?;
|
||||
|
||||
producer.send_batch(batch, None).await?;
|
||||
```
|
||||
|
||||
## Consumer Client
|
||||
|
||||
### Create Consumer
|
||||
|
||||
```rust
|
||||
use azure_messaging_eventhubs::ConsumerClient;
|
||||
|
||||
let credential = DeveloperToolsCredential::new(None)?;
|
||||
let consumer = ConsumerClient::builder()
|
||||
.open("<namespace>.servicebus.windows.net", "eventhub-name", credential.clone())
|
||||
.await?;
|
||||
```
|
||||
|
||||
### Receive Events
|
||||
|
||||
```rust
|
||||
// Open receiver for specific partition
|
||||
let receiver = consumer.open_partition_receiver("0", None).await?;
|
||||
|
||||
// Receive events
|
||||
let events = receiver.receive_events(100, None).await?;
|
||||
for event in events {
|
||||
println!("Event data: {:?}", event.body());
|
||||
}
|
||||
```
|
||||
|
||||
### Get Event Hub Properties
|
||||
|
||||
```rust
|
||||
let properties = consumer.get_eventhub_properties(None).await?;
|
||||
println!("Partitions: {:?}", properties.partition_ids);
|
||||
```
|
||||
|
||||
### Get Partition Properties
|
||||
|
||||
```rust
|
||||
let partition_props = consumer.get_partition_properties("0", None).await?;
|
||||
println!("Last sequence number: {}", partition_props.last_enqueued_sequence_number);
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Reuse clients** — create once, send many events
|
||||
2. **Use batches** — more efficient than individual sends
|
||||
3. **Check batch capacity** — `try_add_event_data` returns false when full
|
||||
4. **Process partitions in parallel** — each partition can be consumed independently
|
||||
5. **Use consumer groups** — isolate different consuming applications
|
||||
6. **Handle checkpointing** — use `azure_messaging_eventhubs_checkpointstore_blob` for distributed consumers
|
||||
|
||||
## Checkpoint Store (Optional)
|
||||
|
||||
For distributed consumers with checkpointing:
|
||||
|
||||
```sh
|
||||
cargo add azure_messaging_eventhubs_checkpointstore_blob
|
||||
```
|
||||
|
||||
## Reference Links
|
||||
|
||||
| Resource | Link |
|
||||
|----------|------|
|
||||
| API Reference | https://docs.rs/azure_messaging_eventhubs |
|
||||
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/eventhubs/azure_messaging_eventhubs |
|
||||
| crates.io | https://crates.io/crates/azure_messaging_eventhubs |
|
||||
Reference in New Issue
Block a user