Azure / Azure/azure-rest-api-specs
Failed to delete Gallery Application when Gallery Application Version was just deleted
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 424
Description
Hi team, when using Go SDK or REST API to delete Gallery Application Version and Gallery Application, it requires an extra wait before deleting the Gallery Application when a Version was just deleted (about 20 seconds). After deleting the version, the GET API already returns 404, but within the first couple of seconds, the Gallery Application still thinks it has the nested Version thus the DELETE API fails to delete the Gallery Application. Are we able to ensure the version is considered removed from the Gallery Application before we return 404 for the Version?
Below is the API request details to explain the deletion scenario:
```
// GET returns 404 after deleting the Version, but DELETE fails when deleting the Application, it succeeded after the retry in 20 seconds
$headers = @{'Authorization'='Bearer [Token]'}
$versionURI = "https://management.azure.com/subscriptions/***/resourceGroups/yicma_rg/providers/Microsoft.Compute/galleries/yicma_gallery/applications/yicma_app/versions/0.0.1?api-version=2021-10-01"
$appURI = "https://management.azure.com/subscriptions/***/resourceGroups/yicma_rg/providers/Microsoft.Compute/galleries/yicma_gallery/applications/yicma_app?api-version=2021-10-01"
$galleryURI = "https://management.azure.com/subscriptions/***/resourceGroups/yicma_rg/providers/Microsoft.Compute/galleries/yicma_gallery?api-version=2021-10-01"
Write-Host "`nBefore deleting Version:`n"
(Invoke-WebRequest -UseBasicParsing -Headers $headers -Method "GET" $versionURI).Content
Write-Host "`nDeleting Version:`n"
(Invoke-WebRequest -UseBasicParsing -Headers $headers -Method "DELETE" $versionURI).Content
Write-Host "`nAfter deleting Version:`n"
(Invoke-WebRequest -UseBasicParsing -Headers $headers -Method "GET" $versionURI).Content
Write-Host "`nDeleting Application (1st try):`n"
(Invoke-WebRequest -UseBasicParsing -Headers $headers -Method "DELETE" $appURI).Content
Sleep 20
Write-Host "`nDeleting Application (2nd try after 20 seconds):`n"
(Invoke-WebRequest -UseBasicParsing -Headers $headers -Method "DELETE" $appURI).Content
Output:
Before deleting Version:
{
"id": "/subscriptions/***/resourceGroups/yicma_rg/providers/Microsoft.Compute/galleries/yicma_gallery/applications/yicma_app/versions/0.0.1",
..... (redacted)
}
Deleting Version
After deleting Version:
Invoke-WebRequest : {
"code": "NotFound",
"message": "The entity was not found in this Azure location.",
"target": "galleryApplicationVersionName"
}
}
At C:\Users\yicma\Downloads\delete_version.ps1:17 char:2
+ (Invoke-WebRequest -UseBasicParsing -Headers $headers -Method "GET" $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Deleting Application (1st try):
Invoke-WebRequest : {"error":{"code":"CannotDeleteResource","message":"Can not delete resource before nested resources
are deleted."}}
At C:\Users\yicma\Downloads\delete_version.ps1:21 char:2
+ (Invoke-WebRequest -UseBasicParsing -Headers $headers -Method "DELETE ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Deleting Application (2nd try after 20 seconds):
```
This is similar to https://github.com/Azure/azure-sdk-for-go/issues/8314 and #18767 in terms of nested resources.
Contributor guide
Research direction
Start with the Gallery Application Version and Gallery Application GET and DELETE requests in the supplied PowerShell reproduction, using api-version 2021-10-01. Compare this behavior with related issues #8314 and #18767 and the corresponding Azure REST API specifications; done means the version deletion state and application deletion behavior are represented or clarified consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100