【问题标题】:How to Connect to Azure from Visual Studio Code Terminal如何从 Visual Studio Code 终端连接到 Azure
【发布时间】:2016-11-08 10:22:47
【问题描述】:

我已在本地系统上安装了所需的软件和 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 Azure Active Directory Module for Windows PowerShell 属性的控制台 目标是:

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

系统属性:64位Win7操作系统

【问题讨论】:

    标签: powershell azure visual-studio-code


    【解决方案1】:

    您可以通过安装 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

    我知道这个帖子很旧,我的回答有点晚了,但我希望这对某人有所帮助。

    干杯, 卡内基J

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-14
      • 2015-07-21
      • 2018-07-20
      • 1970-01-01
      • 2021-08-09
      相关资源
      最近更新 更多