--delete-unmatched parameter doesn't delete some API's cleanly

Open
#142 3 comments 1 reaction 2 assignees View on GitHub

@azaslonov is already working on this.

Since Jul 7, 2026.

Assessment

This issue has not been assessed yet.

Description

go:needs-research P1 squad squad:apimexpert

API's with revisions are not getting deleted from destination API Management when running pipeling with --delete-unmatched parameter.

Command:

apiops publish --resource-group xxxxxxxxxxxxxx --service-name prod-apim-uk-01 --subscription-id 00000000-0000-0000-0000-000000000000 --source C:\vsts-agent-win-x64-4.274.1_work\2\s\apim-artifacts --overrides C:\vsts-agent-win-x64-4.274.1_work\2\s\prod.yaml --delete-unmatched

61 2026-06-11T08:11:50.7868446Z 2026-06-11T08:11:50.784Z [ERROR] Failed to delete apis/ai-project-01: [{"name":"Error","message":"Async operation failed for apis/ai-project-01: [ValidationError] Cannot delete the current revision of an API.","stack":"Error: Async operation failed for apis/ai-project-01: [ValidationError] Cannot delete the current revision of an API.\n at ApimClient.pollAsyncOperation (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/clients/apim-client.js:721:23)\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n at async ApimClient.deleteResource (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/clients/apim-client.js:378:21)\n at async file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/services/publish-service.js:458:29\n at async ParallelRunner.executeTask (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/lib/parallel-runner.js:54:27)"}]
62 2026-06-11T08:11:51.4674195Z ERROR DELETE api/ai-project-01: Async operation failed for apis/ai-project-01: [ValidationError] Cannot delete the current revision of an API.
63 2026-06-11T08:11:51.4674627Z DELETE api/ai-project-01;rev=2
65 2026-06-11T08:11:51.4675322Z DELETE api/m365-proxy
66 2026-06-11T08:11:51.4675539Z DELETE api/petproxy
67 2026-06-11T08:11:51.4675761Z DELETE product/openai-pilot
68 2026-06-11T08:11:51.4675989Z DELETE diagnostic/azuremonitor
69 2026-06-11T08:11:55.2375830Z 2026-06-11T08:11:55.234Z [ERROR] Failed to delete backends/ai-project-01-ai-endpoint: [{"name":"HttpError","message":"HTTP 400: {"error":{"code":"ValidationError","message":"Backend 'ai-project-01-ai-endpoint' is used by the following entities:\r\n/apis/ai-project-01;rev=1/policies/policy\r\n","details":null}}","stack":"HttpError: HTTP 400: {"error":{"code":"ValidationError","message":"Backend 'ai-project-01-ai-endpoint' is used by the following entities:\r\n/apis/ai-project-01;rev=1/policies/policy\r\n","details":null}}\n at ApimClient.request (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/clients/apim-client.js:167:27)\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n at async ApimClient.deleteResource (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/clients/apim-client.js:370:30)\n at async file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/services/publish-service.js:458:29\n at async ParallelRunner.executeTask (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/lib/parallel-runner.js:54:27)"}]
70 2026-06-11T08:12:03.7676613Z 2026-06-11T08:12:03.763Z [ERROR] Failed to delete namedValues/6a1eda3eb949c31708397423: [{"name":"HttpError","message":"HTTP 400: {"error":{"code":"ValidationError","message":"The Api Management Property '6a1eda3eb949c31708397423' is used by the following entities:\r\n/loggers/apim-uk-appinsights\r\n","details":null}}","stack":"HttpError: HTTP 400: {"error":{"code":"ValidationError","message":"The Api Management Property '6a1eda3eb949c31708397423' is used by the following entities:\r\n/loggers/apim-uk-appinsights\r\n","details":null}}\n at ApimClient.request (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/clients/apim-client.js:167:27)\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n at async ApimClient.deleteResource (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/clients/apim-client.js:370:30)\n at async file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/services/publish-service.js:458:29\n at async ParallelRunner.executeTask (file:///C:/Windows/ServiceProfiles/NetworkService/AppData/Roaming/npm/node_modules/@peterhauge/apiops-cli/dist/lib/parallel-runner.js:54:27)"}]
71 2026-06-11T08:12:03.8089233Z ERROR DELETE backend/ai-project-01-ai-endpoint: HTTP 400: {"error":{"code":"ValidationError","message":"Backend 'ai-project-01-ai-endpoint' is used by the following entities:\r\n/apis/ai-project-01;rev=1/policies/policy\r\n","details":null}}
72 2026-06-11T08:12:03.8089978Z ERROR DELETE namedvalue/6a1eda3eb949c31708397423: HTTP 400: {"error":{"code":"ValidationError","message":"The Api Management Property '6a1eda3eb949c31708397423' is used by the following entities:\r\n/loggers/apim-uk-appinsights\r\n","details":null}}

Dominant language
TypeScript
Stars
29
Forks
10
Avg merge
1d 14h
Merged PRs (30d)
22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/apiops-cli

All issues in Azure/apiops-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.