Skip to content

Preview SDK Generation

Ryan K edited this page Dec 12, 2025 · 1 revision

Preview SDK Generation

This guide explains how to generate resource provider SDKs locally using the same methods as official azure-sdk-for-python releases.

Important: This is a different procedure than we use to autorest vendored SDKs for inclusion in our extensions - this process is used to create intermediate "release candidate" builds of service SDKs (for CLI core, as an example) before they are officially released.

Prerequisites

1. Clone both repositories

git clone https://github.com/Azure/azure-rest-api-specs

git clone https://github.com/Azure/azure-sdk-for-python

2. Install Python SDK dev tools

The SDK generation requires the azure-sdk-tools package from the Python SDK repo:

cd /path/to/azure-sdk-for-python
pip install eng/tools/azure-sdk-tools

3. Install spec repository dependencies

Run once, or after pulling updates:

cd /path/to/azure-rest-api-specs
npm ci

Generate SDK code

Important:

  • Make sure you check out the azure-rest-api-specs (or azure-rest-api-specs-pr) repo at your desired branch or commit.
  • Ensure that the default tag in readme.md is the correct version of the SDK you wish to generate (both api-version and SDK build version)
  • Verify provided paths are correct based on your local environment
cd /path/to/azure-rest-api-specs

npx spec-gen-sdk
  --scp /path/to/azure-rest-api-specs
  --sdp /path/to/azure-sdk-for-python
  --wf /path/to/
  -l azure-sdk-for-python
  -c HEAD
  --rm release
  --readme-relative-path "specification/<service>/path/to/readme.md"
  --sdk-release-type [beta | stable]

The spec-gen-sdk tool will load specs / config and run autorest, followed by post-processing steps to determine breaking changes etc. Once the autorest step has completed, you can effectively cancel the process and proceed with building a wheel.

Build wheel

  1. Diff generated code:

    cd /path/to/azure-sdk-for-python/
    git status
    git diff

    The generated code will be in:

    • DPS: sdk/iothub/azure-mgmt-iothubprovisioningservices/
    • IoT Hub: sdk/iothub/azure-mgmt-iothub/
  2. Build wheel

    cd sdk/<service>/<package-name>
    python -m build --wheel

    Wheel file will be in ./dist/

Examples for DPS and IoT Hub

DPS:

# Generate SDK
cd ./src
npx spec-gen-sdk
  --scp ./azure-rest-api-specs
  --sdp ./azure-sdk-for-python
  --wf ./
  -l azure-sdk-for-python
  -c HEAD
  --rm release
  --readme-relative-path "./azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/DeviceProvisioningServices/readme.md"
  --sdk-release-type beta

# Build distributable wheel
cd azure-sdk-for-python/sdk/iothub/azure-mgmt-iothubprovisioningservices
python -m build --wheel

# Wheel location:
# ./dist/azure_mgmt_iothubprovisioningservices-*.whl

IoT Hub:

# Generate SDK
cd ./src
npx spec-gen-sdk
  --scp ./azure-rest-api-specs
  --sdp ./azure-sdk-for-python
  --wf ./
  -l azure-sdk-for-python
  -c HEAD
  --rm release
  --readme-relative-path "./azure-rest-api-specs/specification/iothub/resource-manager/Microsoft.Devices/IoTHub/readme.md"
  --sdk-release-type beta

# Build distributable wheel
cd ./azure-sdk-for-python/sdk/iothub/azure-mgmt-iothub
python -m build --wheel

# Wheel location:
# ./dist/azure_mgmt_iothub-*.whl

Clone this wiki locally