使用用于 Visual Studio Code 的 Azure HDInsight 工具Use Azure HDInsight Tools for Visual Studio Code

了解如何使用 Visual Studio Code 的 Azure HDInsight 工具,为 Apache Spark 创建和提交 Apache Hive 批处理作业、交互式 Hive 查询和 PySpark 脚本。Learn how to use Azure HDInsight Tools for Visual Studio Code to create and submit Apache Hive batch jobs, interactive Hive queries, and PySpark scripts for Apache Spark. 本文首先介绍如何在 Visual Studio Code 中安装 HDInsight 工具,然后演练如何向 Hive 和 Spark 提交作业。First we'll describe how to install the HDInsight tools in Visual Studio Code and then we'll walk through how to submit jobs to Hive and Spark.

可以在 Visual Studio Code 支持的平台(包括 Windows、Linux 和 macOS)上安装 Azure HDInsight 工具。Azure HDInsight Tools can be installed on platforms that are supported by Visual Studio Code, which include Windows, Linux, and macOS. 可以在下面找到不同平台的必备组件。Below you'll find the prerequisites for different platforms.

先决条件Prerequisites

完成本文中的步骤需要具有以下项:The following items are required for completing the steps in this article:

安装 Azure HDInsight 工具Install Azure HDInsight Tools

满足先决条件后,可以安装 Visual Studio Code 的 Azure HDInsight 工具。After you have completed the prerequisites, you can install Azure HDInsight Tools for Visual Studio Code. 完成以下步骤来安装 Azure HDInsight 工具:Complete the following steps to install Azure HDInsight Tools:

  1. 打开 Visual Studio Code。Open Visual Studio Code.

  2. 在菜单栏中,导航到“视图” > “扩展”。 From the menu bar, navigate to View > Extensions.

  3. 在搜索框中输入 HDInsightIn the search box, enter HDInsight.

  4. 从搜索结果中选择“Azure HDInsight 工具”,然后选择“安装”。 Select Azure HDInsight Tools from the search results, and then select Install.

    用于 Visual Studio Code 的 HDInsight - Python 安装

  5. 选择“重载”以激活安装的“Azure HDInsight 工具”扩展。 Select Reload to activate the Azure HDInsight Tools extension after it installs.

打开 HDInsight 工作文件夹Open HDInsight work folder

完成以下步骤打开工作文件夹,并在 Visual Studio Code 中创建一个文件:Complete the following steps to open a work folder, and create a file in Visual Studio Code:

  1. 在菜单栏中,导航到“文件” > “打开文件夹...” > “C:\HD\HDexample”,然后选择“选择文件夹”按钮。 From the menu bar, navigate to File > Open Folder... > C:\HD\HDexample, then select the Select Folder button. 该文件夹将显示在左侧的“资源管理器”视图中。 The folder appears in the Explorer view on the left.

  2. 在“资源管理器”视图中选择文件夹“HDexample”,然后选择工作文件夹旁边的“新建文件”图标。 From the Explorer view, select the folder, HDexample, and then the New File icon next to the work folder.

    新建文件

  3. 为新文件命名,以 .hql(Hive 查询)或 .py(Spark 脚本)作为文件扩展名。Name the new file with either the .hql (Hive queries) or the .py (Spark script) file extension. 本示例使用 HelloWorld.hqlThis example uses HelloWorld.hql.

设置 Azure 环境Set the Azure environment

  1. 连接到 Azure 帐户或链接某个群集(如果尚未这样做)。Connect to your Azure account or link a cluster if you haven't yet done so.

  2. 在菜单栏中,导航到“视图” > “命令面板...”,然后输入 **HDInsight: ** 设置 Azure 环境”。From the menu bar navigate to View > Command Palette..., and enter HDInsight: Set Azure Environment.

  3. 选择一个环境作为默认登录入口。Select an environment as your default login entry.

  4. 同时,工具已将你的默认登录入口保存到 .VSCode\settings.json 中。Meanwhile, the tool has already saved your default login entry in .VSCode\settings.json. 还可以在此配置文件中直接更新默认登录入口。You can also directly update it in this configuration file.

    设置默认登录入口配置

连接到 Azure 帐户Connect to Azure account

将脚本从 Visual Studio Code 提交到 HDInsight 群集之前,需要连接到 Azure 帐户,或链接群集(使用 Ambari 用户名/密码)。Before you can submit scripts to HDInsight clusters from Visual Studio Code, you need to either connect to your Azure account, or link a cluster (using Ambari username/password). 完成以下步骤以连接到 Azure:Complete the following steps to connect to Azure:

  1. 在菜单栏中,导航到“视图” > “命令面板...”,然后输入 **HDInsight: ** Login”。From the menu bar navigate to View > Command Palette..., and enter HDInsight: Login.

    用于 Visual Studio Code 的 HDInsight 工具 - 登录

  2. 遵照“输出”窗格中的登录说明操作。 Follow the sign-in instructions in the OUTPUT pane.

    针对其他环境的登录说明

    连接后,Visual Studio Code 窗口左下角的状态栏上会显示 Azure 帐户名称。After you're connected, your Azure account name is shown on the status bar at the bottom left of the Visual Studio Code window.

可以使用 Apache Ambari 管理的用户名链接标准群集。You can link a normal cluster by using an Apache Ambari managed username.

  1. 在菜单栏中,导航到“视图” > “命令面板...”,然后输入 HDInsight: Link a Cluster”。From the menu bar navigate to View > Command Palette..., and enter HDInsight: Link a Cluster.

    链接群集命令

  2. 选择链接的群集类型“Azure HDInsight”。 Select linked cluster type Azure HDInsight.

  3. 输入 HDInsight 群集 URL。Enter HDInsight cluster URL.

  4. 输入 Ambari 用户名,默认为 adminEnter Ambari user name, default is admin.

  5. 输入 Ambari 密码。Enter Ambari password.

  6. 选择群集类型。Select cluster type.

  7. 查看“输出”视图以进行验证。 Review OUTPUT view for verification.

    Note

    如果群集已登录到 Azure 订阅中并且已链接群集,则使用链接用户名和密码。The linked username and password are used if the cluster both logged in Azure subscription and Linked a cluster.

  1. 在菜单栏中,导航到“视图” > “命令面板...”,然后输入 HDInsight: Link a Cluster”。From the menu bar navigate to View > Command Palette..., and enter HDInsight: Link a Cluster.

  2. 选择链接的群集类型“通用 Livy 终结点”。 Select linked cluster type Generic Livy Endpoint.

  3. 输入通用 Livy 终结点,例如 http://10.172.41.42:18080。Enter the generic Livy endpoint, for example: http://10.172.41.42:18080.

  4. 选择授权类型“基本”或“无”。 Select authorization type Basic or None. 如果选择“基本”,则: If Basic, then:
     a. a. 输入 Ambari 用户名,默认为 adminEnter Ambari user name, default is admin.
     b. b. 输入 Ambari 密码。Enter Ambari password.

  5. 查看“输出”视图以进行验证。 Review OUTPUT view for verification.

列出 HDInsight 群集List HDInsight clusters

  1. 在菜单栏中,导航到“视图” > “命令面板...”,然后输入 HDInsight: List ClusterFrom the menu bar navigate to View > Command Palette..., and enter HDInsight: List Cluster.

  2. 选择所需的订阅。Select the desired subscription.

  3. 查看“输出”视图。 Review the OUTPUT view. 该视图将显示链接的群集,以及 Azure 订阅下的所有群集。The view will show your linked cluster(s) and all cluster(s) under your Azure subscription.

    设置默认群集配置

设置默认群集Set default cluster

  1. 重新打开前面创建的文件夹 HDexample(如果已关闭)。Re-Open the folder HDexample created earlier if closed.

  2. 选择前面创建的文件 HelloWorld.hql,它将在脚本编辑器中打开。Select the file HelloWorld.hql created earlier and it will open in the script editor.

  3. 右键单击脚本编辑器并选择“HDInsight: 设置默认群集”。Right-click the script editor, and select HDInsight: Set Default Cluster.

  4. 连接到 Azure 帐户或链接某个群集(如果尚未这样做)。Connect to your Azure account or link a cluster if you haven't yet done so.

  5. 选择一个群集作为当前脚本文件的默认群集。Select a cluster as the default cluster for the current script file. 工具将自动更新配置文件 .VSCode\settings.jsonThe tools automatically update the configuration file .VSCode\settings.json.

    设置默认群集配置

提交交互式 Hive 查询、Hive 批处理脚本Submit interactive Hive queries, Hive batch scripts

通过 Visual Studio Code 的 HDInsight 工具,可将交互式 Hive 查询和 Hive 批处理脚本提交到 HDInsight 群集。With HDInsight Tools for Visual Studio Code, you can submit interactive Hive queries, and Hive batch scripts to HDInsight clusters.

  1. 重新打开前面创建的文件夹 HDexample(如果已关闭)。Reopen the folder HDexample created earlier if closed.

  2. 选择前面创建的文件 HelloWorld.hql,它将在脚本编辑器中打开。Select the file HelloWorld.hql created earlier and it will open in the script editor.

  3. 将以下代码复制并粘贴到 Hive 文件中,然后保存该文件。Copy and paste the following code into your Hive file, and then save it.

    SELECT * FROM hivesampletable;
    
  4. 连接到 Azure 帐户或链接某个群集(如果尚未这样做)。Connect to your Azure account or link a cluster if you haven't yet done so.

  5. 右键单击脚本编辑器,选择“HDInsight: Hive Interactive”提交查询,或使用快捷方式 Ctrl + Alt + I 。选择“HDInsight: Hive Batch”以提交脚本,或使用快捷键 Ctrl + Alt + H 。Right-click the script editor, select HDInsight: Hive Interactive to submit the query, or use shortcut Ctrl + Alt + I. Select HDInsight: Hive Batch to submit the script, or use shortcut Ctrl + Alt + H.

  6. 如果尚未指定默认群集,请选择群集。Select the cluster if you haven't specified a default cluster. 工具还允许使用上下文菜单提交代码块而非整个脚本文件。The tools also allow you to submit a block of code instead of the whole script file using the context menu. 不久之后,查询结果将显示在新选项卡中。After a few moments, the query results appear in a new tab.

    交互式 Hive 结果

    • “结果” 面板:可以将整个结果作为 CSV、JSON、Excel 保存到本地路径,也可以只选择多个行。RESULTS panel: You can save the whole result as CSV, JSON, or Excel file to local path, or just select multiple lines.

    • “消息” 面板:选择“行” 号会跳转到运行的脚本的第一行。MESSAGES panel: When you select Line number, it jumps to the first line of the running script.

提交交互式 PySpark 查询Submit interactive PySpark queries

可遵循以下步骤提交交互式 PySpark 查询:You can submit interactive PySpark queries by following the steps below:

  1. 重新打开前面创建的文件夹 HDexample(如果已关闭)。Reopen the folder HDexample created earlier if closed.

  2. 遵循前面所述的步骤创建新文件 HelloWorld.pyCreate a new file HelloWorld.py following the earlier steps.

  3. 将以下代码复制并粘贴到脚本文件中:Copy and paste the following code into the script file:

    from operator import add
    lines = spark.read.text("/HdiSamples/HdiSamples/FoodInspectionData/README").rdd.map(lambda r: r[0])
    counters = lines.flatMap(lambda x: x.split(' ')) \
                 .map(lambda x: (x, 1)) \
                 .reduceByKey(add)
    
    coll = counters.collect()
    sortedCollection = sorted(coll, key = lambda r: r[1], reverse = True)
    
    for i in range(0, 5):
         print(sortedCollection[i])
    
  4. 连接到 Azure 帐户或链接某个群集(如果尚未这样做)。Connect to your Azure account or link a cluster if you haven't yet done so.

  5. 选择所有代码,右键单击脚本编辑器并选择“HDInsight: PySpark Interactive”提交查询,或使用快捷键 Ctrl + Alt + IChoose all the code and right-click the script editor, select HDInsight: PySpark Interactive to submit the query, or use shortcut Ctrl + Alt + I.

    pyspark interactive - 右键单击

  6. 如果尚未指定默认群集,请选择群集。Select the cluster if you haven't specified a default cluster. 不久之后,新选项卡中会显示“Python Interactive 结果”。 工具还允许使用上下文菜单提交代码块而非整个脚本文件。After a few moments, the Python Interactive results appear in a new tab. The tools also allow you to submit a block of code instead of the whole script file using the context menu.

    pyspark interactive - python interactive 窗口

  7. 输入 "%%info" ,然后按 Shift + Enter 查看作业信息。Enter "%%info", and then press Shift + Enter to view job information. (可选)(Optional)

    查看作业信息

  8. 工具还支持 Spark SQL 查询。The tool also supports the Spark SQL query.

    Pyspark Interactive - 查看结果

    运行查询时,提交状态将显示在底部状态栏的左侧。The submission status appears on the left of the bottom status bar when you're running queries. 当状态为“PySpark 内核(忙)”时,请不要提交其他查询。 Don't submit other queries when the status is PySpark Kernel (busy).

    Note

    如果设置中的“已启用 Python 扩展”处于未选中状态(默认设置已选中),则提交的 pyspark 交互结果将使用旧窗口。 When Python Extension Enabled is unchecked in the settings (The default setting is checked), the submitted pyspark interaction results will use the old window.

    已禁用 pyspark interactive python 扩展

提交 PySpark 批处理作业Submit PySpark batch job

  1. 重新打开前面创建的文件夹 HDexample(如果已关闭)。Reopen the folder HDexample created earlier if closed.

  2. 遵循前面所述的步骤创建新文件 BatchFile.pyCreate a new file BatchFile.py following the earlier steps.

  3. 将以下代码复制并粘贴到脚本文件中:Copy and paste the following code into the script file:

    from __future__ import print_function
    import sys
    from operator import add
    from pyspark.sql import SparkSession
    if __name__ == "__main__":
        spark = SparkSession\
            .builder\
            .appName("PythonWordCount")\
            .getOrCreate()
    
        lines = spark.read.text('/HdiSamples/HdiSamples/SensorSampleData/hvac/HVAC.csv').rdd.map(lambda r: r[0])
        counts = lines.flatMap(lambda x: x.split(' '))\
                    .map(lambda x: (x, 1))\
                    .reduceByKey(add)
        output = counts.collect()
        for (word, count) in output:
            print("%s: %i" % (word, count))
        spark.stop()
    
  4. 连接到 Azure 帐户或链接某个群集(如果尚未这样做)。Connect to your Azure account or link a cluster if you haven't yet done so.

  5. 右键单击脚本编辑器,然后选择 “HDInsight:** PySpark 批处理”,或使用快捷键 Ctrl + Alt + H 。Right-click the script editor, and then select HDInsight: PySpark Batch, or use shortcut Ctrl + Alt + H.

  6. 选择要将 PySpark 作业提交到的群集。Select a cluster to which to submit your PySpark job.

    提交 python 作业结果

提交 Python 作业后,提交日志会显示在 Visual Studio Code 的“输出”窗口中。 After you submit a Python job, submission logs appear in the OUTPUT window in Visual Studio Code. 同时还会显示 Spark UI URLYarn UI URLThe Spark UI URL and Yarn UI URL are shown as well. 可以在 Web 浏览器中打开 URL 来跟踪作业状态。You can open the URL in a web browser to track the job status.

Apache Livy 配置Apache Livy configuration

支持 Apache Livy 配置,可在工作空间文件夹中的 .VSCode\settings.json 内设置此配置。Apache Livy configuration is supported, it can be set at the .VSCode\settings.json in the work space folder. 目前,livy 配置仅支持 Python 脚本。Currently, livy configuration only supports Python script. 详细信息请参阅 Livy READMEMore details, see Livy README.

如何触发 livy 配置How to trigger livy configuration

方法 1Method 1

  1. 在菜单栏中,导航到“文件” > “首选项” > “设置”。 From the menu bar, navigate to File > Preferences > Settings.
  2. 在“搜索设置”文本框中,输入“HDInsight Job Sumission: Livy Conf”。In the Search settings text box enter HDInsight Job Sumission: Livy Conf.
  3. 在相关搜索结果中选择“在 settings.json 中编辑”。 Select Edit in settings.json for the relevant search result.

方法 2Method 2
提交一个文件,然后观察 .vscode 文件夹是否已自动添加到工作文件夹。Submit a file, notice the .vscode folder is added automatically to the work folder. 可以通过单击 .vscode\settings.json 来查找 livy 配置。You can find the livy configuration by clicking .vscode\settings.json.

  • 项目设置:The project settings:

    Livy 配置

Note

对于 driverMomoryexecutorMomry 设置,请设置带单位的值,例如 1g 或 1024m。For settings driverMomory and executorMomry, set the value with unit, for example 1g or 1024m.

  • 支持的 Livy 配置:The supported Livy configurations:

    POST /batches POST /batches
    请求正文Request Body

    namename 说明description typetype
    filefile 包含要执行的应用程序的文件File containing the application to execute path(必需)path (required)
    proxyUserproxyUser 运行作业时要模拟的用户User to impersonate when running the job stringstring
    classNameclassName 应用程序 Java/Spark main 类Application Java/Spark main class stringstring
    argsargs 应用程序的命令行参数Command line arguments for the application 字符串列表list of strings
    jarsjars 此会话中要使用的 jarsjars to be used in this session 字符串列表List of string
    pyFilespyFiles 此会话中要使用的 Python 文件Python files to be used in this session 字符串列表List of string
    文件files 此会话中要使用的文件files to be used in this session 字符串列表List of string
    driverMemorydriverMemory 要用于驱动程序进程的内存量Amount of memory to use for the driver process stringstring
    driverCoresdriverCores 要用于驱动程序进程的内核数Number of cores to use for the driver process intint
    executorMemoryexecutorMemory 每个执行程序进程要使用的内存量Amount of memory to use per executor process stringstring
    executorCoresexecutorCores 用于每个执行程序的内核数Number of cores to use for each executor intint
    numExecutorsnumExecutors 为此会话启动的执行程序数量Number of executors to launch for this session intint
    archivesarchives 此会话中要使用的存档Archives to be used in this session 字符串列表List of string
    队列queue 要提交的 YARN 队列的名称The name of the YARN queue to which submitted stringstring
    namename 此会话的名称The name of this session stringstring
    confconf Spark 配置属性Spark configuration properties key=val 的映射Map of key=val

    响应正文Response Body
    创建的批处理对象。The created Batch object.

    namename 说明description typetype
    idid 会话 idThe session id intint
    appIdappId 此会话的应用程序 idThe application id of this session StringString
    appInfoappInfo 应用程序详细信息The detailed application info key=val 的映射Map of key=val
    loglog 日志行The log lines 字符串列表list of strings
    statestate 批处理状态The batch state stringstring

Note

当提交脚本时,已分配的 livy 配置将显示在输出窗格中。The assigned livy config will display in output pane when submit script.

通过资源管理器与 Azure HDInsight 集成Integrate with Azure HDInsight from Explorer

Azure HDInsight 已添加到“资源管理器”视图中。Azure HDInsight has been added to the Explorer view. 可以直接通过 Azure HDInsight 浏览和管理群集。You can browse and manage you cluster(s) directly through Azure HDInsight.

  1. 连接到 Azure 帐户或链接某个群集(如果尚未这样做)。Connect to your Azure account or link a cluster if you haven't yet done so.

  2. 在菜单栏中,导航到“视图” > “资源管理器”。 From the menu bar, navigate to View > Explorer.

  3. 在左窗格中,展开“AZURE HDINSIGHT”。 From the left pane, expand AZURE HDINSIGHT. 将列出可用的订阅和群集(支持 Spark、Hadoop 和 HBase)。The available subscriptions and clusters (Spark, Hadoop, and HBase are supported) will be listed.

    Azure HDInsight 订阅

  4. 展开群集以查看 hive 元数据数据库和表架构。Expand the cluster to view hive metadata database and table schema.

    Azure HDInsight 群集

预览 Hive 表Preview Hive Table

可以通过 Azure HDInsight 资源管理器直接在群集中预览 Hive 表。You can preview Hive Table in your cluster(s) directly through Azure HDInsight explorer.

  1. 连接到 Azure 帐户(如果尚未这样做)。Connect to your Azure account if you haven't yet done so.

  2. 单击最左侧列中的“Azure”图标。 Click Azure icon from leftmost column.

  3. 在左窗格中,展开“AZURE HDINSIGHT”。From the left pane, expand AZURE HDINSIGHT. 此时会列出可用的订阅和群集。The available subscriptions and clusters will be listed.

  4. 展开群集以查看 hive 元数据数据库和表架构。Expand the cluster to view hive metadata database and table schema.

  5. 右键单击 Hive 表,例如 hivesampletable。Right-click on the Hive Table, e.g hivesampletable. 选择“预览”。 Select Preview.

    HDInsight for vscode - 预览 hive 表

  6. 此时会打开“预览结果”窗口。 The Preview Results window will be opened.

    HDInsight for vscode - 预览结果窗口

  • “结果”面板 RESULTS panel

    可以将整个结果作为 CSV、JSON、Excel 保存到本地路径,也可以只选择多个行。You can save the whole result as CSV, JSON, or Excel file to local path, or just select multiple lines.

  • “消息”面板 MESSAGES panel

    1. 如果表中的行数大于 100,消息将显示:“显示了 Hive 表的前 100 行”。 When the number of rows in the table is greater than 100 rows, the message shows: The first 100 rows are displayed for Hive table.
    2. 如果表中的行数小于或等于 100,消息将显示:“显示了 Hive 表的 60 行”。 When the number of rows in the table is less than or equal to 100 rows, the message shows: 60 rows are displayed for Hive table.
    3. 如果表中没有任何内容,消息将显示:“显示了 Hive 表的 0 行”。 When there is no content in the table, the message shows: 0 row is displayed for Hive table.

Note

在 Linux 中,安装 xclip 用于复制表数据。In Linux, install xclip to enable copy table data.

linux 中的 HDInsight for vscode

其他功能Additional features

Visual Studio Code 的 HDInsight 支持以下功能:HDInsight for Visual Studio Code supports the following features:

  • IntelliSense 自动完成IntelliSense autocomplete. 弹出关键字、方法、变量等相关建议。Suggestions pop up for keyword, methods, variables, and so on. 不同图标表示不同类型的对象。Different icons represent different types of objects.

    用于 Visual Studio Code 的 HDInsight 工具 IntelliSense 对象类型

  • IntelliSense 错误标记IntelliSense error marker. 语言服务会为 Hive 脚本的编辑错误添加下划线。The language service underlines the editing errors for the Hive script.

  • 语法突出显示Syntax highlights. 语言服务使用不同颜色来区分变量、关键字、数据类型、函数等等。The language service uses different colors to differentiate variables, keywords, data type, functions, and so on.

    用于 Visual Studio Code 的 HDInsight 工具语法突出显示

仅限读取者角色Reader Only Role

具有群集“仅限读取者”角色的用户不再可以将作业提交到 HDInsight 群集,也不可以查看 Hive 数据库。 Users with cluster Reader only role can no longer submit job to the HDInsight cluster nor view the Hive database. 需要在 Azure 门户中联系群集管理员将你的角色升级到“HDInsight 群集操作员”。 You need to contact the cluster administrator to upgrade your role to HDInsight Cluster Operator in the Azure portal. 如果你知道 Ambari 凭据,可遵照以下说明手动链接群集。If you know Ambari credentials, you can manually link the cluster following the instruction below.

浏览 HDInsight 群集Browse HDInsight Cluster

单击 Azure HDInsight 资源管理器展开 HDInsight 群集时,如果你对群集拥有“仅限读取者”角色,系统会提示你链接群集。When clicking on the Azure HDInsight explorer to expand an HDInsight cluster, you will be prompted to link the cluster if you are reader only role for the cluster. 遵循以下步骤通过 Ambari 凭据链接到群集。Follow the steps below to link to the cluster via Ambari credentials.

将作业提交到 HDInsight 群集Submit job to HDInsight cluster

将作业提交到 HDInsight 群集时,如果你对群集拥有“仅限读取者”角色,系统会提示你链接群集。When submitting job to an HDInsight cluster, you will be prompted to link the cluster if you are reader only role for the cluster. 遵循以下步骤通过 Ambari 凭据链接到群集。Follow the steps below to link to the cluster via Ambari credentials.

  1. 输入 Ambari 用户名Enter the Ambari username
  2. 输入 Ambari 用户密码。Enter Ambari user Password.

HDInsight Tools for Visual Studio Code 用户名

HDInsight Tools for Visual Studio Code 密码

Note

可以使用“HDInsight:列出群集”检查已链接的群集。You can use HDInsight: List Cluster to check the linked cluster.

HDInsight Tools for Visual Studio Code 读取者已链接

Azure Data Lake Storage Gen2 (ADLS Gen2)Azure Data Lake Storage Gen2 (ADLS Gen2)

浏览 ADLS Gen2 帐户Browse an ADLS Gen2 Account

单击 Azure HDInsight 资源管理器展开 ADLS Gen2 帐户时,如果你的 Azure 帐户对 Gen2 存储没有访问权限,系统会提示你输入存储访问密钥When clicking on the Azure HDInsight explorer to expand an ADLS Gen2 account, you will be prompted to enter the storage Access key if your Azure account has no access to the Gen2 storage. 成功验证访问密钥后,ADLS Gen2 帐户会自动展开。The ADLS Gen2 account will be auto expanded once the access key is validated successfully.

将作业提交到包含 ADLS Gen2 的 HDInsight 群集Submit jobs to HDInsight cluster with ADLS Gen2

将作业提交到包含 ADLS Gen2 的 HDInsight 群集时,如果你的 Azure 帐户对 Gen2 存储没有写入访问权限,系统会提示你输入存储访问密钥When submitting job to an HDInsight cluster with ADLS Gen2, you will be prompted to enter the storage Access key if your Azure account has no write access to the Gen2 storage. 成功验证访问密钥后,作业将成功提交。The job will be successfully submitted once the access key is validated successfully.

HDInsight Tools for Visual Studio Code 访问密钥

Note

可以在 Azure 门户中获取存储帐户的访问密钥。You can get the access key for storage account from the Azure portal. 有关信息,请参阅查看和复制访问密钥For information, see View and copy access keys.

  1. 在菜单栏中,导航到“视图” > “命令面板...”,然后输入 HDInsight: Unlink a ClusterFrom the menu bar navigate to View > Command Palette..., and then enter HDInsight: Unlink a Cluster.

  2. 选择要取消链接的群集。Select cluster to unlink.

  3. 查看“输出”视图以进行验证。 Review OUTPUT view for verification.

注销Sign out

在菜单栏中,导航到“视图” > “命令面板...”,然后输入 HDInsight: Logout 命令。From the menu bar navigate to View > Command Palette..., and then enter HDInsight: Logout. 右下角会弹出一个窗口,指出“注销成功!”。 There will be a pop-up in the bottom right-hand corner stating Logout successfully!.