Administración de Análisis de Azure Data Lake mediante Azure SDK para Node.jsManage Azure Data Lake Analytics using Azure SDK for Node.js

En este artículo se describe cómo administrar cuentas, orígenes de datos, usuarios y trabajos de Azure Data Lake Analytics con una aplicación escrita utilizando el SDK de Azure para Node.js.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.

Las versiones compatibles son las siguientes:The following versions are supported:

  • Versión de Node.js: 0.10.0 o superiorNode.js version: 0.10.0 or higher
  • Versión de API de REST para la cuenta: 2015-10-01-previewREST API version for Account: 2015-10-01-preview
  • Versión de API de REST para el catálogo: 2015-10-01-previewREST API version for Catalog: 2015-10-01-preview
  • Versión de API de REST para el trabajo: 2016-03-20-previewREST API version for Job: 2016-03-20-preview

CaracterísticasFeatures

  • Administración de cuentas: crear, obtener, enumerar, actualizar y eliminar.Account management: create, get, list, update, and delete.
  • Administración de trabajos: enviar, obtener, enumerar y cancelar.Job management: submit, get, list, and cancel.
  • Administración de catálogos: obtener y lista.Catalog management: get and list.

Cómo instalarloHow to Install

npm install azure-arm-datalake-analytics

Autenticación mediante Azure Active DirectoryAuthenticate using Azure Active Directory

var msrestAzure = require('ms-rest-azure');
//user authentication
var credentials = new msRestAzure.UserTokenCredentials('your-client-id', 'your-domain', 'your-username', 'your-password', 'your-redirect-uri');
//service principal authentication
var credentials = new msRestAzure.ApplicationTokenCredentials('your-client-id', 'your-domain', 'your-secret');

Creación del cliente de Análisis de Data LakeCreate the Data Lake Analytics client

var adlaManagement = require("azure-arm-datalake-analytics");
var accountClient = new adlaManagement.DataLakeAnalyticsAccountClient(credentials, 'your-subscription-id');
var jobClient = new adlaManagement.DataLakeAnalyticsJobClient(credentials, 'azuredatalakeanalytics.net');
var catalogClient = new adlaManagement.DataLakeAnalyticsCatalogClient(credentials, 'azuredatalakeanalytics.net');

Creación de una cuenta de Análisis de Data LakeCreate 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.account.create(resourceGroupName, accountName, accountToCreate, function (err, result, request, response) {
  if (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
      }
    */
  } else {
    console.log('result is: ' + util.inspect(result, {depth: null}));
  }
});

Obtención de una lista de dominiosGet a list of jobs

var util = require('util');
var accountName = 'testadlaacct';
jobClient.job.list(accountName, function (err, result, request, response) {
  if (err) {
    console.log(err);
  } else {
    console.log('result is: ' + util.inspect(result, {depth: null}));
  }
});

Obtención de una lista de bases de datos en el catálogo de Análisis de Data LakeGet a list of databases in the Data Lake Analytics Catalog

var util = require('util');
var accountName = 'testadlaacct';
catalogClient.catalog.listDatabases(accountName, function (err, result, request, response) {
  if (err) {
    console.log(err);
  } else {
    console.log('result is: ' + util.inspect(result, {depth: null}));
  }
});

Consulte tambiénSee also