2013-03-14 38 views
4

我想使用Bamboo(持續集成解決方案)進行自動部署。我在這裏找到(http://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/#script)一段腳本來幫忙。主要的代碼片段:Azure部署腳本不斷抱怨「CurrentStorageAccount未設置」

#configure powershell with Azure 1.7 modules 
Import-Module Azure 

#configure powershell with publishsettings for your subscription 
$pubsettings = $subscriptionDataFile 
Import-AzurePublishSettingsFile $pubsettings 
Set-AzureSubscription -CurrentStorageAccount $storageAccountName -SubscriptionName $selectedsubscription 
write-host $storageAccountName 
write-host "$selectedsubscription" 

#set remaining environment variables for Azure cmdlets 
$subscription = Get-AzureSubscription $selectedsubscription 
$subscriptionname = $subscription.subscriptionname 
$subscriptionid = $subscription.subscriptionid 
$slot = $environment 

#main driver - publish & write progress to activity log 
Write-Output "$(Get-Date –f $timeStampFormat) - Azure Cloud Service deploy script started." 
Write-Output "$(Get-Date –f $timeStampFormat) - Preparing deployment of $deploymentLabel for $subscriptionname with Subscription ID $subscriptionid." 


Publish 

$deployment = Get-AzureDeployment -slot $slot -serviceName $servicename 
$deploymentUrl = $deployment.Url 

Write-Output "$(Get-Date –f $timeStampFormat) - Created Cloud Service with URL $deploymentUrl." 
Write-Output "$(Get-Date –f $timeStampFormat) - Azure Cloud Service deploy script finished." 

我只是第一次嘗試通過執行powershell E:\CI\OCZDeployment\publish_cloud_service.ps1 -environment Staging -serviceName "ocz" -storageAccountName "t2vsoft" -packageLocation OCZ.cspkg -cloudConfigLocation ServiceConfiguration.Cloud.cscfg -subscriptionDataFile E:\CI\OCZDeployment\SubscriptionDataFile.publishsettings -selectedsubscription "Development Subscription"

,其中publishsettings文件從Azure中運行下載從CMD這個腳本。

但我一直得到錯誤信息:

新AzureDeployment:CurrentStorageAccount未設置。使用Set-AzureSubscription子名稱 - CurrentStorageAccount storageaccount來設置它。

它已經確定在片段中。我甚至嘗試複製&將Set-AzureSubscription行粘貼到New-AzureDeployment函數內。沒有運氣。

幫幫我!謝謝!

回答

4

固定。不知道什麼是確切的原因,但我通過執行刪除所有已註冊的湛藍訂閱:

PS> Get-AzureSubscription | ForEach-Object { Remove-AzureSubscription $_.SubscriptionName } 

,並通過執行重新導入訂閱:

PS> Import-AzurePublishSettingsFile xxx.publishsettings 

和它的所有工作! :)

訂閱列表中確實存在一些類似命名的訂閱。可能有衝突,因爲這些天藍色的腳本不知道他們真正想要哪一個。

1

如果您有多個訂閱,那麼您需要確保您要使用的訂閱被設置爲默認。這是可以做到以下幾點:

Select-AzureSubscription -SubscriptionName "{subscriptionName}" -Default 

,如果你不知道你的訂閱的名字是什麼,你可以使用以下方法來查看您的所有訂閱:

Get-AzureSubscription 
+0

非常感謝你爲這個回答!!!它終於有效。 – 2014-10-16 13:07:55