这是完全可行的,这是在 azure 数据湖中创建示例文件的 nodeJs 代码,你可以在你的 Azure 函数中使用类似的东西来处理 ndoe js
先决条件:
1) 有权访问 Data Lake Analytics 帐户的服务主体。
见https://github.com/Huachao/azure-content/blob/master/articles/data-lake-store/resource-group-authenticate-service-principal.md
2) Azure Data Lake Store 帐户。
需要的库
npm 安装异步
npm install adal-node
npm install azure-common
npm install azure-arm-datalake-store
var async = require('async');
var adalNode = require('adal-node');
var azureCommon = require('azure-common');
var azureDataLakeStore = require('azure-arm-datalake-store');
var resourceUri = 'https://management.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 = 'adls_account_name';
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();
},
function (next) {
client.fileSystem.directCreate(destinationFilePath, accountName, content, function(err, result){
if (err) throw err;
});
}
]);
希望对你有帮助。