This document provides guidance for AI agents (e.g., GitHub Copilot, MCP servers, or LLM-based assistants) interacting with the Azure SDK for Rust repository.
The Azure SDK for Rust provides Rust language bindings and client libraries for Azure services, following the Azure SDK Design Guidelines for Rust.
Rust (MSRV: 1.85)
- Rust toolchain with Cargo
- TypeSpec for API specification and code generation
- OpenTelemetry for distributed tracing
- Test Proxy for recorded integration tests
.
├── sdk/ # Service-specific crates organized by service
│ └── <service>/ # Service directory (e.g., "keyvault", "storage")
│ ├── <crate>/ # Service crate (e.g., "azure_security_keyvault_secrets")
│ ├── assets.json # Pointer to test recordings (may be under <crate>/)
│ ├── test-resources.bicep # Test resource definitions (may be under <crate>/)
│ └── tsp-location.yaml # Pointer to TypeSpec in azure-rest-api-specs (may be under <crate>/)
├── eng/ # Engineering system scripts and common tooling
├── doc/ # Additional documentation
├── .github/
│ ├── copilot-instructions.md # Copilot-specific Rust coding guidelines
│ ├── instructions/ # Agent instruction files for specific tasks
│ └── prompts/ # Reusable Copilot prompts
├── CONTRIBUTING.md # Contribution guidelines (see for detailed workflows)
└── README.md # Repository overview
AI agents can assist with:
-
Code Generation
- Writing new Rust code following repository conventions (see
.github/copilot-instructions.md) - Generating unit tests using
#[cfg(test)]modules - Creating integration tests with
#[recorded::test]attributes (seeCONTRIBUTING.mdfor details) - Generating documentation tests in
.rsfiles (avoidno_runwhen tests can be run) - In README markdown files, use
```rust no_runfor examples with placeholders - Running
rustfmton all generated code to ensure proper formatting
- Writing new Rust code following repository conventions (see
-
Code Review Support
- Identifying potential bugs or safety issues
- Suggesting improvements for idiomatic Rust patterns
- Checking adherence to Azure SDK design guidelines
- Reviewing error handling using
azure_core::Result<T>
-
Documentation
- Improving inline documentation (using
///doc comments) - Updating README files
- Creating or updating CHANGELOG entries (see
.github/instructions/changelog.instructions.md) - Writing hero scenario examples in doc comments (avoid examples in
examples/directories unless demonstrating primary use cases)
- Improving inline documentation (using
-
Issue Triage
- Labeling issues with appropriate tags
- Identifying duplicate issues
- Suggesting relevant code owners based on
CODEOWNERS - Summarizing issue discussions
-
Refactoring
- Applying clippy suggestions
- Improving code organization and modularity
- Updating dependencies in
Cargo.toml - Consolidating imports (e.g.,
use std::{borrow::Cow, marker::PhantomData};instead of separate lines)
AI agents should not:
-
Modify Generated Code
- Never edit files in
generated/subdirectories - These are produced by TypeSpec code generators and will be overwritten
- Instead, propose changes to TypeSpec specifications in Azure/azure-rest-api-specs
- Never edit files in
-
Break API Compatibility
- Avoid introducing breaking changes without explicit approval
- Check if changes affect public APIs before proceeding
- Consider deprecation process (see
doc/deprecation-process.md)
-
Bypass CI/CD Checks
- Do not suggest skipping or disabling CI checks
- All code must pass
cargo build,cargo test, andcargo clippy
-
Commit Secrets
- Never include credentials, keys, or tokens in code
- Use environment variables for sensitive data
- Sanitize test recordings to remove secrets
-
Modify Security or License Files
- Do not alter
SECURITY.md,LICENSE.txt, orCODE_OF_CONDUCT.mdwithout maintainer approval
- Do not alter
# Build a specific crate
cargo build -p <crate-name>
# Build entire workspace (not recommended unless necessary)
cargo build --workspaceWhen running cargo test, use --all-features to ensure no tests are missed.
# Run tests for a specific crate
cargo test -p <crate-name> --all-features
# Run integration tests with recordings
cargo test -p <crate-name> --test <test-name>
# Provision test resources (see CONTRIBUTING.md for details)
eng/common/TestResources/New-TestResources.ps1 -ServiceDirectory <service>
# Record new test sessions (requires provisioned resources)
AZURE_TEST_MODE=record cargo test -p <crate-name> --test <test-name>See CONTRIBUTING.md for comprehensive testing guidance including debugging, Test Proxy usage, and trace logging.
# Check for common issues
cargo clippy -p <crate-name>
# Auto-fix some issues
cargo clippy --fix -p <crate-name>
# Format code
cargo fmt -p <crate-name>For crates with TypeSpec specifications:
cd sdk/<service>/<crate-name>
tsp-client updatecargo run --package <crate-name> --example <example-name>Agents must follow comprehensive Rust coding guidelines defined in .github/copilot-instructions.md. Key areas include:
- Naming conventions (PascalCase for types, snake_case for functions, UPPER_SNAKE_CASE for constants)
- Import style (explicit imports, consolidated
usestatements, prefercrate::) - Error handling (use
azure_core::Result<T>and?operator) - Documentation (all public APIs need
///doc comments with examples) - Testing (unit tests in
#[cfg(test)] mod tests, integration tests with#[recorded::test])
See .github/copilot-instructions.md for complete code generation rules.
All pull requests trigger:
cargo build- Compilation checkcargo test- Unit and integration testscargo clippy- Lint checkscargo fmt --check- Format validation- License/CLA verification
- Code coverage analysis
Integration tests use the Azure SDK Test Proxy for recording/playback. See CONTRIBUTING.md for Test Proxy setup and usage.
- Code Review: All changes require review and approval from code owners
- Static Analysis: Must pass
cargo clippywithout warnings - Secret Scanning: Automated checks prevent committing credentials
- Dependencies: Managed through workspace
Cargo.toml, vetted for security - Vulnerability Reporting: Via MSRC at secure@microsoft.com
For detailed guidance, see:
- Rust Coding Standards:
.github/copilot-instructions.md - Contributing Guide:
CONTRIBUTING.md - Testing Guide:
CONTRIBUTING.md(Test Proxy, recorded tests, debugging) - Changelog Updates:
.github/instructions/changelog.instructions.md - Git Commit Standards:
.github/instructions/git-commit.instructions.md - GitHub Pull Request Standards:
.github/instructions/github-pullrequest.instructions.md - PowerShell Scripts:
.github/instructions/pwsh.instructions.md - Deprecation Process:
doc/deprecation-process.md - Azure SDK Design Guidelines: https://azure.github.io/azure-sdk/rust_introduction.html
Additional specialized instructions for specific workflows can be found in:
.github/copilot-instructions.md- Comprehensive Rust coding guidelines.github/instructions/- Task-specific instructions (loaded when pattern-matched).github/prompts/- Reusable Copilot prompts (use#promptin Copilot)
- Issues: https://github.com/Azure/azure-sdk-for-rust/issues
- Discussions: Use issue comments or StackOverflow with
azure+rusttags - Code Owners: See
.github/CODEOWNERSfor service-specific contacts
The SDK includes telemetry via User-Agent headers. Follow Microsoft Privacy Statement: https://go.microsoft.com/fwlink/?LinkID=824704
All contributions are licensed under the MIT License. See LICENSE.txt.
Last Updated: 2026-01-08 Version: 1.0 Canonical Spec: https://agents.md