Partajați prin


Manage Azure Data Lake Analytics using Azure SDK for Node.js

Important

Azure Data Lake Analytics retired on 29 February 2024. Learn more with this announcement.

For data analytics, your organization can use Azure Synapse Analytics or Microsoft Fabric.

This article describes how to manage Azure Data Lake Analytics accounts, data sources, users, and jobs using an app written using the Azure SDK for Node.js.

The following versions are supported:

  • Node.js version: 0.10.0 or higher
  • REST API version for Account: 2015-10-01-preview

Features

  • Account management: create, get, list, update, and delete.

How to install

npm install @azure/arm-datalake-analytics

Authenticate using Microsoft Entra ID

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

Create the Data Lake Analytics client

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

Create a Data Lake Analytics account

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

See also