Deployment Azure script keeps complaining "CurrentStorageAccount not installed"

I want to do an automatic deployment using Bamboo (continuous integration solution). I found here ( http://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/#script ) the script part to help. The main code snippet:

#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." 

First, I tried to run this script from cmd by running 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"

where the publish settings file is downloaded from Azure.

But I kept getting the error message:

New-AzureDeployment: CurrentStorageAccount is not installed. Use Set-AzureSubscription under the name -CurrentStorageAccount storageaccount to install it.

It was definitely installed in the fragment. I even tried to copy and paste the Set-AzureSubscription line inside the New-AzureDeployment function. Bad luck.

Help me! Thanks!

+4
source share
2 answers

Fixed. I don’t know what the reason is, but I deleted all registered subscriptions for cyan printing by doing:

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

and re-import the subscription by doing:

 PS> Import-AzurePublishSettingsFile xxx.publishsettings 

and it worked! :)

There really are similar subscriptions in the list of subscriptions. There may have been conflicts, so the azure scenarios did not know which one they really wanted.

+4
source

If you have multiple subscribers, you need to make sure that the subscription you want to use is set to the default value. This can be done as follows:

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

if you don’t know which subscription name you can use to view all your subscriptions:

 Get-AzureSubscription 
+1
source

Source: https://habr.com/ru/post/1469150/


All Articles