运行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}
当您尝试上载具有不同证书名称的现有证书时,会出现此错误。将ARM模板作为CI/CD工作流的一部分运行(在通过门户进行初始设置之后(是最常见的场景。将同一证书上传到两个不同的AppServicePlan是另一种常见的场景(它们在同一个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
}
}