automation account add connection

Copper Contributor

hey , i am new to azure, i am facing a automation issue,

i have success create a runbook and when i run it, it got error, the told me:

Get-AutomationConnection : Connections asset not found. To create this Connections asset, navigate to the Assets blade and create a Connections asset named: AzureRunAsConnection.

so i go to automation account ---> connection --->add a connection (AzureRunAsConnection)

BUT, i am not sure which type i should choose, so i selected "Azure" and it need a AutomationCertificateName, i don't have any certificate on automation account. and it seems can't self sign. so i type AzureRunAsConnection, same with my connection name.

then, run the runbook again, got

Add-AzureRmAccount : Cannot validate argument on parameter 'TenantId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again

i check the runbook powershell, it's seems the AutomationConnection is not work? you can check the attachment which uploaded.

as my analysis, i think it all about the i don't have available "Connection " on the automation account.

how to get it ?????please help



1 Reply

I guess the problem might be that you need to distinguish between login to Azure and remoting to your server. I use below to login to Azure:

$SubscriptionName = Get-AutomationVariable -Name 'VAR-AUTO-SubscriptionName'

$AzureAutomationCredential = Get-AutomationPSCredential -Name 'CRE-AUTO-AutomationUser'
$AzureAccount = Add-AzureRmAccount -Credential $AzureAutomationCredential -SubscriptionName $SubscriptionName

I'm not using Azure Connection Assets but retrieve credentials from Azure Credential Assets and then perform the remoting using that credential - same as you did.