【发布时间】:2014-01-30 22:50:27
【问题描述】:
我想使用 PowerShell CmdLets 将 Web 角色部署到 Azure。
我的脚本如下:
$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
当我执行它时会抛出一个错误:
Exception: The subscription named <name-of-subscription> already exists.
我想既然我已经导入了我的发布设置文件,我可以摆脱Set-AzureSubscription。但是,一旦我这样做了,我就会收到下一个错误:
Exception: CurrentStorageAccountName is not set.
Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
这是首先给我错误的行,所以我不确定我需要如何设置 storageaccountname 而不会导致错误。
我还做了一个小测试:
Import-AzurePublishSettingsFile "C:\path-to.publishsettings"
Get-AzureSubscription | Format-Table
执行此操作后,我会得到以下输出(重新格式化):
SubscriptionName: <name-of-subscription>
SubscriptionId: 123456789-123...
ServiceEndpoint: https://man....
ActiveDirectoryEndpoint:
ActiveDirectoryTenantId:
IsDefault: True
Certificate [Subject]
CurrentStorageAccountName
CurrentCloudStorageAccount
ActiveDirectoryUserId
如您所见,CurrentStorageAccountName 为空,但我不知道如何将其设置为正确的值。
我查找了其他一些脚本,但它们似乎都具有这种导入顺序,然后进行设置。知道为什么这不起作用以及如何解决吗?
【问题讨论】:
标签: powershell azure azure-web-roles powershell-cmdlet