看來,現在你可以使用
$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
}
注意:這隻能當你將使用進口AzurePublishSettingsFile天青
任何人都可以確認可以安全使用DefaultAccount
屬性?
UPDATE
如果使用Kudu API上傳您的網站,like this,你不需要任何證書或發佈配置文件。您應該使用Get-AzureWebsite
來讀取用戶名和密碼,主機名只是yourwebsitename.scm.azurewebsites.net
(注意scm段)。我建議使用Kudu,因爲它更加可靠和快速。
另一種方法是通過SCM(Kudu)站點部署文件。查看可用的REST API(https://github.com/projectkudu/kudu/wiki/REST-API);特別是VFS或Zip。讓我們知道如果仍然問題。 – 2014-11-04 04:08:44
@SuwatCh謝謝,Kudu似乎是一個非常有趣的選擇! – 2014-11-05 08:39:26
@SuwatCh我結束了使用kudu。這裏[我的要點](https://gist.github.com/davideicardi/a8247230515177901e57) – 2014-11-07 10:52:24