Azure Startup run book stop working, not sure what happened?

86 Views Asked by At

The following script below worked for awhile, not sure why I keep getting this error:

Select-AzureSubscription : The subscription name Visual Studio Ultimate with MSDN doesn't exist. Parameter name: name

...etc..

Get-AzureVM : No default subscription has been designated. Use Select-AzureSubscription -Default to set the default subscription. At RICSVMStartup:13 char:13

Here's the powerscript:

workflow RICSVMStartup
{
    # Grab the credential to use to authenticate
    $Cred = Get-AutomationPSCredential -Name 'AzureCredential'

    #Connect to Azure
    Add-AzureAccount -Credential $Cred

    #Select the Azure subscription you want to work against
    Select-AzureSubscription -SubscriptionName "Visual Studio Ultimate with MSDN"

    # Get all Azure VMs in the subscription that are not stopped and deallocated and shut down
    inlinescript
    {
        Get-AzureVM | where{$_.status -ne 'Started' -and $_.name -like 'RICS*' -and $_.name -ne 'RICSDC2'} | start-AzureVM 
    }
}
2

There are 2 best solutions below

3
On BEST ANSWER

In brief, you must have a server administrator account and create a AD account, set the new AD Account as co-administrator in SETTING>Administrators, set the new AD account as credential in Automation>ASSET, and run your code: $Cred = Get-AutomationPSCredential -Name 'your new AD account'. The above answer refers to more information links.

0
On

I encounter these errors when using Live Id as the credential to connect to Azure. The solution is to use Azure Active Directory OrgID credential-based authentication, please follow the steps in this blog to create an Azure AD user and then use the OrgId to create the Automation credential asset.

For more information, please refer to this thread https://social.msdn.microsoft.com/Forums/en-US/055f9830-3bf1-48f4-908b-66ddbdfc2d95/authenticate-to-azure-via-addazureaccount-with-live-id?forum=azureautomation