使用适用于 Node.js 的 Azure SDK 管理 Azure Data Lake Analytics

重要

Azure Data Lake Analytics已于 2024 年 2 月 29 日停用。 通过此公告了解更多信息。

对于数据分析,你的组织可以使用 Azure Synapse AnalyticsMicrosoft Fabric

本文介绍如何通过使用用于 Node.js 的 Azure SDK 编写的应用管理 Azure Data Lake Analytics 帐户、数据源、用户和作业。

支持以下版本:

  • Node.js 版本:0.10.0 或更高版本
  • 帐户的 REST API 版本:2015 年 10 月 1 日预览版

功能

  • 帐户管理:创建、获取、列出、更新和删除。

如何安装

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
      }
    */
}) 

另请参阅