Powershell Azure部署脚本一直在抱怨”;CurrentStorageAccount未设置";

Powershell Azure部署脚本一直在抱怨”;CurrentStorageAccount未设置";,powershell,deployment,azure,Powershell,Deployment,Azure,我想用Bambol(一个持续集成解决方案)进行自动化部署。我在这里()找到了一段脚本。主要代码段: #configure powershell with Azure 1.7 modules Import-Module Azure #configure powershell with publishsettings for your subscription $pubsettings = $subscriptionDataFile Import-AzurePublishSettingsFile

我想用Bambol(一个持续集成解决方案)进行自动化部署。我在这里()找到了一段脚本。主要代码段:

#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."
我刚开始尝试从cmd运行此脚本,方法是执行powershell E:\CI\OCZDeployment\publish\u cloud\u 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下载的

但我一直收到错误信息:

新AzureDeployment:未设置CurrentStorageAccount。使用Set-AzureSubscription子名称-CurrentStorageAccount-storageaccount进行设置

它肯定是在代码段中设置的。我甚至尝试将Set-AzureSubscription行复制并粘贴到新的AzureDeployment函数中。不走运


救救我!谢谢大家!

固定。不知道确切原因是什么,但我通过执行以下操作删除了所有已注册的azure订阅:

PS> Get-AzureSubscription | ForEach-Object { Remove-AzureSubscription $_.SubscriptionName }
PS> Import-AzurePublishSettingsFile xxx.publishsettings
并通过执行以下操作重新导入订阅:

PS> Get-AzureSubscription | ForEach-Object { Remove-AzureSubscription $_.SubscriptionName }
PS> Import-AzurePublishSettingsFile xxx.publishsettings
这一切都成功了!:)


订阅列表中确实有一些名称类似的订阅。可能存在冲突,因为azure脚本不知道他们真正想要的是哪一个。

如果您有多个订阅,则需要确保将要使用的订阅设置为默认订阅。这可以通过以下方式完成:

Select-AzureSubscription -SubscriptionName "{subscriptionName}" -Default
如果您不确定订阅名称,可以使用以下内容查看所有订阅:

Get-AzureSubscription