Reputation: 28747
I want to deploy a web role to Azure using the PowerShell CmdLets.
My script is as follows:
$subscription = "<name-of-subscription>"
$service = "<name-of-cloudservice>"
$slot = "staging"
$package = "path\to\package.cspkg"
$configuration = path\to\config.cscfg"
$deploymentLabel = "Deploy to $service"
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"
Import-AzurePublishSettingsFile "C:\path-to.publishsettings"
Set-AzureSubscription -CurrentStorageAccount $service -SubscriptionName $subscription
# some more stuff to check whether to upgrade or to create ...
Set-AzureDeployment -Upgrade -Slot $slot -Package $package -Configuration $configuration -label $deploymentLabel -ServiceName $service -Force
When I execute this it throws an error:
Exception: The subscription named <name-of-subscription> already exists.
I figured that since I'm importing my publishsettings-file already I could get rid of Set-AzureSubscription
. However, once I do that I get the next error:
Exception: CurrentStorageAccountName is not set.
Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
This is the line that gave me the error in the first place, so I'm not sure how I need to set the storageaccountname without causing an error.
I also ran a little test:
Import-AzurePublishSettingsFile "C:\path-to.publishsettings"
Get-AzureSubscription | Format-Table
Once I do this I get the following output (reformatted):
SubscriptionName: <name-of-subscription>
SubscriptionId: 123456789-123...
ServiceEndpoint: https://man....
ActiveDirectoryEndpoint:
ActiveDirectoryTenantId:
IsDefault: True
Certificate [Subject]
CurrentStorageAccountName
CurrentCloudStorageAccount
ActiveDirectoryUserId
As you can see, the CurrentStorageAccountName
is empty, but I don't know how I can set it to a correct value.
I looked up some other scripts, but they all seem to be having this sequence of importing, then setting. Any idea why this is not working and how to solve it?
Upvotes: 0
Views: 1725
Reputation: 28747
I have found out the reason. It appears that you cannot include the subscription name as a named parameter. Changing this line:
Set-AzureSubscription -CurrentStorageAccount $service -SubscriptionName $subscription
to this line did the trick
Set-AzureSubscription $subscription -CurrentStorageAccount $service
Upvotes: 0
Reputation: 10117
You are trying to set CurrentStorageAccount to the name of your cloudservice, but you should be setting it to the name of your blob storage account. Get the list of you storage accounts
PS U:\>Get-AzureStorageAccount |select StorageAccountName
StorageAccountName
------------------
portalvhdsgsomething
storage1
storage2
storage3
then run your previously failing line but with the name of your storage account ie.
Set-AzureSubscription -CurrentStorageAccount storage2 -SubscriptionName $subscription
You can confirm your changes with
PS U:\>Get-AzureSubscription | select CurrentStorageAccount
CurrentStorageAccount : storage2
Upvotes: 1
Reputation: 36342
For Set-AzureSubscription
the MSDN doc shows the -SubscriptionName
parameter as parameter 1, not as named. The error message's suggested fix even implied that you needed to do Set-AzureSubscription <service> -CurrentStorageAccount <storage solution>
Perhaps simply moving that will solve it?
Set-AzureSubscription -SubscriptionName $subscription -CurrentStorageAccount $service
Reference: http://msdn.microsoft.com/en-us/library/dn495189.aspx
Upvotes: 0
Reputation: 327
You need to use -CurrentStorageAccountName as the parameter of Set-AzureSubscription.
Upvotes: 0