如何在基于Powershell的azure函数中安装托管依赖项,例如Powershell模块?

问题描述 投票:0回答:1

在Azure功能应用程序中,我们可以按照requiremnts.psd1文件中提到的默认安装Az模块,如下图所示,通过取消注释,它将安装Az模块

enter image description here

通过遵循相同的过程,我们尝试在函数应用程序中安装 Microsoft.graph 模块,以在脚本中使用 Microsoft graph 命令,并遵循相同的过程,在 requests.psd1 文件中提及它,如下图所示

enter image description here

但是失败了

在需求.psd1文件中尝试了不同的组合,如下所示

例如

@{

# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. 

# To use the Az module in your function app, please uncomment the line below.

Az = '11.*'

Microsoft.Graph = '2.15.0'

}

@{

# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. 

# To use the Az module in your function app, please uncomment the line below.

'Microsoft.Graph' = '2.15.0'

}

但它要么失败要么超时,如下所示

enter image description here

enter image description here

我们发现唯一有效的方法是将文件手动上传到该功能的 D:\home\site\wwwroot\Modules 中,并且命令按预期工作。

但是我们面临的问题是创建一个自动加载 Microsoft 图模块的函数应用程序,类似于我们通过更改requirements.psd1 文件的内容在函数应用程序中安装 Az 模块,而不是通过上传文件手动添加函数应用程序.

**任何人都可以建议为什么它不安装其他模块,而是在requirements.psd1文件中提到时安装Az模块,但只能通过手动上传来工作。**谢谢

azure azure-functions
1个回答
0
投票

尝试安装 Microsoft.Graph 中可用的各个模块,如下所示: 'Microsoft.Graph.Groups' = '1.' 'Microsoft.Graph.Users' = '1.'

这对我有用,如果我没记错的话,我在安装整个 Microsoft.Graph 时尝试了完全相同的操作,但它只是无法安装。

© www.soinside.com 2019 - 2024. All rights reserved.