The Automation Python Runbook job type runs a published Python runbook (Python 3.10 is the supported runtime) in an Azure Automation account. Each Polysync execution creates one Automation job, polls it to completion, and reads the runbook's result back as output parameters. The runbook is identified by its name — Polysync stores that in the Job's External Id.
This job type is supported on the Azure Automation platform. PowerShell runbooks use the Automation Runbook job type.
export_daily_files). Set
automatically on import.Automation Python Runbook (set automatically on import).Optional job setting:
runOn). Leave it blank to run in the Azure sandbox. To let
each task choose its own group, also add a parameter named Hybrid Worker Group
to the Job: a task value wins over the Job setting and is never passed to the
script.Python runbooks take no named parameters — Azure Automation passes arguments
to the script as sys.argv[1:]. Discovery therefore imports the runbook with no
parameters. Add the arguments on the Job's Parameters tab, in the order the
script reads them.
Polysync passes the job's Input and Input & Output parameters as positional arguments, in the order the parameters are listed on the Job (top to bottom). The parameter names are for you; the script only sees the values:
import sys
source_folder = sys.argv[1] # first parameter on the Job
run_date = sys.argv[2] # second parameter on the Job
Rules:
int(sys.argv[2]),
json.loads(...)).hello world arrives as one argument).say "hi"
arrives as say hi, {"a":1} as {a:1}). To pass JSON, base64-encode it or
use single quotes.Values are stored with the job. Azure Automation keeps each job's input for 30 days and shows it in the portal. Do not pass secrets as arguments.
Print a JSON object as the last line of output:
import json
print(json.dumps({"filesExported": 12, "resultNote": "done"}))
When the job completes, Polysync reads the job's output stream and takes the last line that is a JSON object; earlier lines are ignored. Each top-level property fills the Output or Input & Output parameter of the same name (matched case-insensitively). Child tasks can then map them through task dependencies.
PUT …/automationAccounts/{account}/jobs/{guid}
with the runbook name, the arguments and runOn (the Hybrid Worker Group, or
blank for the Azure sandbox). Azure Automation orders the arguments by their
key, so Polysync keys them 001, 002, … in Job order.GET …/jobs/{guid} and maps the job status exactly as
for the Automation Runbook job
type (Completed → Success, Failed → Failed with the exception text, Stopped →
Cancelled, or Failed when a cloud job reached the three-hour fair-share limit).GET …/jobs/{guid}/output and fills the
output parameters.POST …/jobs/{guid}/stop; the run is Cancelled.The run links to the job in the Azure portal:
https://portal.azure.com/#@/resource/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Automation/automationAccounts/{account}/jobs/{jobId}
| Symptom | Likely cause | Fix |
|---|---|---|
| Runbook … has never been published | The runbook is still a draft | Publish it in Azure Automation |
IndexError: list index out of range in the job's exception |
The script reads more arguments than the Job has parameters | Add the missing parameters on the Job, in order |
| Arguments arrive in the wrong order | The Job's parameters are listed in a different order from the script | Reorder the parameters on the Job |
| JSON argument fails to parse | Azure Automation removed the double quotes | Base64-encode the JSON, or use single quotes |
| Output parameters stay empty | The script did not print a JSON object last, or the names differ | Print json.dumps(...) last; match the parameter names |