首页 > 解决方案 > 为自定义域启用 HTTPS 时,Azure CDN 失败并显示“不允许该操作”

问题描述

我正在尝试在 Azure CDN 的自定义域上启用 HTTPS,但是az当我尝试以编程方式执行此操作时,PowerShell 和 API 都失败了。

{
  "error": {
    "code": "BadRequest",
    "message": "That action isn’t allowed in this profile."
  }
}

首先,我尝试通过 PowerShell。-Debug注意:除非您使用开关,否则这会产生一个相当无用的错误-

Enable-AzCdnCustomDomainHttps -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -CustomDomainName $customDomainName -Debug

注意到az我安装的 PowerShell 版本使用的是 API 版本2019-04-15,我开始调查是否有更新的 API 版本可用,并且有 - 2019-12-21。使用这个最新的 API,我在 PowerShell 之外运行了 HTTP 请求,但这导致了完全相同的错误。

curl --location --request POST 'https://management.azure.com/subscriptions/{{SubscriptionId}}/resourceGroups/{{ResourceGroup}}/providers/Microsoft.Cdn/profiles/{{CdnProfile}}/endpoints/{{CdnEndpoint}}/customDomains/{{CdnCustomDomain}}/enableCustomHttps?api-version=2019-12-31' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{BearerToken}}' \
--data-raw '{
  "certificateSource": "Cdn",
  "certificateSourceParameters": {
    "certificateType": "Shared",
    "@odata.type": "#Microsoft.Azure.Cdn.Models.CdnCertificateSourceParameters"
  },
  "protocolType": "IPBased"
}'

进一步挖掘,微软似乎在去年 8 月承认了这个问题,但随后迅速关闭了这个问题,没有实际修复它或提供解决方法。

有没有人能够为此提出解决方法?微软不费心去解决这个问题似乎是不可思议的,而且每次我们创建一个新的 CDN 时都依赖人工干预是不可持续的。

标签: azure-cdn

解决方案


看看这个线程: https ://github.com/Azure/azure-powershell/issues/9654 ,同样的问题出现在 UI 上,所以它似乎是 Azure 资源管理器中的一个错误。

在 UI 上,解决方案是以隐身模式打开。也许这是会话的问题,因此在 CLI 中再次注销应该也有帮助。


推荐阅读