【Azure 应用服务】Azure Powershell Function 出错 The term 'Connect-AzAccount' is not recognized

简介: 【Azure 应用服务】Azure Powershell Function 出错 The term 'Connect-AzAccount' is not recognized

问题描述

在Azure Function中,执行Powershell的Function脚本时,先后出现

1:[Error] ERROR: The term 'Connect-AzAccount' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again

2:[Error] ERROR: The term 'Set-AzApplicationGatewayAutoscaleConfiguration' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again

 

问题解答

以上错误,和在本地执行Powershell命令一样,就是缺少命令对应的Powershell 模块。 只是PowerShell Function的module配置在文件 requirements.psd1 中, 这个文件在创建Powershell Function时候会自动生成在WWWROOT目录下,可以通过Kudu站点(https://<your function app name>.scm.chinacloudsites.cn/),或者是 App Service Editer 页面进行修改。

如下图:

 

而 Connect-AzAccount 对应的module为 az.Accounts,  Set-AzApplicationGatewayAutoscaleConfiguration 对应的module为 Az.Network。

只要把这两个Modul加入到 requirements.psd1文件中后,重启Function App即可(重启的目的是为了让Funciton App所在实例安装 Poweshell Module)。

 

参考资料

Connect-AzAccount : https://learn.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-9.1.0

Set-AzApplicationGatewayAutoscaleConfiguration : https://learn.microsoft.com/en-us/powershell/module/az.network/set-azapplicationgatewayautoscaleconfiguration?view=azps-9.1.0

相关文章
|
17天前
|
C#
【Azure Function】Function App出现System.IO.FileNotFoundException异常
Exception while executing function: xxxxxxx,The type initializer for 'xxxxxx.Storage.Adls2.StoreDataLakeGen2Reading' threw an exception. Could not load file or assembly 'Microsoft.Extensions.Configuration, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the
113 64
|
1月前
|
JSON C# 数据格式
【Azure Function】C#独立工作模式下参数类型 ServiceBusReceivedMessage 无法正常工作
Cannot convert input parameter 'message' to type 'Azure.Messaging.ServiceBus.ServiceBusReceivedMessage' from type 'System.String'.
111 73
|
2天前
|
JavaScript API
【Azure Function】Function App门户上的Test/Run返回错误:Failed to fetch
Running your function in portal requires the app to explicitly accept requests from https://portal.azure.cn. This is known as cross-origin resource sharing (CORS).Configure CORS to add https://portal.azure.cn to allowed origins.
|
1月前
|
Java Windows
【Azure Function】部署Java Function失败:报错deploy [ERROR] Status code 401和警告 'China North 3' may not be a valid region
1:deploy [ERROR] Status code 401, (empty body). 2: China North 3 may not be a valid region,please refer to https://aka.ms/maven_function_configuration#supported-regions for values. 3:  <azure.functions.maven.plugin.version>1.36.0</azure.functions.maven.plugin.version>
38 11
|
3月前
【Azure App Service】PowerShell脚本批量添加IP地址到Web App允许访问IP列表中
Web App取消公网访问后,只允许特定IP能访问Web App。需要写一下段PowerShell脚本,批量添加IP到Web App的允许访问IP列表里!
|
3月前
|
中间件 Docker Python
【Azure Function】FTP上传了Python Function文件后,无法在门户页面加载函数的问题
通过FTP上传Python Function至Azure云后,出现函数列表无法加载的问题。经排查,发现是由于`requirements.txt`中的依赖包未被正确安装。解决方法为:在本地安装依赖包到`.python_packages/lib/site-packages`目录,再将该目录内容上传至云上的`wwwroot`目录,并重启应用。最终成功加载函数列表。
|
4月前
|
Linux Python
【Azure Function】Python Function部署到Azure后报错No module named '_cffi_backend'
ERROR: Error: No module named '_cffi_backend', Cannot find module. Please check the requirements.txt file for the missing module.
110 2
|
4月前
|
数据安全/隐私保护
【Azure Entra ID】使用PowerShell脚本导出Entra ID中指定应用下的所有用户信息
在Azure Entra ID中,需要导出一个Application 下的用户信息, 包含User的创建时间。
|
6月前
|
Python
【Azure Function】发布 Python Function 到 Azure 成功,但是无法显示Function列表
【Azure Function】发布 Python Function 到 Azure 成功,但是无法显示Function列表

热门文章

最新文章