Repository navigation
Description
Command that triggered the bug
apiops publish
Expected behavior
When migrating from development to test environment I expect same schema to be created on test environment.
Actual behavior
Checking the extracted artifact they look fine. One schema is available in the artifact and has expected format.
After publish the expected schema is created but also an additional one.
I did another extract on test environment to compare the 2 schemas in the produced artifact schemaInformation.json.
They are very similar only difference I could notice in portal was the location of required array in components ->schemas at the beginning of the items object in the additional schema and at the end in expected schema.
"components": {
"schemas": {
"IngestionRequest": {
"minItems": 1,
"type": "array",
"items": {
"required": [
"type",
"objectClass",
"object",
"parameter",
"eventHost"
],
"type": "object",
"properties": {
"type": {
"type": "string"
},
"protocolVersion": {
"type": "integer"
},
Another difference was the "provisioningState": "Succeeded" present in the original schema.
When visualizing the API Json in portal OpenAPI specification editor the "components": {
"schemas": { } }..are missing and I get below message at the end of the json.
"x-ms-export-notes": ["Definitions/body parameters are not exported since this API references multiple schemas with OpenAPI components as opposed to one. Schemas referenced: 1786466527403,6aa014505ddd1707103c870a"]
}
This issue could be in relatio with issue: #262
apiops CLI version
apiops --version 1.0.1
Environment details
Usage:
npm install -g @azure-tools/apiops-cli --no-fund --no-audit
apiops extract --resource-group ${AZURE_RESOURCE_GROUP_NAME} --service-name ${API_MANAGEMENT_SERVICE_NAME} --output ./apim-artifacts --filter ${CONFIGURATION_YAML_FILE} --format json
Runs in : Gitlab pipeline on self hosted runner with base image: mcr.microsoft.com/dotnet/sdk:6.0
Nodejs version node-v22.14.0-linux-x64
Tried env variable ARM_API_VERSION: "2024-05-01" or no mention leading to -> 2025-09-01-preview
Tried with both formats on export: text and JSON
CI/CD environment
Other
Is this bug blocking you?
Yes
Activity
fix: attribute 13-digit schema IDs to portal-created schemas; add pub…
Alexey-Zheltov commentedon Sep 8, 2026
I've been investigating this and can share verification results plus a candidate fix, but I need a few details from your environment to confirm the mechanism.
What I verified against a live APIM instance: importing an OpenAPI spec through ARM (
PUT /apis/{id}?import=true) generates 24-char hex schema IDs on every API version I probed (2021-08-01, 2022-08-01, 2023-05-01-preview, 2024-05-01, 2025-09-01-preview). I could not get ARM spec import to produce a 13-digit ID like1786466527403on any version.1786466527403parses as an epoch-milliseconds timestamp (≈ 2026-08-11) — aDate.now()-style ID. Since the schema ID inPUT .../schemas/{schemaId}is chosen by the client, this points at the schema having been created by a different client on your source instance, most likely the Azure portal's OpenAPI specification editor. The duplicate would then be: spec import creates a fresh 24-hex schema on the destination + the CLI re-publishes the 13-digit artifact schema as "explicit" (its auto-generated-ID filter only matches 24-hex), yielding two schemas.Candidate fix (treats 13-digit epoch-millis IDs as auto-generated so they are skipped on publish, like their 24-hex counterparts):
Alexey-Zheltov/apiops-cli@fix/timestamp-schema-idsTo confirm this matches your case, could you check:
1786466527403or6aa014505ddd1707103c870a? (i.e. what's underapis/<api>/schemas/<id>/schemaInformation.json)GET .../apis/<api>/schemas?api-version=2024-05-01)contentTypeof the artifact schema —application/vnd.oai.openapi.components+json?schemaIdin request/response representations) in the artifacts?Answer to (1) is the critical one: if the artifact schema is the 13-digit one, the linked fix should resolve your case; if it's the 24-hex one, the duplicate is produced by a different mechanism and needs more digging.
TiberiuGarbea commentedon Sep 8, 2026
Hi Aleksey Zheltov (@Alexey-Zheltov) , thanks for looking into this.
To answer your questions here is a redacted snippet from extracted schemaInformation.json of an api:
"id": "/subscriptions/1232222222/resourceGroups/my-tes-trg/providers/Microsoft.ApiManagement/service/apim-source-instance/apis/api-name/schemas/1786466527403",
"type": "Microsoft.ApiManagement/service/apis/schemas",
"name": "1786466527403",
"properties": {
"contentType": "application/vnd.oai.openapi.components+json",
"document": {
"components": {
"schemas": {
"ApiRequest": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
TiberiuGarbea commentedon Sep 11, 2026
Hi Aleksey Zheltov (@Alexey-Zheltov) , yesterday one of my colleagues did a test:
fetched the following branch
https://github.com/Alexey-Zheltov/apiops-cli/tree/fix/timestamp-schema-ids
build locally and ran the pipeline using this not-yet merged version of apiops-cli.
What we observed was that indeed there was only one schema on the destination APIs but it was the newly created one and not the original from dev.
DEV schema:
"type": "Microsoft.ApiManagement/service/apis/schemas",
"name": "1758020457424",
"properties": {
"contentType": "application/vnd.oai.openapi.components+json"
TEST schema:
"type": "Microsoft.ApiManagement/service/apis/schemas",
"name": "6aa17c915ddd1707103c8815",
"properties": {
"contentType": "application/vnd.oai.openapi.components+json"
TiberiuGarbea commentedon Sep 11, 2026
Hi Aleksey Zheltov (@Alexey-Zheltov), good afternoon. Today we did another test regarding schema transition across environments:
Expectations:
Our Expectation is that Schema ID will be kept during migration between environments so that we know that APIs migrated with CICD are consistent across environments and were not altered from Portal.
Test apiops_cli schema transition across environments
Apiops_cli version: https://github.com/Alexey-Zheltov/apiops-cli/tree/fix/timestamp-schema-ids
Envs: APIM Demo1 as source and APIM Demo 2 (newly created) as destination
Scenario proposed for testing:
1. Migration from Demo1 to Demo1 - create the second schema -- delete the original schema by hand
2. Migration Demo1 to Demo2 - Demo2 clean 0 schemas --- you can see what schema we have after publish -- is it the one that came from dev?
3. Changes in the portal Demo1 - add operation to an API -- query Demo1 schema - Do we have the same schema or more?
4. Migration Demo1 to Demo2 - is the dev schema kept? How many schemas do we have?
Results:
Demo1 source: schema 6aa2987c5ddd17093c34d59e - deleted (1758020457424) could not delete 6aa2987c5ddd17093c34d59e - error, schema linked to operations.
Conclusion: Publish creates a new schema ID on every iteration. Event publishing to self will update schema ID. Only one schema was always retrieved per API.
Alexey-Zheltov commentedon Sep 11, 2026
Update: I was able to reproduce the full scenario end-to-end, including where the 13-digit ID comes from.
Where
1786466527403-style IDs originate (verified live):The Azure portal generates them client-side (
Date.now()), but only on one specific path:application/json→ New definition with a sample payloadThe portal then does
PUT .../schemas/{Date.now()}— the resulting schema name decodes exactly to the millisecond of the Save click (I verified this: my test produced1789146226316= the moment I hit Save; yours,1786466527403, decodes to2026-08-11 16:42:07 UTC, presumably when one of your developers edited the API on dev).For completeness, the other paths do not produce these IDs:
PUT /apis/{id}?import=true) generates 24-hex IDs on every api-version from 2021-08-01 to 2025-09-01-previewThe duplication mechanism, confirmed: your artifact carries the portal-created 13-digit schema; on publish the spec import creates its own 24-hex schema on the destination, and the CLI additionally re-PUTs the 13-digit one because its auto-generated-ID filter only recognized 24-hex names. Hence exactly two schemas, stable across repeated publishes — matching everything you observed, including the
x-ms-export-notes"multiple schemas" message.Fix:
Alexey-Zheltov/apiops-cli@fix/timestamp-schema-ids— 13-digit epoch-millis schema names are now skipped during publish, but only on the spec-import path for ApiSchema resources (deliberately not widening the general auto-generated-ID predicate, so named values, subscriptions, and operations with numeric names are unaffected). After the fix the destination ends up with the single import-created schema; operation schema bindings are handled by the import itself.Two notes for trying it:
az rest --method delete --url ".../apis/<api>/schemas/1786466527403?api-version=2024-05-01"On the #262 relation: unrelated to schema IDs. I reproduced the 24h→12h time mangling with plain
az restand no apiops involved: importing a spec whose schema example contains"2026-07-11T14:01:26.0000000+00:00"stores it as"2026-07-11T02:01:26Z". That's APIM's own OpenAPI serializer (a .NEThh-vs-HHformat defect) re-serializing the spec on import — consistent with your observation that the archived .NET apiops v7.0.4 shows the same corruption. #262 is an APIM service defect, not a CLI bug; worth raising with the APIM product group.fix: treat 13-digit epoch-millis schema IDs as auto-generated