【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term 'Select-AzContext' is not recognized as the name

简介: 【Azure Web Job】Azure Web Job执行Powershell脚本报错 The term 'Select-AzContext' is not recognized as the name

问题描述

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 下

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

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

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

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

如图:

 

 

 

[end]

相关文章
|
20天前
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
|
20天前
|
存储 C# Python
【Azure Storage Account】Azure 存储服务计算Blob的数量和大小的PowerShell代码
【Azure Storage Account】Azure 存储服务计算Blob的数量和大小的PowerShell代码
|
20天前
|
Ubuntu Linux 测试技术
【Azure Function App】Python Function调用Powershell脚本在Azure上执行失败的案例
【Azure Function App】Python Function调用Powershell脚本在Azure上执行失败的案例
|
20天前
|
Shell PHP Windows
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
|
13天前
|
数据库 开发者 Python
web应用开发
【9月更文挑战第1天】web应用开发
33 1
|
1天前
|
数据可视化 图形学 UED
只需四步,轻松开发三维模型Web应用
为了让用户更方便地应用三维模型,阿里云DataV提供了一套完整的三维模型Web模型开发方案,包括三维模型托管、应用开发、交互开发、应用分发等完整功能。只需69.3元/年,就能体验三维模型Web应用开发功能!
18 8
只需四步,轻松开发三维模型Web应用
|
10天前
|
数据采集 Java 数据挖掘
Java IO异常处理:在Web爬虫开发中的实践
Java IO异常处理:在Web爬虫开发中的实践
|
11天前
|
前端开发 JavaScript 持续交付
Web应用开发的方法
Web应用开发的方法
13 1
|
11天前
|
前端开发 JavaScript 持续交付
web应用开发
web应用开发
22 1