PowerShell Azure函数-使用内部函数

时间:2020-11-07 13:37:48

标签: powershell azure-functions

我有一个powershell脚本,我没有尝试将其转换为Azure函数。该脚本非常简单,但是使用函数定义-像这样:

function InternalFunction {
    # Do some processing
    ...
}

$someData = ...
$someOtherData = 
...
# now call internal function
InternalFunction $someData
...
InternalFunction $someOtherData

现在,我将此代码放在Azure函数代码的run.ps1中,并且无法抱怨InternalFunction不是已知的cmdlet。具体来说,我在日志中得到了此信息:

Function应用程序可能缺少包含“ InternalFunction”的模块...

那么,有没有办法使用“内部”函数来做到这一点,或者我需要将所有内容重写为一个函数?

1 个答案:

答案 0 :(得分:0)

最好在模块内定义函数,并使用代码上传模块。

您可以通过在functionapps目录的根目录中创建一个Modules文件夹来添加自己的模块,然后在主机启动时将此文件夹附加到$PSModulePath上,以便可以发现您的模块。 / p>

您可以在文件夹结构here

中找到文档