【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term 'Select-Az
  ExOerB7z3frR 2023年11月30日 21 0

问题描述

Azure Web Job执行Powershell脚本报错 

Select-AzContext : The term 'Select-AzContext' 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. 

 

问题解答

根据错误信息,判断是此Web Job执行时,缺失对应的PS模块导致无法正常运行。

针对这种情况,需要通过高级站点(Kudu工具:https://<your app service name>.scm.chinacloudsites.cn/DebugConsole )上传 Az.Accounts 到 \home\site\wwwroot 下

【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term

然后,在修改 $Env:PSModulePath 的路径,在其后面添加上 +“;c:\home\site\wwwroot”, 示例如下:

【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term

但是,请注意,这样的修改为临时性修改。如果App Service的实例重启后,此处修改会丢失。

所以为了是修改长久有效,可以在Web Job的PowerShell脚本中加入这句话。

$Env:PSModulePath =$Env:PSModulePath + "; c:\home\site\wwwroot"

如图:

【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term

 

 

 

[end]

 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月30日 0

暂无评论

推荐阅读
ExOerB7z3frR