Search code examples
azureazure-powershellazure-automation

Execute Azure Automation Runbooks Across Tenants


I am able to execute Runbooks within my Azure tenant/subscription, but would like to use a single Azure Automation Account in my tenant to execute Runbooks against other tenants and their subscriptions.

I have found this article for running against multiple subscriptions, but is it possible to have a centralized Azure Automation Account in one tenant that can connect and execute against other tenants and their subscriptions?

https://blogs.technet.microsoft.com/knightly/2017/05/26/using-azure-automation-with-multiple-subscriptions/


Solution

  • Based on my knowledge, if your account is a Auzre AD account, it is possible. Also, your account is Microsoft account, you also could create a Azure AD account. More information about how to create a new Azure AD user please refer to this link.

    You could create a credential and store your account and password in it.enter image description here

    You can retrieve the credential in a runbook using the Get-AutomationPSCredential activity and then use it with Add-AzureRmAccount to connect to your Azure subscription. The following commands work for me.

    $cred = Get-AutomationPSCredential –Name "shuitest"
    Add-AzureRmAccount –Credential $cred
    Select-AzureRmSubscription –SubscriptionName "Your Subscription Name"
    

    More information about this, you could refer to this link.

    If you want to login multiple tenants in one runbook, you need to sign in separately and execute your PowerShell cmdlets.