Gestire Azure Data Lake Analytics tramite Azure SDK per Node.jsManage Azure Data Lake Analytics using Azure SDK for Node.js

Azure SDK per Node. js può essere usato per gestire account, processi e cataloghi di Analisi Azure Data Lake.The Azure SDK for Node.js can be used for managing Azure Data Lake Analytics accounts, jobs and catalogs. Per visualizzare l'argomento relativo alla gestione tramite altri strumenti, fare clic sul selettore di scheda riportato sopra.To see management topic using other tools, click the tab select above.

Attualmente supporta:Right now it supports:

  • Versione di Node.js: 0.10.0 o successivaNode.js version: 0.10.0 or higher
  • Versione dell'API REST per l'account: 2015-10-01-previewREST API version for Account: 2015-10-01-preview
  • Versione dell'API REST per il catalogo: 2015-10-01-previewREST API version for Catalog: 2015-10-01-preview
  • Versione dell'API REST per il processo: 2016-03-20-previewREST API version for Job: 2016-03-20-preview

FunzionalitĂ Features

  • Gestione account: creare, ottenere, elencare, aggiornare ed eliminare.Account management: create, get, list, update, and delete.
  • Gestione dei processi: inviare, ottenere, elencare, annullare.Job management: submit, get, list, and cancel.
  • Gestione del catalogo: ottenere ed elencare.Catalog management: get and list.

Come eseguire l'installazioneHow to Install

npm install azure-arm-datalake-analytics

Eseguire l'autenticazione con 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');

Creare il client di Analisi Data LakeCreate the Data Lake Analytics client

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

Creare un account di Analisi 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}));
  }
});

Ottenere un elenco di processiGet 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}));
  }
});

Ottenere un elenco di database nel catalogo di Analisi 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}));
  }
});

Vedere ancheSee also