Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,38 @@ You are an expert Rust programmer. You write safe, efficient, maintainable, and

> **Note**: For comprehensive guidance on how AI agents should interact with this repository, including workflows, automation boundaries, and repository structure, see [AGENTS.md](https://github.com/Azure/azure-sdk-for-rust/blob/main/AGENTS.md).

## Prerequisites
## Build, Test, and Lint

- To use Azure SDK MCP tool calls, the user must have PowerShell installed. Provide [PowerShell installation instructions](https://learn.microsoft.com/powershell/scripting/install/installing-powershell) if not installed, and recommend restarting the IDE to start the MCP server.
```bash
# Build a specific crate
cargo build -p <crate-name>

# Run all tests for a crate
cargo test -p <crate-name>

# Run a single test by name
cargo test -p <crate-name> --test <test-file> <test-name>

# Run clippy lints
cargo clippy -p <crate-name>

# Format code
cargo fmt -p <crate-name>

# Record integration tests (requires provisioned Azure resources)
AZURE_TEST_MODE=record cargo test -p <crate-name> --test <test-file>
```

## Architecture

- **Core crates** (`sdk/core/`): Foundation libraries that all service crates depend on.
- `azure_core`: HTTP pipeline, credentials, error types, `Result<T>` alias.
- `typespec`/`typespec_client_core`: Base types for TypeSpec-generated clients.
- `azure_core_test`: Test utilities including `#[recorded::test]` for integration tests.
- **Service crates** (`sdk/<service>/<crate>/`): Azure service clients (e.g., `azure_security_keyvault_secrets`).
- Most contain a `generated/` subdirectory with TypeSpec-generated code — **never edit these files**.
- Hand-written code in `src/` adds convenience methods or customizations.
- **Identity crate** (`sdk/identity/azure_identity`): Authentication via `DefaultAzureCredential` and related types.
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference to DefaultAzureCredential is incorrect for the Rust SDK. The Rust SDK uses DeveloperToolsCredential as the primary credential for development scenarios, not DefaultAzureCredential. Update this line to reference DeveloperToolsCredential and other available credentials (like ManagedIdentityCredential for production scenarios) to accurately reflect the Rust SDK's identity crate structure.

Suggested change
- **Identity crate** (`sdk/identity/azure_identity`): Authentication via `DefaultAzureCredential` and related types.
- **Identity crate** (`sdk/identity/azure_identity`): Authentication via `DeveloperToolsCredential`, `ManagedIdentityCredential`, and other identity types.

Copilot uses AI. Check for mistakes.

## Code Generation

Expand Down Expand Up @@ -50,3 +79,15 @@ Use these instructions for test generation as well.
- The `tests` module should always import APIs from `super`.
- Do not begin test function names with "test" unless necessary to disambiguate from the function being tested.
- Test functions do not need to be public.

## Integration Tests

- Integration tests go in a crate's `tests/` directory and use `#[recorded::test]` (from `azure_core_test`).
- Recorded tests replay HTTP traffic from recordings in `sdk/<service>/assets/` (referenced via `assets.json`).
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statement about recordings being in sdk/<service>/assets/ is inaccurate. Recordings are stored in an external repository (Azure/azure-sdk-assets) and referenced via the assets.json file. The recordings are not stored in a local assets/ subdirectory. Consider rephrasing to clarify that recordings are managed via assets.json which points to recordings in the azure-sdk-assets repository.

Suggested change
- Recorded tests replay HTTP traffic from recordings in `sdk/<service>/assets/` (referenced via `assets.json`).
- Recorded tests replay HTTP traffic from recordings stored in the external `Azure/azure-sdk-assets` repository, as mapped by the per-service `assets.json` file.

Copilot uses AI. Check for mistakes.
- To record new sessions, set `AZURE_TEST_MODE=record` and provide credentials/config via environment variables.
- Use `#[recorded::test(live)]` for tests that cannot be recorded (non-HTTP or non-automated provisioning).

## Error Handling

- Service crate code returns `azure_core::Result<T>` (defaults to `azure_core::Error`).
- Examples should return `Result<(), Box<dyn std::error::Error>>`.