我正在尝试将 az
cmdlet 安装到 Kudu 上以用于我的 Azure Function。我目前正在遵循本指南:
How to install a PowerShell module in an Azure Function
...但是 - 我的 Azure 函数中仍然收到以下错误:
az:术语“az”未被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。
在 run.ps1:第 1 行
到目前为止我已完成的步骤:
- 在
D:\home\site\wwwroot\Communication_with_Azure_Container_Registry\>
下创建了一个module
文件夹 在
module
文件夹中,我添加了azure-cli/2.0.35/...
的内容(如下所示):... Azure Function 代码非常简单,可以证明安装 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 的内容? - 是否有其他方法可以在不实现
node
模块的情况下访问azure-cli
?
最佳答案
我解决了您问题的以下部分
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
如果执行
Test-Path -Path 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin'
你可能会得到 False。这意味着您需要安装 Azure CLI,例如 https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest
关于powershell - Azure Function - PowerShell,安装 az cmdlet::术语 'az' 未被识别为 cmdlet 的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50821036/