Open robpukdf opened 2 years ago
I managed to get it to work using this code:
$adminCredential = Get-AutomationPSCredential -Name 'test@test.com' $creds = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $adminCredential.UserName, $adminCredential.Password $conn = Connect-AzAccount -Credential $creds
$azureContext = Set-AzContext -Tenant
Start-AzAutomationRunbook -AutomationAccountName "XXX" -Name "ChildToCallFromParent" -ResourceGroupName "YYY" -DefaultProfile $azureContext -RunOn "DEV-HYB-WORKERS" -Wait -Parameters @{"userDataDiffs"="testString"}
@robpukdf , Azure PowerShell establishes multiple contexts if user can access to multiple subscriptions. According to your script and error, it seems target automation account is not in default subscription. You need to either switch context using Set-AzContext
or just login to target subscription via Connect-AzAccount -Tenant <> -Subscription <>
The error message is client side problem. I believe service returns 404 error. It should not be swallowed. I include owner team to fix it.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jaspkaur28.
Author: | robpukdf |
---|---|
Assignees: | - |
Labels: | `Automation`, `Service Attention`, `bug`, `customer-reported`, `good first issue` |
Milestone: | - |
Description
I am trying to call an Azure Automation Hybrid Worker Runbook from another Azure Automation Runbook, but I keep receiving a null reference error. To start, I was just trying to call one Runbook from another:
Parent:
Start-AzAutomationRunbook -AutomationAccountName "XXX" -Name "ChildToCallFromParent" -ResourceGroupName "YYY" -Parameters @{"userDataDiffs"="testString"}
Child:
param ( [string] $userDataDiffs )
Write-Output $userDataDiffs
Output:
Start-AzAutomationRunbook : Object reference not set to an instance of an object. At line:29 char:1 + Start-AzAutomationRunbook -AutomationAccountName "XXX" ... +
Anyone have any guidance on this please?
Script or Debug output
No response
Environment data
No response
Module versions
No response
Error output
No response