2016-11-08 32 views
0

我已經在本地系統上安裝了必需的軟件和Azure PowerShell cmdlet。我嘗試通過從Visual Studio代碼終端連接到Azure來執行powershell腳本。以下是錯誤。如何從Visual Studio代碼終端連接到Azure

Import-Module Microsoft.Online.SharePoint.PowerShell 

function PublishToAzure{ 
Add-AzureAccount 
...... 
...... 
} 

錯誤是.. 添加-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 Azure Active Directory模塊的控制檯爲Windows PowerShell屬性 目標是:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "Import-Module MSOnline" 

系統屬性:64位Win7操作系統

回答

1

您可以連接並通過安裝微軟Azure CLI 2.0從VS代碼的終端窗口中管理Azure的資源。 (https://aka.ms/InstallAzureCliWindows)。

將CLI 2.0成功安裝到您的環境中後,將CLI 2.0組件添加到您的環境路徑。

例如,我的環境是Windows 10和VS Code v1.13.0。我成功運行了Windows的CLI 2.0 MSI安裝程序。在我的VS代碼終端會話,我通過這個命令的路徑添加到我的PowerShell環境:

$Env:Path += ';C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin' 

要我Azure訂閱(S)內工作,首先,我通過命令登錄

az login 

關注提示瀏覽到一個URL以完成登錄到您的Azure帳戶並授權CLI會話。有關CLI 2.0命令的其他幫助可以在此鏈接找到,https://aka.ms/cli

我知道這個線程是舊的,我的答案有點晚,但我希望這可以幫助某人。

乾杯, CarnegieJ

相關問題