有没有办法将ADLS gen2与Node js连接并向其中写入文件

时间:2020-02-11 10:18:52

标签: javascript node.js azure-data-lake-gen2

我需要创建一个API,以将数据直接从Node写入ADLS gen2。我尝试了以下方法:

var async = require('async');
var adalNode = require('adal-node');
var azureCommon = require('azure-common');
var azureDataLakeStore = require('azure-arm-datalake-store');

var resourceUri = 'https://<name>.core.dfs.core.windows.net/';
var loginUri = 'https://login.windows.net/'

var clientId = 'application_id_(guid)';
var clientSecret = 'application_password';

var tenantId = 'aad_tenant_id';
var subscriptionId = 'azure_subscription_id';
var resourceGroup = 'adls_resourcegroup_name';

var accountName = 'analytics';

var context = new adalNode.AuthenticationContext(loginUri+tenantId);

var client;
var response;

var destinationFilePath = '/newFileName.txt';
var content = 'desired file contents';

async.series([
    function (next) {
        context.acquireTokenWithClientCredentials(resourceUri, clientId, clientSecret, function(err, result){
            if (err) throw err;
            response = result;
            next();
        });
    },
    function (next) {
        var credentials = new azureCommon.TokenCloudCredentials({
            subscriptionId : subscriptionId,
            authorizationScheme : response.tokenType,
            token : response.accessToken
        });

        client = azureDataLakeStore.createDataLakeStoreFileSystemManagementClient(credentials, 'azuredatalakestore.net');

        next();
    }

我无法解决第二代连接的方式和位置以及如何将数据从第二根连接写入所需路径位置的问题

0 个答案:

没有答案