You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Azure Automation Python Runbook中获取作业ID?

在Python Runbook中获取作业ID的方法

在Azure Automation的Python Runbook里,无法像PowerShell那样通过$PSPrivateMetadata.JobId.Guid直接获取作业ID,取而代之的是读取环境变量:

  • 直接读取AZURE_AUTOMATION_JOB_ID环境变量即可获取当前作业的ID,该变量由Azure Automation自动注入到Runbook的运行环境中。

示例代码:

import os

# 获取作业ID
job_id = os.environ.get('AZURE_AUTOMATION_JOB_ID')
# 打印作业ID(可选)
print(f"当前作业ID: {job_id}")

内容的提问来源于stack exchange,提问作者richard

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 08:42:01