相关疑难解决方法(0)

如何在Azure功能中安装PowerShell模块

我需要可以从PS-Gallery获得的AWS模块,但是当我尝试在Azure功能中运行安装步骤时,它不起作用.-verbose参数标志未向控制台写入任何内容.

在Azure功能中获取和使用其他PowerShell模块的正确方法是什么?

功能代码

[Console]::WriteLine("PowerShell Timer trigger function executed at:$(get-date)");
if (-not (Get-Module -Name "AWSPowerShell")) {
[Console]::WriteLine("AWSPowerShell not installed");
Install-Module -Name AWSPowerShell -Scope CurrentUser -ErrorAction Continue -Verbose
}
if (-not (Get-Module -Name "AWSPowerShell")){
[Console]::WriteLine("AWSPowerShell install step failed");
}
Run Code Online (Sandbox Code Playgroud)

功能日志

2016-06-09T11:24:31.108 Function started (Id=e09be687-2e13-4754-942e-eab75c8516e5)
2016-06-09T11:24:32.788 Powershell Timer trigger function executed at:06/09/2016 11:24:32
AWSPowerShell not installed
AWSPowerShell install step failed
2016-06-09T11:24:32.788 Function completed (Success, Id=e09be687-2e13-4754-942e-eab75c8516e5)
Run Code Online (Sandbox Code Playgroud)

更新

根据@travis的回答,我添加了建议的代码,包括nuget包管理器行.这仍然无效.我添加了另一个调试行,发现即使在尝试添加nuget之后也没有模块提供者!

修改后的代码

[Console]::WriteLine("Powershell Timer trigger function executed at:$(get-date)");

Get-PackageProvider -Name nuget -ForceBootstrap

$pkg=Get-PackageProvider -ListAvailable
if …
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-functions

9
推荐指数
1
解决办法
8071
查看次数

标签 统计

azure ×1

azure-functions ×1

powershell ×1