Creating a New Crate
All new service crates must be generated from TypeSpec specifications in Azure/azure-rest-api-specs. Do not hand-write client libraries from scratch.
Install tsp-client
Use the repository-pinned CLI; do not invoke a globally installed binary:
_TspClientDir="$(pwd)/eng/common/tsp-client" npm ci --prefix "$_TspClientDir"Run commands with
npm exec --prefix "$_TspClientDir" --no -- tsp-clientSee
eng/common/tsp-client/README.mdfor prerequisites and more context
Find the TypeSpec spec
- Look for a
tspconfig.yamlunderspecification/{service}/in azure-rest-api-specs - Check the
tspconfig.yamlfor@azure-tools/typespec-rustemitter configuration - If no emitter configuration exists, stop and report an error indicating that the TypeSpec specification in Azure/azure-rest-api-specs must be updated before generating the client
- Look for a
Initialize the crate
- From the repository root, run
npm exec --prefix "$_TspClientDir" --no -- tsp-client init --tsp-config {url} {url}is the GitHub URL to thetspconfig.yaml- Always use a specific commit SHA in the URL — never a branch or tag, which can move
- Example:
https://github.com/Azure/azure-rest-api-specs/blob/{commit-sha}/specification/{service}/{rp}/tspconfig.yaml
- From the repository root, run
Generate the client
- Use the
azsdk_package_generate_codeMCP tool, or - From the crate directory, run
npm exec --prefix "$_TspClientDir" --no -- tsp-client update
- Use the
Add hand-written wrappers
- Create
clients.rs(or similar) for custom client constructors, authentication setup, and convenience methods - Build on top of the generated code in
src/generated/
- Create
Register the crate
- Add the new crate to the workspace
memberslist in the rootCargo.toml
- Add the new crate to the workspace
Add tests, examples, and documentation
- Write unit tests and integration tests (using
#[recorded::test]) - Add examples, a
README.md, and aCHANGELOG.md
- Write unit tests and integration tests (using