简体   繁体   English

如何在Node js应用程序中使用azure-cli节点包

[英]How to use azure-cli node package in Node js application

I am developing a Node js application. 我正在开发一个Node js应用程序。 I want to use the azure-cli package in my application to create HDI cluster and VM. 我想在我的应用程序中使用azure-cli包来创建HDI集群和VM。

npm install azure-cli -g --save

Above command install the azure-cli v1.0 only. 以上命令仅安装azure-cli v1.0。

How and where should I use the azure commands in my application. 我应该如何以及在何处使用我的应用程序中的azure命令。

Should I need write azure cli commands in shell script file and call that script file from node js application or any other way like calling azure cli commands in the node js application without a script file? 我是否需要在shell脚本文件中编写azure cli命令并从节点js应用程序调用该脚本文件或者在没有脚本文件的情况下在节点js应用程序中调用azure cli命令?

Note: Why azure-cli doesn't install azure cli V2.0 注意:为什么azure-cli不安装azure cli V2.0

Update 1:- 更新1: -

If I install winston package application, I can use like the following 如果我安装winston包应用程序,我可以使用如下

 var winston = require('winston');

  winston.log('info', 'Hello distributed log files!');
  winston.info('Hello again distributed logs');

Like that, Is there a way to use if I install azure-cli ? 像这样,如果我安装azure-cli ,有没有办法使用? (ie inside my node js application) (即在我的节点js应用程序内)

To answer your specific question around creating a VM or HDI (Hadoop cluster) in your Node.js app, the best approach would be to use the Azure SDK for Node. 要回答有关在Node.js应用程序中创建VM或HDI(Hadoop集群)的具体问题,最好的方法是使用Azure SDK for Node。

  1. For VMs, use npm install azure-arm-compute and follow instructions in VM Modules for NodeJS 对于VM,请使用npm install azure-arm-compute并按照VM Modules中的NodeJS说明进行操作
  2. For Hadoop, use npm install azure-arm-hdinsight and follow reference for azure-arm-hdinsight package 对于Hadoop,使用npm install azure-arm-hdinsight并遵循azure-arm-hdinsight包的参考

The older version of the Azure CLI was Node.js based, while the current version of the Azure CLI (v2) is Python based. 较旧版本的Azure CLI基于Node.js,而当前版本的Azure CLI(v2)基于Python。 You can install the latest version via the multiple mechanisms provided in http://aka.ms/cli . 您可以通过http://aka.ms/cli中提供的多种机制安装最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM