Azure 操作返回无效状态 'Conflict'

Azure Operation returned an invalid status 'Conflict'

我在 运行 powershell

时遇到以下错误
$thumbprint=$(az webapp config ssl upload --certificate-file $Path --certificate-password $(pwd) --name $env:APP_NAME --resource-group $env:RG_NAME --query thumbprint --output tsv)



{"Code":"Conflict","Message":"Another certificate exists with same thumbprint xxxxxxxxxxxxxxxxxxxxxxxxxxx at location xxxxxx in the Resource Group xxxxxx.","Target":null,"Details":[{"Message":"Another certificate exists with same thumbprint xxxxxxxxxxxxxxxxxxxxxxxxxxx at location xxxxxx in the Resource Group xxxxxx."},{"Code":"Conflict"},{"ErrorEntity":{"ExtendedCode":"53008","MessageTemplate":"Another certificate exists with same thumbprint {0} at location {1} in the Resource Group {2}.","Parameters":["xxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxx","xxxxxx"],"Code":"Conflict","Message":"Another certificate exists with same thumbprint xxxxxxxxxxxxxxxxxxxxxxxxxxx at location xxxxxx in the Resource Group xxxxxx."}}],"Innererror":null}

当您尝试上传具有不同证书名称的现有证书时,您会收到此错误。 运行 作为 CI/CD 工作流程一部分的 ARM 模板(通过门户进行初始设置后)是最常见的情况。将同一个证书上传到两个不同的 AppServicePlans 是另一种常见情况(它们在同一个 WebSpace 中)。
您可以通过更改 ARM 模板来解决此问题,以便证书资源名称与资源浏览器中的名称相匹配。或者,您可以删除旧证书和 运行 ARM 模板。
要获取证书资源名称,您可以尝试下面列出的 PowerShell 脚本。

$resourceGroupName = "SixShotRG"
$thumbprint = "78311D191030008F5D7EEDC0FCC295AFEED5DFD7"

$certificates = Get-AzResource `
 -ResourceGroupName $resourceGroupName `

 -ResourceType Microsoft.Web/certificates
Write-Host ("Looking for thumbprint "  + $thumbprint + "..."  )
Write-Host ("`tFound "  + $certificates.Count `
+ " certificates in ResourceGroup : "  `
+ $resourceGroupName `
+ $resourceGroup.Name)
foreach  ($certificate **in**  $certificates) {
 $cert = Get-AzResource `
-ResourceGroupName $resourceGroupName `
-ResourceType Microsoft.Web/certificates `
-ResourceName $certificate.Name
if  ($thumbprint -eq $cert.properties.thumbprint) {
Write-Host ("`tFound our cert in "  `
+ $cert.properties.webSpace `
+ ' webspace')
+ Write-Host ("`tCert name is "  `
+ $cert.Name)
 Exit
}
}