简体   繁体   English

Azure Runbook-从单独的Runbook导入命令

[英]Azure Runbooks - Import Commands From Separate Runbook

I have created Runbook A that has some declared variables and some functions. 我创建了Runbook A,它具有一些声明的变量和一些函数。

// Runbook A
$myvar = "test"
Function MyFunc($var1) {
  Write-Output $var1
}

// Runbook B
Write-Output $myvar
MyFunc

How do I import the code from Runbook A into Runbook B so I can make the code in Runbook A reusable? 如何将代码从Runbook A导入到Runbook B,以使Runbook A中的代码可重复使用?

Basically, there is no direct way of doing what you ask for. 基本上,没有直接方法可以满足您的要求。 You cant use runbooks as functions. 您不能将运行手册用作功能。 But you could create your runbooks to be modular and invoke them. 但是您可以将您的运行手册创建为模块化并调用它们。

You don't have to login to Azure to invoke a runbook. 您无需登录到Azure即可调用运行手册。 Webhook looks like a much better option. Webhook看起来是一个更好的选择。

In order to solve this, I created a powershell module .psm1 file. 为了解决这个问题,我创建了一个powershell模块.psm1文件。 It allows me to call the functions, but it's not letting me print the variables. 它允许我调用函数,但不允许我打印变量。 Still working on that. 仍在努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM