0

我正在尝试在 Windows Azure 中启动并运行自动化脚本。我收到一条错误消息,告诉我必须使用 Select-AzureSubscription。这个失败并出现以下错误:

    Error: Select-AzureSubscription : The subscription named 'xxx' cannot be found. Use Set-AzureSubscription to 
initialize the subscription data.
Parameter name: name
At my-script:15 char:15
+ 
    + CategoryInfo          : CloseError: (:) [Select-AzureSubscription], ArgumentException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SelectAzureSubscriptionCommand

所以我使用了 Set-AzureSubscription 但这个也失败了。我尝试传递订阅名称和订阅 ID。

有人设法正确配置了吗?

4

2 回答 2

3

您需要使用 Add-AzureAccount 设置对 Azure 的身份验证。有关详细信息,请参阅https://msdn.microsoft.com/en-us/library/azure/dn865019.aspx 。

于 2015-02-04T01:20:35.893 回答
0

在选择订阅之前,您需要通过任何可用的方法添加您的 Azure 帐户。最简单的一种是使用凭据

$username = "your username"
$password = ConvertTo-SecureString 'yourpassword' –asplaintext –force 
$Cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
<#you can also use Azure assets to store the credential and use it directly like
    $Cred=Get-AutomationPSCredential -Name $AzureAccountCredentialName
#>

Add-AzureAccount -Credential $Cred

#Now select your subscription
于 2015-06-23T08:18:14.750 回答