【问题标题】:Azure deployment script keeps complaining "CurrentStorageAccount is not set"Azure 部署脚本不断抱怨“未设置 CurrentStorageAccount”
【发布时间】:2013-03-14 06:02:51
【问题描述】:

我想使用 Bamboo(一种持续集成解决方案)进行自动化部署。我在这里(http://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/#script) 找到了一段脚本来提供帮助。主要代码sn -p:

#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" 从 cmd 运行此脚本

,其中发布设置文件是从 Azure 下载的。

但我一直收到错误消息:

New-AzureDeployment:未设置 CurrentStorageAccount。使用 Set-AzureSubscription subname -CurrentStorageAccount storageaccount 进行设置。

它肯定是在sn-p中设置的。我什至尝试将 Set-AzureSubscription 行复制并粘贴到 New-AzureDeployment 函数中。没有运气。

帮帮我!谢谢!

【问题讨论】:

    标签: powershell deployment azure


    【解决方案1】:

    已修复。不知道究竟是什么原因,但我通过执行删除了所有已注册的 azure 订阅:

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

    并通过执行重新导入订阅:

    PS> Import-AzurePublishSettingsFile xxx.publishsettings
    

    这一切都奏效了! :)

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

    【讨论】:

      【解决方案2】:

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

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

      如果您不确定您的订阅名称是什么,您可以使用以下命令查看您的所有订阅:

      Get-AzureSubscription
      

      【讨论】:

        猜你喜欢
        • 2020-06-13
        • 1970-01-01
        • 1970-01-01
        • 2014-08-24
        • 1970-01-01
        • 2016-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多