[英]Can we execute az PowerShell module commands inside of a runspace in a .net console app deployed as a webjob on Azure app service?
我有一個運行在 azure 應用程序服務中的 Web 作業,它使用運行空間來執行 azure powershell 模塊命令。 在本地它工作正常,因為我可以直接使用 Windows powershell 安裝 az 模塊,但是當我將它部署到 Azure 時,它失敗了。
最初我在執行Connect-AzAccount -Identity
時遇到以下錯誤
Connect-AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet
然后我嘗試在運行空間內安裝 az 模塊,但我開始收到另一個錯誤:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
這是我嘗試安裝 az 模塊的方式:
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模塊命令呢?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.