Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start-AzAutomationRunbook swallows error returned from service #19823

Open
robpukdf opened this issue Oct 17, 2022 · 3 comments · May be fixed by #26924
Open

Start-AzAutomationRunbook swallows error returned from service #19823

robpukdf opened this issue Oct 17, 2022 · 3 comments · May be fixed by #26924
Labels
Automation bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported good first issue Issues suited for folks who want to help for the first time. Service Attention This issue is responsible by Azure service team.

Comments

@robpukdf
Copy link

robpukdf commented Oct 17, 2022

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

@robpukdf robpukdf added needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 17, 2022
@ghost ghost added customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Oct 17, 2022
@robpukdf
Copy link
Author

I managed to get it to work using this code:

$adminCredential = Get-AutomationPSCredential -Name '[email protected]'
$creds = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $adminCredential.UserName, $adminCredential.Password
$conn = Connect-AzAccount -Credential $creds

$azureContext = Set-AzContext -Tenant -Subscription

Start-AzAutomationRunbook -AutomationAccountName "XXX" -Name "ChildToCallFromParent" -ResourceGroupName "YYY" -DefaultProfile $azureContext -RunOn "DEV-HYB-WORKERS" -Wait -Parameters @{"userDataDiffs"="testString"}

@dingmeng-xue
Copy link
Member

@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.

@dingmeng-xue dingmeng-xue added Automation Service Attention This issue is responsible by Azure service team. bug This issue requires a change to an existing behavior in the product in order to be resolved. good first issue Issues suited for folks who want to help for the first time. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 20, 2022
@ghost
Copy link

ghost commented Oct 20, 2022

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jaspkaur28.

Issue Details

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

Author: robpukdf
Assignees: -
Labels:

Automation, Service Attention, bug, customer-reported, good first issue

Milestone: -

@dingmeng-xue dingmeng-xue changed the title Call Hybrid Worker Runbook from Other Runbook Start-AzAutomationRunbook swallows error returned from service Oct 20, 2022
@divyeshg94 divyeshg94 linked a pull request Dec 23, 2024 that will close this issue
6 tasks
@VeryEarly VeryEarly linked a pull request Dec 24, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automation bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported good first issue Issues suited for folks who want to help for the first time. Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants