[英]How to call C# method in DLL from Runbook in Azure Automation?
Let's say I create a simple C# class: 假设我创建了一个简单的C#类:
public class HelloWorld
{
public static string Start()
{
return "Hello World at " + DateTime.Now.ToLongTimeString();
}
}
Now let's say I compile it into a DLL and want to call the 'Start' method externally. 现在让我说我将它编译成DLL并想在外部调用'Start'方法。 Through trial & error, I discovered how to do that from PowerShell:
通过反复试验,我发现了如何从PowerShell中做到这一点:
[Reflection.Assembly]::LoadFile("c:\code\HelloWorld.dll")
[HelloWorld.HelloWorld]::Start()
Or this way: 或者这样:
Add-Type -Path "c:\code\Helloworld.dll"
[HelloWorld.HelloWorld]::Start()
Both work fine! 两者都很好!
But say I wanted to bundle up this DLL, load it into Azure Automation, and then make a call from a RunBook. 但是说我想捆绑这个DLL,将其加载到Azure Automation中,然后从RunBook进行调用。 How would I do that?
我该怎么办? I have tried several things but keep on getting an error.
我尝试了几件事,但继续犯错误。
Please try the following steps to do this: 请尝试以下步骤来执行此操作:
1) zip the dll file, then click Azure Automation -> ASSETS -> IMPORT MODULES as below screenshot, upload zipped file. 1)压缩dll文件,然后单击Azure Automation - > ASSETS - > IMPORT MODULES如下截图,上传压缩文件。
2) write the test code as below screenshot, we can get the output when we click "TEST" 2)编写测试代码如下截图,我们点击“TEST”时可以得到输出
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.