使用適用於 Visual Studio 的 Data Lake 工具來開發 U-SQL 指令碼Develop U-SQL scripts by using Data Lake Tools for Visual Studio

Azure Data Lake 和串流分析工具包含兩項 Azure 服務、Azure Data Lake Analytics 和 Azure 串流分析相關的功能。Azure Data Lake and Stream Analytics Tools include functionality related to two Azure services, Azure Data Lake Analytics and Azure Stream Analytics. 如需 Azure 串流分析案例的詳細資訊,請參閱適用于 Visual Studio 的 azure 串流分析工具For more information about the Azure Stream Analytics scenarios, see Azure Stream Analytics tools for Visual Studio.

本文說明如何使用 Visual Studio 來建立 Azure Data Lake Analytics 帳戶。This article describes how to use Visual Studio to create Azure Data Lake Analytics accounts. 您可以在 [ U-SQL] 中定義作業,並將作業提交至 Data Lake Analytics 服務。You can define jobs in U-SQL, and submit jobs to the Data Lake Analytics service. 如需有關 Data Lake Analytics 的詳細資訊,請參閱 Azure Data Lake Analytics 概觀For more information about Data Lake Analytics, see Azure Data Lake Analytics overview.

重要

我們建議您升級至 Azure Data Lake Tools for Visual Studio 版本2.3.3000.4 版或更新版本。We recommend you upgrade to Azure Data Lake Tools for Visual Studio version 2.3.3000.4 or later. 舊版目前已淘汰,不再提供下載。The previous versions are no longer available for download and are now deprecated.

  1. 請檢查您是否使用比 2.3.3000.4 版 Azure Data Lake Tools for Visual Studio 還要舊的版本。Check if you are using an earlier version than 2.3.3000.4 of Azure Data Lake Tools for Visual Studio.

    檢查工具版本

  2. 如果您的版本比 2.3.3000.4 版還要舊,請藉由造訪下載中心來更新您的 Azure Data Lake Tools for Visual Studio:If your version is an earlier version of 2.3.3000.4, update your Azure Data Lake Tools for Visual Studio by visiting the download center:

必要條件Prerequisites

安裝 Azure Data Lake Tools for Visual StudioInstall Azure Data Lake Tools for Visual Studio

要進行本教學課程,就必須安裝 Data Lake Tools for Visual Studio。This tutorial requires that Data Lake Tools for Visual Studio is installed. 如需詳細資訊,請參閱安裝適用于 Visual Studio 的 Data Lake 工具For more information, see Install Data Lake Tools for Visual Studio.

連線至 Azure Data Lake Analytics 帳戶Connect to an Azure Data Lake Analytics account

  1. 開啟 Visual Studio。Open Visual Studio.

  2. 選取 [ View > 伺服器總管] 來開啟伺服器總管Open Server Explorer by selecting View > Server Explorer.

  3. 以滑鼠右鍵按一下 [ Azure],然後選取 [連線至 Microsoft Azure 訂用帳戶]。Right-click Azure, then select Connect to Microsoft Azure Subscription. 在 [登入您的帳戶] 中,遵循指示。In Sign in to your account, follow the instructions.

  4. 伺服器總管中,選取 Azure > Data Lake AnalyticsIn Server Explorer, select Azure > Data Lake Analytics. 您會看到 Data Lake Analytics 帳戶的清單。You see a list of your Data Lake Analytics accounts.

撰寫第一個 U-SQL 指令碼Write your first U-SQL script

下列文字是簡單的 U-SQL 指令碼。The following text is a simple U-SQL script. 它會定義小型資料集,並將該資料集寫入預設 Data Lake Store 中,作為名為 /data.csv 的檔案。It defines a small dataset and writes that dataset to the default Data Lake Store as a file called /data.csv.

USE DATABASE master;
USE SCHEMA dbo;
@a  = 
    SELECT * FROM 
        (VALUES
            ("Contoso", 1500.0),
            ("Woodgrove", 2700.0)
        ) AS 
              D( customer, amount );
OUTPUT @a
    TO "/data.csv"
    USING Outputters.Csv();

提交資料湖分析作業Submit a Data Lake Analytics job

  1. 在 Visual Studio 中,選取 [檔案] > [新增] > [專案]。In Visual Studio, select File > New > Project.

  2. 選取 [ U-SQL] 專案類型,然後選取 [下一步]Select the U-SQL Project type, and then select Next. 在 [設定您的新專案] 中,選取 [建立]。In Configure your new project, select Create.

    Visual Studio 會建立包含script.usql檔案的方案。Visual Studio creates a solution that contains a Script.usql file.

  3. 將腳本從 [撰寫您的第一個 U-SQL 腳本] 貼入 [ script.usql ] 視窗。Paste the script from Write your first U-SQL script into the Script.usql window.

  4. 方案總管中,以滑鼠右鍵按一下 [ script.usql],然後選取 [提交腳本]。In Solution Explorer, right-click Script.usql, and select Submit Script.

  5. 在 [提交作業] 中,選擇您的 Data Lake Analytics 帳戶,然後選取 [提交]。In Submit Job, choose your Data Lake Analytics account and select Submit.

    提交 U-SQL Visual Studio 專案

提交作業之後,[作業檢視] 索引標籤隨即開啟,並顯示作業進度。After the job submission, the Job view tab opens to show the job progress.

  • 作業摘要會顯示作業的摘要。Job Summary shows the summary of the job.
  • 作業圖形會以視覺化方式檢視作業的進度。Job Graph visualizes the progress of the job.
  • 中繼資料作業會顯示 U-SQL 目錄上所執行的所有動作。MetaData Operations shows all the actions that were taken on the U-SQL catalog.
  • 資料會顯示所有的輸入和輸出。Data shows all the inputs and outputs.
  • [狀態歷程記錄] 會顯示時間軸和狀態的詳細資料。State History shows the timeline and state details.
  • AU 分析顯示作業中使用了多少 AU,並探索不同 AU 配置策略的模擬。AU Analysis shows how many AUs were used in the job and explore simulations of different AU allocation strategies.
  • 診斷會提供作業執行和效能最佳化的進階分析。Diagnostics provides an advanced analysis for job execution and performance optimization.

U SQL Visual Studio Data Lake Analytics 工作效能圖表

若要查看最新的作業狀態並重新整理畫面,請選取 [ 重新整理]。To see the latest job status and refresh the screen, select Refresh.

檢查作業狀態Check job status

  1. 伺服器總管中,選取 Azure > Data Lake AnalyticsIn Server Explorer, select Azure > Data Lake Analytics.

  2. 展開 Data Lake Analytics 帳戶名稱。Expand the Data Lake Analytics account name.

  3. 按兩下 [作業]。Double-click Jobs.

  4. 選取您先前提交的作業。Select the job that you previously submitted.

查看作業輸出See the job output

  1. 伺服器總管中,流覽至您所提交的作業。In Server Explorer, browse to the job you submitted.

  2. 按一下 [資料] 索引標籤。Click the Data tab.

  3. 在 [作業輸出] 索引標籤中,選取 "/data.csv" 檔案。In the Job Outputs tab, select the "/data.csv" file.

後續步驟Next steps