powershell - Azure Function - PowerShell,安装 az cmdlet::术语 'az' 未被识别为 cmdlet 的名称

标签 powershell azure azure-functions azure-cli

我正在尝试将 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/... 的内容(如下所示):enter image description here

    ... 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/

相关文章:

iis - 在 PowerShell 中显示所有站点和绑定(bind)

powershell - 用于更改 "Opens With"属性的 Boxstarter 或 PowerShell 命令

azure - 如何为静态 HTML 后备站点配置 Windows Azure Web 角色实例

azure - 连续的 Azure Web 作业在交换到新插槽后是否会重新启动?

c# - 使用 C# 中的 v4 函数应用从 Azure 表存储获取包含所有数据集的完整表

azure - 无法在 VSCode 中调试 Azure Functions Core Tools

PowerShell - 为整个脚本设置 $ErrorActionPreference

azure - 为什么 CloudConfigurationManager 使用我的 Cloud.cscfg 而不是 Local.cscfg?

azure - 如何限制/停止公共(public)(互联网)访问Azure功能?

windows - 使用 powershell 设置新的 smb 共享时出错