我想使用 Bamboo(一种持续集成解决方案)进行自动化部署。我在这里(http://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/#script)找到了一段脚本来提供帮助。主要代码片段:
#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_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"
,其中从 Azure 下载 publishsettings 文件。
但我不断收到错误消息:
New-AzureDeployment :未设置 CurrentStorageAccount。使用 Set-AzureSubscription subname -CurrentStorageAccount storageaccount 进行设置。
它肯定已在片段中设置。我什至尝试将 Set-AzureSubscription 行复制并粘贴到 New-AzureDeployment 函数中。没运气。
帮我!谢谢!