看来现在您可以使用访问证书指纹了
$thumbprint = $s.DefaultAccount
代替
#$thumbprint = $s.Certificate.Thumbprint
似乎 DefaultAccount 具有与证书指纹完全相同的值。
仅供参考,这是我获取给定网站的发布配置文件的完整脚本:
Function get-AzureWebSitePublishXml
{
Param(
[Parameter(Mandatory = $true)]
[String]$WebsiteName
)
# Get the current subscription
$s = Get-AzureSubscription -Current
if (!$s) {throw "Cannot get Windows Azure subscription."}
#$thumbprint = $s.Certificate.Thumbprint #this code doesn't work anymore
$thumbprint = $s.DefaultAccount
if (!$thumbprint) { throw "Cannot get subscription cert thumbprint."}
# Get the certificate of the current subscription from your local cert store
$cert = Get-ChildItem Cert:\CurrentUser\My\$thumbprint
if (!$cert) {throw "Cannot find subscription cert in Cert: drive."}
$website = Get-AzureWebsite -Name $WebsiteName
if (!$website) {throw "Cannot get Windows Azure website: $WebsiteName."}
# Compose the REST API URI from which you will get the publish settings info
$uri = "https://management.core.windows.net:8443/{0}/services/WebSpaces/{1}/sites/{2}/publishxml" -f `
$s.SubscriptionId, $website.WebSpace, $Website.Name
# Get the publish settings info from the REST API
$publishSettings = Invoke-RestMethod -Uri $uri -Certificate $cert -Headers @{"x-ms-version" = "2013-06-01"}
if (!$publishSettings) {throw "Cannot get Windows Azure website publishSettings."}
return $publishSettings
}
注意:这仅在您使用 Import-AzurePublishSettingsFile 连接到 azure 时有效
任何人都可以确认使用DefaultAccount
财产是安全的吗?
更新
如果您像这样使用Kudu API上传您的网站,则不需要任何证书或发布配置文件。您应该使用读取用户名和密码,并且主机名只是(注意 scm 段)。我建议使用 Kudu,因为它更加可靠和快速。Get-AzureWebsite
yourwebsitename.scm.azurewebsites.net