I'm looking for a way to monitor the status of an Azure Automation Python runbook through code, so I can create a function to send alerts using a specific template like this: Azure Automation Runbook Job Alert Subscription: Automation account name: Runbook name: Status: Job ID: CreationTime: Notification time: Detail: msg error, exception ... I tried using os.environ.get to retrieve the job information inside the runbook itself, like this: import os subscription = os.environ.get('AZURE_SUBSCRIPTION_ID') resource_group = os.environ.get('AZURE_RESOURCE_GROUP') automation_account = os.environ.get('AUTOMATION_ACCOUNT_NAME') runbook_name = os.environ.get('AUTOMATION_RUNBOOK_NAME') job_id = os.environ.get('AUTOMATION_JOB_ID') creation_time = os.environ.get('AUTOMATION_JOB_CREATION_TIME') Unfortunately, all these variables return None, even though the information is visible in the Azure Portal after the runbook is executed — and is available in JSON format in the job summary. Has anyone successfully retrieved this metadata programmatically during or right after a runbook's execution? Is there an API or SDK-based workaround for this? Continue reading...