![](/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.