Extract Azure API Management configuration to local artifact files.
apiops extract --resource-group <rg> --service-name <name> [options]apiops extract \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group my-rg \
--service-name my-apimapiops extract \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group my-rg \
--service-name my-apim \
--output ./artifactsapiops extract \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group my-rg \
--service-name my-apim \
--filter ./configuration.extractor.yamlapiops extract \
--resource-group my-rg \
--service-name my-apim \
--no-transitiveapiops extract \
--resource-group my-rg \
--service-name my-apim \
--format json| Flag | Type | Default | Required | Description |
|---|---|---|---|---|
--resource-group <rg> |
string | — | Yes | Azure resource group name |
--service-name <name> |
string | — | Yes | APIM service instance name |
--output <dir> |
string | ./apim-artifacts |
No | Output directory path |
--filter <path> |
string | — | No | Filter configuration YAML file |
--no-transitive |
boolean | false (transitive ON) | No | Disable transitive dependency inclusion |
--remove-stale |
boolean | false | No | Remove stale managed artifacts in the selected filter and workspace scope after a fully successful extraction |
| Flag | Type | Default | Description |
|---|---|---|---|
--subscription-id <id> |
string | env: AZURE_SUBSCRIPTION_ID |
Azure subscription ID (required) |
--log-level <level> |
string | info |
Log level: debug, info, warn, error |
--format <type> |
string | text |
Output format: text or json |
--cloud <name> |
string | public |
Sovereign cloud: public, china, usgov, germany |
--client-id <id> |
string | — | Service principal client ID |
--client-secret <secret> |
string | — | Service principal client secret |
--tenant-id <id> |
string | — | Azure AD tenant ID |
apiops extract authenticates using DefaultAzureCredential, which tries credentials in this order:
- Managed Identity
- Workload Identity
- Service Principal (via
--client-id,--client-secret,--tenant-id) - Azure CLI (
az login)
For local development, az login is the simplest option. For CI/CD pipelines, use federated credentials (OIDC) or a service principal. See the authentication guide for details.
By default, apiops extract exports all resources from the APIM instance (34 resource types including APIs, products, backends, named values, tags, policies, and more).
To extract only specific resources, pass a YAML filter file with --filter. Filter entries support exact names, wildcard patterns (* for any characters, ? for a single character), and !-prefixed exclusions (e.g. '!prod-legacy' — see filtering-resources.md for details):
Always quote
!-prefixed entries — unquoted- !prod-legacyis parsed by YAML as a tag and fails to load.
# configuration.extractor.yaml
apis:
- echo-api
- petstore-api
- 'prod-*' # Wildcard: all APIs starting with prod-
- '!prod-legacy-*' # Exclusion: skip legacy prod APIs
products:
- starter
backends:
- backend-api
- '*-internal' # Wildcard: all backends ending with -internal
namedValues:
- api-key
tags:
- production
policyFragments:
- rate-limit-fragment
loggers:
- appinsights-logger
diagnostics:
- applicationinsightsAll 17 supported filter keys:
| Filter key | Resource type |
|---|---|
apis |
APIs (accepts nested object entries — see API sub-filters below) |
backends |
Backends |
products |
Products |
namedValues |
Named values |
loggers |
Loggers |
diagnostics |
Diagnostics |
tags |
Tags |
policyFragments |
Policy fragments |
gateways |
Gateways |
versionSets |
API version sets |
groups |
Groups |
subscriptions |
Subscriptions |
schemas |
Schemas |
policies |
Service-level policy (singleton — use - 'policy' to include, [] to exclude) |
policyRestrictions |
Policy restrictions |
documentations |
Documentation resources |
workspaces |
Workspaces (accepts nested object entries — see Workspace sub-filters below) |
For every key, the value semantics are:
- Key omitted → include all resources of that type (default)
key: []→ include none of that typekey: [name1, name2]→ include only the named resources (exact match, case-insensitive; supports*and?wildcards)
Tip
Each key is independent. Setting only apis: [my-api] still extracts every backend, named value, product, tag, workspace, and other resource type, because those keys are omitted and default to "include all". To extract just one API plus its transitive dependencies, set every other key to []. See How To: Extract Just One API in the filtering guide.
To restrict which child resources of an API are extracted (operations,
diagnostics, schemas, releases), use the nested object entry form under
apis:. Each entry becomes a name: { subKey: [...] } map:
apis:
- 'echo-api' # plain entry — all child resources included
- 'petstore-api': # nested entry — only listed children
operations:
- 'listPets'
- 'getPet'
diagnostics: [] # exclude all diagnostics for this API
schemas:
- 'pet-schema'
releases: []Supported API sub-filter keys: operations, diagnostics, schemas, releases.
Same value semantics as top-level keys (omitted = include all, [] = include none, list = allowlist).
Workspaces accept the same nested object entry form. Each workspace can have its own inner allowlists for the workspace-scoped resource types:
workspaces:
- 'team-a-workspace':
apis:
- 'team-a-orders'
backends: [] # exclude all workspace backends
namedValues:
- 'team-a-secret'Supported workspace sub-filter keys: apis, backends, diagnostics,
groups, loggers, namedValues, policyFragments, products, schemas,
subscriptions, tags, versionSets.
When extracting with a filter, transitive dependencies are included automatically. For example, extracting echo-api also extracts any backends, named values, and policy fragments that echo-api references in its policies.
Use --no-transitive to disable this behavior and extract only the explicitly listed resources.
Extracted artifacts are organized as JSON info files and XML policy files in a directory tree:
apim-artifacts/
├── apis/
│ └── echo-api/
│ ├── apiInformation.json
│ ├── policy.xml
│ └── operations/
│ └── get-resource/
│ ├── operationInformation.json
│ └── policy.xml
├── products/
│ └── starter/
│ ├── productInformation.json
│ └── policy.xml
├── backends/
│ └── backend-api/
│ └── backendInformation.json
├── namedValues/
│ └── api-key/
│ └── namedValueInformation.json
└── ...
When using --format json, structured output is written to stdout with resource counts and file paths. This is useful for scripting and CI/CD pipelines.
| Code | Meaning |
|---|---|
0 |
Success — all resources extracted |
1 |
Partial — some resources failed to extract |
2 |
Fatal — extraction could not proceed |
- apiops publish — publish extracted artifacts to APIM
- apiops init — scaffold a repository with CI/CD pipelines
- Authentication guide
- Filtering resources
- Artifact format reference