Azure / Azure/azure-rest-api-specs

[APIM] The service could not be restored immediately after soft deletion

Open
#25,262 2 comments 0 reactions 0 assignees View on GitHub
customer-reported needs-team-attention question Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 2h
Merged PRs (30d)
424

Description

The APIM service `acctestAM-test` could not be restored immediately after soft deletion succeeds. The details are as follows. It is worth mentioning that if you wait for a while (about 1 minute) after step2, the restore could succeed. We look forward to recovering immediately after a successful soft delete. If it is by design, I assume that a status should be returned to let us know when the deleted service could be restored, right? For example: append the status field in the response of [DeletedServices_GetByName](https://github.com/Azure/azure-rest-api-specs/blob/d3edca94ae4ddb854e88142cba6a7337ef1a5eed/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/apimdeletedservices.json#L81C13-L81C13) API.

step1. Confirm `acctestAM-test` does not exist after soft deletion:
```
AzureRM Request:
GET /subscriptions/.../resourceGroups/acctestRG-test/providers/Microsoft.ApiManagement/service/acctestAM-test?api-version=2022-08-01 HTTP/1.1
Host: management.azure.com
User-Agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 apimanagementservice/2022-08-01) HashiCorp Terraform/1.5.1 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
Accept-Encoding: gzip

AzureRM Response for https://management.azure.com/subscriptions/.../resourceGroups/acctestRG-test/providers/Microsoft.ApiManagement/service/acctestAM-test?api-version=2022-08-01:
HTTP/2.0 404 Not Found
Content-Length: 138
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Thu, 10 Aug 2023 05:21:46 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
X-Ms-Ratelimit-Remaining-Subscription-Reads: 11998
X-Ms-Request-Id: 85972085-5b34-4d1a-8709-b075fb8deb45
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20230810T052146Z:85972085-5b34-4d1a-8709-b075fb8deb45

{"error":{"code":"ServiceNotFound","message":"Api service does not exist: acctestAM-test","details":null,"innerError":null}}

```
step2. Get `acctestAM-test` exist in deletedServices:
AzureRM Request:
```
GET /subscriptions/.../providers/Microsoft.ApiManagement/locations/eastus/deletedServices/acctestAM-test?api-version=2022-08-01 HTTP/1.1
Host: management.azure.com
User-Agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 deletedservice/2022-08-01) HashiCorp Terraform/1.5.1 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
Accept-Encoding: gzip

AzureRM Response for https://management.azure.com/subscriptions/.../providers/Microsoft.ApiManagement/locations/eastus/deletedServices/acctestAM-test?api-version=2022-08-01:
HTTP/2.0 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Thu, 10 Aug 2023 05:21:47 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
X-Ms-Ratelimit-Remaining-Subscription-Reads: 11999
X-Ms-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20230810T052148Z:c7fa4ff2-6126-4764-8704-332f2a06b056

{"id":"/subscriptions/.../providers/Microsoft.ApiManagement/locations/eastus/deletedservices/acctestAM-test","name":"acctestAM-test","type":"Microsoft.ApiManagement/deletedservices",
"location":"East US","properties":{"serviceId":"/subscriptions/.../resourceGroups/acctestRG-test/providers/Microsoft.ApiManagement/service/acctestAM-test",
"scheduledPurgeDate":"9999-12-31T23:59:59.9999999","deletionDate":"2023-08-10T05:20:59.810718Z"}}

```

step3. Restore the `acctestAM-test` =>error occurred.
```
AzureRM Request:
PUT /subscriptions/.../resourceGroups/acctestRG-test/providers/Microsoft.ApiManagement/service/acctestAM-test?api-version=2022-08-01 HTTP/1.1
Host: management.azure.com
User-Agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 apimanagementservice/2022-08-01) HashiCorp Terraform/1.5.1 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Length: 132
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
Accept-Encoding: gzip

{"location":"eastus","properties":{"restore":true},"sku":{"capacity":0,"name":"Consumption"}}

AzureRM Response for https://management.azure.com/subscriptions/.../resourceGroups/acctestRG-test/providers/Microsoft.ApiManagement/service/acctestAM-test?api-version=2022-08-01:
HTTP/2.0 400 Bad Request
Content-Length: 141
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Thu, 10 Aug 2023 05:21:49 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
X-Ms-Ratelimit-Remaining-Subscription-Resource-Requests: 23999
X-Ms-Request-Id: d2cee4f3-883e-ce55-1910-78d3d39ce805
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20230810T052150Z:9cc60d65-86ca-4d9e-bd60-fb55a626128c

{"error":{"code":"InvalidOperation","message":"Unable to undelete service 'acctestAM-test'.","details":null,"innerError":null}}

```

Contributor guide

Open the contributing guide

Research direction

Start with specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/apimdeletedservices.json and the DeletedServices_GetByName operation. Compare its response with the restore request and the reported InvalidOperation response. Done means the API behavior or contract clearly indicates when a soft-deleted service can be restored, with the required specification change identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, openapi
Domain
api, cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.