Estimated time: 10 minutes
Extract your Azure API Management configuration, version it in git, and publish to a target environment — all from the command line.
| Requirement | Details |
|---|---|
| Node.js | v22 or later (download) |
| Azure CLI | Installed and authenticated (az login) |
| Azure subscription | With an existing APIM instance |
| RBAC roles | API Management Service Contributor + Reader on the APIM resource |
npm install -g @azure-tools/apiops-cliVerify the installation:
apiops --versionPull your entire APIM configuration into local files:
apiops extract \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group my-rg \
--service-name my-apim \
--output ./apim-artifactsTip: Set
AZURE_SUBSCRIPTION_IDas an environment variable to omit--subscription-idfrom every command.
This creates a directory tree under ./apim-artifacts with all your APIM resources as JSON and XML files.
ls ./apim-artifactsYou'll see directories for each resource type — apis/, backends/, namedValues/, products/, policies/, and more. Each resource is a separate file, ready for version control.
Extract only the APIs you care about. Create a filter.yaml:
apiNames:
- pet-store-api
- user-api
- 'staging-*' # Wildcard: all APIs starting with staging-apiops extract \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group my-rg \
--service-name my-apim \
--output ./apim-artifacts \
--filter filter.yamlReferenced backends, named values, and policy fragments are included automatically (transitive dependencies). Use --no-transitive to disable this.
Create configuration.prod.yaml for environment-specific values:
namedValues:
- name: backend-url
properties:
value: "https://api.prod.example.com"
backends:
- name: my-backend
properties:
url: "https://api.prod.example.com"Publish to your target APIM instance:
apiops publish \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group prod-rg \
--service-name prod-apim \
--source ./apim-artifacts \
--overrides configuration.prod.yamlSee what would change without modifying the target instance:
apiops publish \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group prod-rg \
--service-name prod-apim \
--source ./apim-artifacts \
--overrides configuration.prod.yaml \
--dry-runDry-run output shows each resource that would be created, updated, or deleted — without making any changes.
Generate pipeline files, sample configs, and directory structure for your repository:
apiops init --ci github-actionsOr for Azure DevOps:
apiops init --ci azure-devopsThis creates:
- CI/CD pipeline definitions
- Sample
filter.yamlandoverrides.{env}.yamlfiles - Artifact directory structure
See apiops init --help for additional options like --environments, --artifact-dir, and --non-interactive.
In your pipeline, the CLI automatically detects COMMIT_ID to publish only changed resources:
# GitHub Actions example
- run: |
apiops publish \
--subscription-id ${{ vars.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ vars.APIM_RG }} \
--service-name ${{ vars.APIM_NAME }} \
--overrides overrides.${{ vars.ENV }}.yaml
env:
COMMIT_ID: ${{ github.sha }}When COMMIT_ID is set, only resources changed since that commit are deployed — faster pipelines, smaller blast radius.
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Partial failure — some resources failed, others succeeded |
2 |
Fatal error — command could not run |
| Topic | Link |
|---|---|
| Extract command reference | commands/extract.md |
| Publish command reference | commands/publish.md |
| Init command reference | commands/init.md |
| Filtering guide | guides/filtering.md |
| Environment overrides | guides/environment-overrides.md |
| Authentication methods | guides/authentication.md |
| GitHub Actions setup | ci-cd/github-actions.md |
| Azure DevOps setup | ci-cd/azure-devops.md |
| Troubleshooting | troubleshooting/common-errors.md |
← Back to Documentation Home