【发布时间】:2018-11-22 01:54:51
【问题描述】:
我正在尝试将 az cmdlet 安装到 Kudu 上以用于我的 Azure Function。我目前正在关注本指南:
How to install a PowerShell module in an Azure Function
...但是 - 我的 Azure Function 中仍然出现以下错误:
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
到目前为止我已经完成的步骤:
- 在
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
问题:
- 我的配置中是否存在不允许安装
azcmdlet 的内容? - 是否有其他方法可以在不实现
node模块的情况下访问azure-cli?
【问题讨论】:
-
您链接到的问题是关于 Azure PowerShell cmdlet,而不是 az-cli,它是在 python 上运行的跨平台 cli。我不知道通过 kudu 在 azure app 服务上安装 az-cli 的任何方式。如果你在机器上安装了 python 3.6,你可能可以让它工作,然后手动获取 cli,但我从未尝试过,我不知道它是否会真正运行。
-
我升级并能够运行
python.exe -m pip install azure-cli,但我不确定它保存在哪里... -
您的目标是什么,从 Azure 函数运行 Azure CLI 2 (python) 或从 Azure 函数运行 Azure Powershell Commandlet?如果您的目标是前者,我认为您将在通过 CLI 进行身份验证以实际运行任何命令时遇到问题。
-
@KWilson 我的目标是通过我的 Azure 函数中的
azure-cli进行身份验证,以便与我的 Azure 容器注册表通信 - 将 Docker 容器作为 Azure 实例容器调用。
标签: powershell azure azure-functions azure-cli