0
votes

I'm trying to get an automation script up and running in Windows Azure. I got an error telling the I have to use Select-AzureSubscription. This one is failing with the following error:

    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

So I used Set-AzureSubscription but this one is failing as well. I tried passing the subscription name and the subscription ID.

Did someone managed to properly configure this?

2

2 Answers

3
votes

You need to set up authentication to Azure using Add-AzureAccount. See https://msdn.microsoft.com/en-us/library/azure/dn865019.aspx for more details.

0
votes

Before Selecting subscription you need to add your azure account through any of the methods available. The simplest one is using credentials

$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