New-AzWebAppSSLBinding:操作返回无效的状态代码“NotFound”

SUP*_*S3T 2 powershell azure

我正在尝试将New-AzWebAppSSLBindingpfx ssl 证书上传并安装到 Azure,但是出现错误:

"New-AzWebAppSSLBinding : Operation returned an invalid status code 'NotFound'".





PSVersion 5.1.14393.2515 
PSEdition Desktop 
BuildVersion 10.0.14393.2515 
CLRVersion 4.0.30319.42000
Run Code Online (Sandbox Code Playgroud)

我可以通过以下方式成功获取有关我的资源的信息:

Get-AzResourceGroup -Name $azResourceGroup
Get-AzWebApp -Name $azWebAppName
Run Code Online (Sandbox Code Playgroud)

通过以下方式成功连接到 SPN 后:

$azpsw = ConvertTo-SecureString $clientSecret -AsPlainText -Force
$pscredential = New-Object System.Management.Automation.PSCredential($appID, $azpsw)
$azConnect = Connect-AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantID -Force
Run Code Online (Sandbox Code Playgroud)

我执行以下命令:

New-AzWebAppSSLBinding -ResourceGroupName $azResourceGroup -WebAppName $azWebAppName -Name $azName -CertificateFilePath $azCertPath -CertificatePassword $azCertPsw -Verbose
Run Code Online (Sandbox Code Playgroud)

这会导致错误:

New-AzWebAppSSLBinding : Operation returned an invalid status code 'NotFound'
Run Code Online (Sandbox Code Playgroud)

SUP*_*S3T 7

我能够通过将-Debug参数附加到 New-AzWebAppSSLBinding 来解决我的问题。我的主机名与证书主题名称不匹配。

这导致我通过以下方式设置正确的主机名: Set-AzWebApp -ResourceGroupName $azResourceGroup -Name $azWebAppName -HostNames @("server_name.azurewebsites.net","server_name.my.domain.name")

第一个条目必须存在,否则 Azure PS 将引发警告。

我的问题已解决。