azure - Azure 自动化 - 我们能否将参数从 powershell 主运行手册传递给 python 子进程
问题描述
我面临一个我没有找到解决方案的问题。我试图从我的父母那里执行一个 python 运行手册,它在 powershell 中。
我在我的 powershell runbook 中尝试过的命令列表:
- 开始-AzureRmAutomationRunbook -ResourceGroupName "" -AutomationAccountName "" -Name "" -Parameters $params
- Start-AutomationRunbook -Name "" -Parameters $params
- Start-AzAutomationRunbook -ResourceGroupName "" -AutomationAccountName "" -Name "" - 参数 $params
这是我的变量参数:
- $params = @{"args"="你好"}
如果有人有解决方案,我将不胜感激!我试了一整天都没有成功。
预先感谢您的帮助
解决方案
-Parameters 选项不适用于 Python runbooks 。您可以从另一个 Runbook 中使用 Start-AutomationRunbook 的 -Parameters 选项。
解决方法是使用内部自动化模块 Start-AutomationRunbook而不是外部 Start-AzureRmAutomation 模块。
创建一个名为Start-PythonRunbook的新 Runbook ,如下所示:
Param(
[parameter(Mandatory=$true)] [string]$runbook,
[string]$args
)
Start-AutomationRunbook -Name $runbook -Parameters $args
现在,您可以使用Start-AzureRmAutomationRunbook cmdlet 启动此 Runbook:
Start-AzureRmAutomationRunbook -ResourceGroupName <RGName>
-AutomationAccountName <AAName>
-Name Start-PythonRunbook `
-Parameters @{ "runbook" = "<pythonrunbookname>"; "args" = "arg1 arg2 arg3 arg4 arg5 arg6" }
您可以查看此GitHub 讨论以获取更多信息。
推荐阅读
- c++ - 当为 extern const 分配新值而没有任何错误时,程序将失败。需要对此进行解释
- firebase - 将有天赋的聊天消息发送到 Firestore 时,有没有办法解决反应原生的“遇到两个具有相同密钥的孩子”错误?
- unit-testing - 为什么我的 GNURadio 单元测试在应该失败时却通过了?
- haskell - 使用 Lenses 用来自 IO 的数据填充某些复杂结构的正确方法是什么?
- python - SVC 的 predict_proba 和 decision_function 速度差异
- python - 使用正则表达式替换文件中的单词
- python - 如何将 Pandas 函数条件设置为等于自身偏移 X 记录的一条记录?
- angular - 错误您在预期流的位置提供了“未定义”。您可以提供 Observable、Promise、Array 或 Iterable,在 Cognito 中调用 refreshSession
- json - 如何在 Nim 中解析 JSON(长整数问题)?
- multithreading - 如何以正确的方式从另一个线程渲染到 qt 小部件?