共用方式為


使用 Node.js 的 Azure SDK 管理 Azure 資料湖分析

重要

Azure Data Lake Analytics 於 2024 年 2 月 29 日淘汰。 使用此公告深入瞭解。

針對數據分析,您的組織可以使用 Azure Synapse AnalyticsMicrosoft Fabric

本文說明如何使用以 Azure SDK for Node.js 所撰寫的應用程式,來管理 Azure Data Lake Analytics 帳戶、資料來源、使用者和作業。

下面是支援的版本:

  • Node.js 版本:0.10.0 或更高版本
  • 帳戶的 REST API 版本:2015-10-01-preview

功能

  • 帳戶管理:建立、取得、列出、更新及刪除。

安裝方式

npm install @azure/arm-datalake-analytics

使用 Microsoft Entra ID 進行驗證

const { DefaultAzureCredential } = require("@azure/identity");
//service principal authentication
var credentials = new DefaultAzureCredential();

建立 Data Lake Analytics 用戶端

const { DataLakeAnalyticsAccountManagementClient } = require("@azure/arm-datalake-analytics");
var accountClient = new DataLakeAnalyticsAccountManagementClient(credentials, 'your-subscription-id');

建立 Data Lake Analytics 帳戶

var util = require('util');
var resourceGroupName = 'testrg';
var accountName = 'testadlaacct';
var location = 'eastus2';

// A Data Lake Store account must already have been created to create
// a Data Lake Analytics account. See the Data Lake Store readme for
// information on doing so. For now, we assume one exists already.
var datalakeStoreAccountName = 'existingadlsaccount';

// account object to create
var accountToCreate = {
  tags: {
    testtag1: 'testvalue1',
    testtag2: 'testvalue2'
  },
  name: accountName,
  location: location,
  properties: {
    defaultDataLakeStoreAccount: datalakeStoreAccountName,
    dataLakeStoreAccounts: [
      {
        name: datalakeStoreAccountName
      }
    ]
  }
};

client.accounts.beginCreateAndWait(resourceGroupName, accountName, accountToCreate).then((result)=>{
  console.log('result is: ' + util.inspect(result, {depth: null}));
}).catch((err)=>{
  console.log(err);
    /*err has reference to the actual request and response, so you can see what was sent and received on the wire.
      The structure of err looks like this:
      err: {
        code: 'Error Code',
        message: 'Error Message',
        body: 'The response body if any',
        request: reference to a stripped version of http request
        response: reference to a stripped version of the response
      }
    */
}) 

另請參閱