我们可以在Azure应用程序服务上部署为WebJob的.NET控制台应用程序中的Runspace内部执行AZ PowerShell模块命令吗?
我有一个在Azure App Service中运行的WebJob,该服务使用Runspace执行Azure PowerShell模块命令。在本地工作正常,因为我可以使用Windows PowerShell直接安装AZ模块,但是当我将其部署到Azure时,它会失败。
最初,当我执行connect -azAccount -Identity
时
Connect-AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet
,
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
我会 遇到关注错误模块:
runSpace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke();
scriptInvoker.Invoke("Install-PackageProvider Nuget -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser");
scriptInvoker.Invoke("Import-PackageProvider Nuget");
scriptInvoker.Invoke("Install-Module Az.Websites -Force -AllowClobber -Scope CurrentUser");
scriptInvoker.Invoke("Import-Module Az.Websites");
scriptInvoker.Invoke("Install-Module Az.Storage -Force -AllowClobber -Scope CurrentUser");
scriptInvoker.Invoke("Import-Module Az.Storage");
那么是否可以在AppService中执行AZ PowerShell模块命令?
I've a webjob running in an azure app service that uses runspace to execute azure powershell module commands. Locally it's working fine because I can install az module directly using Windows powershell but when I deploy it to Azure, it fails.
Initially I was getting following error when I was executing Connect-AzAccount -Identity
Connect-AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet
Then I tried to install az module inside of a runspace and I started getting another error:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Here is how I'm trying to install az module:
runSpace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke();
scriptInvoker.Invoke("Install-PackageProvider Nuget -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser");
scriptInvoker.Invoke("Import-PackageProvider Nuget");
scriptInvoker.Invoke("Install-Module Az.Websites -Force -AllowClobber -Scope CurrentUser");
scriptInvoker.Invoke("Import-Module Az.Websites");
scriptInvoker.Invoke("Install-Module Az.Storage -Force -AllowClobber -Scope CurrentUser");
scriptInvoker.Invoke("Import-Module Az.Storage");
So is it possible to execute az powershell module command in appservice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复1:
解决问题运行以下命令。
当您执行上述命令时,它将提示您获得凭据。
修复2:
通过使用以下powershell cmdlet,
您可以检查工作解决方案来自此处。
还要检查此 so 进行了相关讨论。
Fix 1:
To resolve the issue run the below command.
When you executed the above command, it will prompt you for the credentials.
Fix 2:
By using the below PowerShell cmdlet,
You can check the worked solution from here.
Also check this SO with the related discussions.