[英]How Do I Purge A Soft-Deleted APIM With Terraform?
Azure API 管理现在是“软删除”的,如果被误删除,您可以恢复它。
creating Azure API Management using deleted name results name "already in use" 错误
当使用terraform destroy
时,它会进行软删除,这使得开发变得棘手,因为您经常想要重新创建它。
如何使用 terraform 清除软删除的 APIM?
遇到同样的事情,我快速研究如何调用这个 API:
az rest --method delete --header "Accept=application/json" -u 'https://management.azure.com/subscriptions/{SubscriptionId}/providers/Microsoft.ApiManagement/locations/{eastus}/deletedservices/{api name}?api-version=2020-06-01-preview'
此功能已纳入 azurerm provider v2.77.0
您可以拨打api查看并删除软删除的azure apims。 下面的脚本。
参考:- https://www.sharepointcollabs.com/2021/08/purging-soft-deleted-azure-apim-api.html
#GET 请求 - 列出特定订阅中所有软删除的 apims
$token = Get-AzAccessToken
$request = @{
Method = 'GET'
Uri = "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices?api-version=2020-06-01-preview"
Headers = @{
Authorization = "Bearer $($token.Token)"
}
}
调用-RestMethod @request -OutFile c:\apimoutput.txt
#DELETE 请求 - 这将清除软删除的 apim
$token = Get-AzAccessToken
$request = @{
Method = 'DELETE'
Uri = "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{Location}/deletedservices/{APIMName}?api-version=2020-06-01-preview"
Headers = @{
Authorization = "Bearer $($token.Token)"
}
}
调用-RestMethod @request
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.