Skip to content

Commit 5accd82

Browse files
authored
Merge pull request #308794 from dlepow/sdcli
[APIM] Update soft-delete article with Azure CLI examples
2 parents 486c2e6 + 2fdb125 commit 5accd82

1 file changed

Lines changed: 62 additions & 31 deletions

File tree

articles/api-management/soft-delete.md

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.service: azure-api-management
55
ms.topic: how-to
66
author: dlepow
77
ms.author: danlep
8-
ms.date: 10/13/2025
8+
ms.date: 11/26/2025
99
---
1010

1111
# API Management soft-delete
@@ -14,18 +14,13 @@ ms.date: 10/13/2025
1414

1515
With API Management soft-delete, you can recover and restore a recently deleted API Management instance. This feature protects against accidental deletion of your API Management instance.
1616

17-
Currently, depending on how you delete an API Management instance, the instance is either soft-deleted and recoverable during a retention period, or permanently deleted:
18-
19-
- When you use the Azure portal or REST API version `2020-06-01-preview` or later to delete an API Management instance, it's **soft-deleted**.
20-
- An API Management instance deleted using a REST API version before `2020-06-01-preview` is **permanently deleted**.
21-
- An API Management instance deleted using API Management commands in Azure PowerShell or Azure CLI is **soft-deleted**.
22-
2317
## Supporting interfaces
2418

25-
Recovery and other operations on a soft-deleted instance are enabled through [REST API](/rest/api/apimanagement/current-ga/api-management-service/restore) version `2020-06-01-preview` or later, or the Azure SDK for .NET, Go, or Python.
19+
You can recover and perform other operations on a soft-deleted instance through [REST API](/rest/api/apimanagement/current-ga/api-management-service/restore) version `2020-06-01-preview` or later, [Azure CLI](/cli/azure/apim/deletedservice), or the Azure SDK for .NET, Go, or Python.
2620

2721
> [!TIP]
28-
> For more information about tips and tools for calling Azure REST APIs, see [Azure REST API Reference](/rest/api/azure/), and for information specific to API Management, see [API Management REST](/rest/api/apimanagement/).
22+
> * For more information about tips and tools for calling Azure REST APIs, see [Azure REST API Reference](/rest/api/azure/). For information specific to API Management, see [API Management REST](/rest/api/apimanagement/).
23+
> * To use the Azure CLI, see [Install Azure CLI](/cli/azure/install-azure-cli) if you haven't already installed it.
2924
3025
| Operation | Description | API Management namespace | Minimum API version |
3126
|--|--|--|--|
@@ -38,66 +33,90 @@ Recovery and other operations on a soft-deleted instance are enabled through [RE
3833

3934
## Soft-delete behavior
4035

41-
You can use any API version to create your API Management instance. When you use the Azure portal, Azure REST API, or another Azure tool using API version `2020-06-01-preview` or later to delete an API Management instance, the instance is automatically soft-deleted.
36+
You can use any API version to create your API Management instance. When you use the Azure portal, Azure REST API, or another Azure tool with API version `2020-06-01-preview` or later to delete an API Management instance, the instance is automatically soft-deleted.
4237

43-
Once an API Management instance is soft-deleted, the service exists in a deleted state, making it inaccessible to normal API Management operations.
38+
When you soft-delete an API Management instance, the service enters a deleted state and becomes inaccessible to normal API Management operations.
4439

4540
In the soft-deleted state:
4641

47-
- The API Management instance can only be [listed](#list-deleted-api-management-instances), [recovered](#recover-a-soft-deleted-instance), or [purged](#purge-a-soft-deleted-instance) (permanently deleted).
48-
- Azure will schedule the permanent deletion of the underlying data corresponding to the API Management instance after the predetermined (48 hour) retention period.
42+
- You can only [list](#list-deleted-api-management-instances), [recover](#recover-a-soft-deleted-instance), or [purge](#purge-a-soft-deleted-instance) (permanently delete) the API Management instance.
43+
- Azure schedules the permanent deletion of the underlying data for the API Management instance after the predetermined 48-hour retention period.
4944
- You can't reuse the name of the API Management instance.
5045

51-
If you don't recover or purge your API Management instance within 48 hours, the instance is automatically deleted permanently.
46+
If you don't recover or purge your API Management instance within 48 hours, the instance is permanently deleted.
5247

5348
## List deleted API Management instances
5449

55-
You can verify that a soft-deleted API Management instance is available to restore (undelete), by using either the Deleted Services [Get By Name](/rest/api/apimanagement/current-ga/deleted-services/get-by-name) operations or the [List By Subscription](/rest/api/apimanagement/current-ga/deleted-services/list-by-subscription) operation.
50+
You can verify that a soft-deleted API Management instance is available to restore by using either the Deleted Services [Get By Name](/rest/api/apimanagement/current-ga/deleted-services/get-by-name) operations or the [List By Subscription](/rest/api/apimanagement/current-ga/deleted-services/list-by-subscription) operation.
5651

5752
### Get a soft-deleted instance by name
5853

54+
# [REST API](#tab/rest)
55+
5956
Use the API Management [Get By Name](/rest/api/apimanagement/current-ga/deleted-services/get-by-name) operation, substituting `{subscriptionId}`, `{location}`, and `{serviceName}` with your Azure subscription, [resource location name](/rest/api/resources/subscriptions/list-locations#location), and API Management instance name:
6057

6158
```rest
62-
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2021-08-01
59+
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2024-05-01
60+
```
61+
62+
# [Azure CLI](#tab/cli)
63+
64+
Use the [az apim deletedservice show](/cli/azure/apim/deletedservice#az-apim-deletedservice-show) command, substituting `{location}` and `{serviceName}` with your [resource location name](/rest/api/resources/subscriptions/list-locations#location) and API Management instance name:
65+
66+
```azurecli
67+
az apim deletedservice show --location {location} --service-name {serviceName}
6368
```
6469

65-
If it's available for undelete, Azure returns a record of the API Management instance showing its `deletionDate` and `scheduledPurgeDate`, for example:
70+
---
71+
72+
If the API Management instance is available for undelete, Azure returns a record of the instance that shows its `deletionDate` and `scheduledPurgeDate`. For example, the REST API returns output similar to this:
6673

6774
```json
6875
{
69-
"id": "subscriptions/########-####-####-####-############/providers/Microsoft.ApiManagement/locations/southcentralus/deletedservices/apimtest",
76+
"id": "subscriptions/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f/providers/Microsoft.ApiManagement/locations/southcentralus/deletedservices/apimtest",
7077
"name": "apimtest",
7178
"type": "Microsoft.ApiManagement/deletedservices",
7279
"location": "South Central US",
7380
"properties": {
74-
"serviceId": "/subscriptions/########-####-####-####-############/resourceGroups/apimtestgroup/providers/Microsoft.ApiManagement/service/apimtest",
75-
"scheduledPurgeDate": "2021-11-26T19:40:26.3596893Z",
76-
"deletionDate": "2021-11-24T19:40:50.1013572Z"
81+
"serviceId": "/subscriptions/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f/resourceGroups/apimtestgroup/providers/Microsoft.ApiManagement/service/apimtest",
82+
"scheduledPurgeDate": "2024-11-26T19:40:26.3596893Z",
83+
"deletionDate": "2024-11-24T19:40:50.1013572Z"
7784
}
7885
}
7986
```
8087

8188
### List all soft-deleted instances for a given subscription
8289

90+
# [REST API](#tab/rest)
91+
8392
Use the API Management [List By Subscription](/rest/api/apimanagement/current-ga/deleted-services/list-by-subscription) operation, substituting `{subscriptionId}` with your subscription ID:
8493

8594
```rest
86-
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices?api-version=2021-08-01
95+
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices?api-version=2024-05-01
8796
```
8897

89-
This command returns a list all soft-deleted services available for undelete under the given subscription, showing the `deletionDate` and `scheduledPurgeDate` for each.
98+
# [Azure CLI](#tab/cli)
99+
100+
Use the [az apim deletedservice list](/cli/azure/apim/deletedservice#az-apim-deletedservice-list) command:
90101

91-
## Recover a soft deleted instance
102+
```azurecli
103+
az apim deletedservice list
104+
```
105+
106+
---
107+
108+
This command returns a list of all soft-deleted services that you can undelete under the given subscription. It shows the `deletionDate` and `scheduledPurgeDate` for each service.
109+
110+
## Recover a soft-deleted instance
92111

93112
Use the API Management [Create Or Update](/rest/api/apimanagement/current-ga/api-management-service/create-or-update) operation, substituting `{subscriptionId}`, `{resourceGroup}`, and `{apimServiceName}` with your Azure subscription, resource group name, and API Management name:
94113

95114
```rest
96115
PUT
97-
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.ApiManagement/service/{apimServiceName}?api-version=2021-08-01
116+
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.ApiManagement/service/{apimServiceName}?api-version=2024-05-01
98117
```
99118

100-
. . . and set the `restore` property to `true` in the request body. (When this flag is specified and set to *true*, all other properties are ignored.) For example:
119+
In the request body, set the `restore` property to `true`. (When this flag is specified and set to *true*, all other properties are ignored.) For example:
101120

102121
```json
103122
{
@@ -116,15 +135,27 @@ https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{reso
116135

117136
## Purge a soft-deleted instance
118137

119-
Use the API Management [Purge](/rest/api/apimanagement/current-ga/deleted-services/purge) operation, substituting `{subscriptionId}`, `{location}`, and `{serviceName}` with your Azure subscription, resource location, and API Management name.
120-
121138
> [!NOTE]
122139
> To purge a soft-deleted instance, you must have the following role-based access control (RBAC) permissions at the subscription scope in addition to Contributor access to the API Management instance: Microsoft.ApiManagement/locations/deletedservices/delete, Microsoft.ApiManagement/deletedservices/read.
123140
141+
# [REST API](#tab/rest)
142+
143+
Use the API Management [Purge](/rest/api/apimanagement/current-ga/deleted-services/purge) operation, substituting `{subscriptionId}`, `{location}`, and `{serviceName}` with your Azure subscription, resource location, and API Management name.
144+
124145
```rest
125-
DELETE https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2021-08-01
146+
DELETE https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}?api-version=2024-05-01
126147
```
127148

149+
# [Azure CLI](#tab/cli)
150+
151+
Use the [az apim deletedservice purge](/cli/azure/apim/deletedservice#az-apim-deletedservice-purge) command, substituting `{location}` and `{serviceName}` with your resource location and API Management name.
152+
153+
```azurecli
154+
az apim deletedservice purge --location {location} --service-name {serviceName}
155+
```
156+
157+
---
158+
128159
This command permanently deletes your API Management instance from Azure.
129160

130161
## Reuse an API Management instance name after deletion
@@ -139,9 +170,9 @@ You **can't** reuse the name of an API Management instance in a new deployment:
139170

140171
- While the instance is soft-deleted.
141172

142-
- In a subscription other than the one used to deploy the original instance, even after the original instance is permanently deleted (purged) from Azure. This restriction applies whether the new subscription used is in the same or a different Microsoft Entra tenant. The restriction is in effect for several days or longer after deletion, depending on the subscription type.
173+
- In a subscription other than the one used to deploy the original instance, even after the original instance is permanently deleted (purged) from Azure. This restriction applies whether the new subscription is in the same or a different Microsoft Entra tenant. The restriction is in effect for several days or longer after deletion, depending on the subscription type.
143174

144-
This restriction is because Azure reserves the service host name to a customer's tenant for a reservation period to prevent the threat of subdomain takeover with dangling domain name system (DNS) entries. For more information, see [Prevent dangling DNS entries and avoid subdomain takeover](/azure/security/fundamentals/subdomain-takeover). To see all dangling DNS entries for subscriptions in a Microsoft Entra tenant, see [Identify dangling DNS entries](/azure/security/fundamentals/subdomain-takeover#identify-dangling-dns-entries).
175+
This restriction exists because Azure reserves the service host name to a customer's tenant for a reservation period to prevent the threat of subdomain takeover with dangling domain name system (DNS) entries. For more information, see [Prevent dangling DNS entries and avoid subdomain takeover](/azure/security/fundamentals/subdomain-takeover). To see all dangling DNS entries for subscriptions in a Microsoft Entra tenant, see [Identify dangling DNS entries](/azure/security/fundamentals/subdomain-takeover#identify-dangling-dns-entries).
145176

146177

147178
## Related content

0 commit comments

Comments
 (0)