2013-03-14 53 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