![](/img/trans.png)
[英]Visual Studio Code PowerShell code debugging from the terminal
[英]How to Connect to Azure from Visual Studio Code Terminal
我已經在本地系統上安裝了必需的軟件和Azure PowerShell cmdlet。 我試圖通過從Visual Studio Code Terminal連接到Azure來執行Powershell腳本。 下面是錯誤。
Import-Module Microsoft.Online.SharePoint.PowerShell
function PublishToAzure{
Add-AzureAccount
......
......
}
錯誤是.. Add-AzureAccount:句柄無效
Visual Studio代碼設置:
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
}
用於Windows PowerShell屬性目標的Windows Azure Active Directory模塊的控制台是:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "Import-Module MSOnline"
系統屬性:64位Win7 OS
您可以通過安裝Microsoft Azure CLI 2.0在VS Code的終端窗口中連接和管理Azure資源。 ( https://aka.ms/InstallAzureCliWindows )。
在您的環境中成功安裝CLI 2.0之后,請將CLI 2.0組件添加到您的環境路徑中。
例如,我的環境是Windows 10和VS Code v1.13.0。 我已成功運行Windows的CLI 2.0 MSI安裝程序。 在我的VS Code終端會話中,我通過以下命令將路徑添加到PowerShell環境:
$Env:Path += ';C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin'
要在我的Azure訂閱中工作,首先我通過命令登錄
az login
按照提示瀏覽至URL,以完成對Azure帳戶的登錄並授權CLI會話。 可以在以下鏈接中找到有關CLI 2.0命令的其他幫助:https://aka.ms/cli
我知道這個主題很舊,我的回答有點晚了,但是我希望這對某人有幫助。
卡內基,干杯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.