我正在尝试将az
cmdlet安装到Kudu上以用于我的Azure功能。我目前正在遵循本指南:
How to install a PowerShell module in an Azure Function
...但是 - 我的Azure功能中仍然出现以下错误:
az : The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at run.ps1: line 1
到目前为止我已经完成的步骤:
module
D:\home\site\wwwroot\Communication_with_Azure_Container_Registry\>
文件夹
在module
文件夹中我添加了azure-cli/2.0.35/...
的内容(看起来像这样):
... Azure功能代码非常简单,可以证明安装cmdlet的能力:
if (-not (Get-Module -Name "az"))
{
Write-Output "azure-cli not installed";
}
else
{
Write-Output "azure-cli installed";
}
$test = 'az --help'
Invoke-Expression $test
Write-output `n$test
问题:
az
cmdlet的内容? azure-cli
模块的情况下访问node
? 答案 0 :(得分:0)
我自己没有对此进行测试,但根据https://blogs.msdn.microsoft.com/powershell/2017/02/24/using-powershell-modules-in-azure-functions/,您应该可以执行导入模块。在他们的例子中......
Write-Output “Loading Wunderlist Module”
import-module ‘D:\Home\site\wwwroot\HttpTriggerPowerShellDemo\Modules\Wunderlist\1.0.10\Wunderlist.psm1’
$Result = Get-Help Get-WunderlistUser | Out-String
Write-Output $Result
答案 1 :(得分:0)
安装Azure CLI https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
这应该给你az命令
答案 2 :(得分:0)
我解决了您问题的以下部分
az:术语“ az”未被识别为cmdlet,函数,脚本文件或可运行程序的名称。检查名称的拼写,或者是否包含路径,请验证路径是否正确,然后重试。在run.ps1:第1行
如果执行
Test-Path -Path 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin'
您可能会得到False。这意味着您需要安装Azure CLI,例如从https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest