page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
Sample code repo for Azure Cosmos DB Rust SDK for NoSQL API |
Sample code repository for Azure Cosmos DB Rust SDK for NoSQL API. By cloning and running these samples, and then studying their implementations, you will have examples for sending various requests to Azure Cosmos DB from the Rust SDK via the NoSQL API.
File/folder | Description |
---|---|
basic-samples |
Basic CRUD operations and container management samples. |
advanced-samples |
More advanced features and usage examples. |
.gitignore |
Defines what to ignore at commit time. |
Cargo.toml |
Cargo configuration file for Rust. |
README.md |
This README file. |
LICENSE |
The license for the sample. |
- Rust (1.56 or newer)
- Setting up an Azure Cosmos DB account through the Azure Portal. The Create a database account section of this guide walks you through account creation.
- The hostname and master key for your Azure Cosmos DB account
- Azure SDK for Rust
azure_identity
crate for authentication
Clone the sample to your PC. You can run the samples using Cargo.
git clone https://github.com/Azure-Samples/azure-cosmos-rust-nosql-api-samples.git
cd azure-cosmos-rust-nosql-api-samples/basic-samples/container-crud
These environment variables must be set in order to give the samples read/write access to your account:
export COSMOSDB_ENDPOINT=your_account_hostname
To authenticate with Azure Cosmos DB, you can use DefaultAzureCredential
from the azure_identity
crate. A simple way to get the sample working is to log in to Azure using the Azure CLI:
az login
This credential type will automatically attempt to authenticate via multiple methods, including environment variables, managed identities, and Azure CLI credentials. Ensure that you have the required authentication setup for your Azure account.
For more details on the azure_identity
crate, refer to the documentation here.
To run a sample, use Cargo:
cd basic-samples/document-crud
cargo run
This will build and run the selected sample.
These samples include:
basic-samples
- container and document crud
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.