运行 AZ 命令的 Azure Functions [英] Azure Functions Running AZ Commands

查看:23
本文介绍了运行 AZ 命令的 Azure Functions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Powershell 脚本,其中包含我从 Azure 函数运行的 az 命令

I have a Powershell Script that contains az commands which i am running from an Azure Function

我在 requirements.psd1 中指定的模块和主机 json 托管依赖已启用

I have The module specified in requirements.psd1 and host json managed dependency is enabled

在我的脚本中,我输入了以下命令

In my script I have put in the following commands

Get-Module -Name Az -ListAvailable
Import-Module Az

Get Module 在 4.8.0 安装后返回

Get Module comes back as 4.8.0 is installed

然后我收到警告

[Warning] The Function app may be missing a module containing the 'az' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.

后面是实际的命令

az storage account keys list <blah>

[Error] ERROR: 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.

推荐答案

az cli 目前在函数中不可用PowerShell环境.这是一个功能问题,我们正在研究它.

az cli is not available currently out the box in the functions powershell environment. This is a feature ask and we are looking into it.

请参考 GitHub 问题#221.

使用相应的 Azure PowerShell 模块 应该是目前唯一的方法.

Using the corresponding Azure PowerShell Modules shall be the only way to go for now.

您可以使用 Get-AzStorageAccountKey 而不是 az 存储帐户密钥

这篇关于运行 AZ 命令的 Azure Functions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆