有没有办法在 azure 中使用 typescript 列出所有 VM?

Is there a way to list all VM using typescript in azure?

我正在尝试从我的 Azure 资源组中获取所有 VM 的列表。我正在使用如下的armcompute。 在这里我没有得到 VM 列表。并且长度没有给我正确的虚拟机数量。我不确定我是否在正确的道路上。

var computeClient = new armCompute.ComputeManagementClient(credentials, subscriptionId);       
const virtualMachines: any = computeClient.virtualMachines.list;
 console.log(`Found ${virtualMachines.length} virtual machines:`);```


你可以这样做,

  msRestAzure.loginWithAppServiceMSI()
        .then(credentials => {
            computeClient = new computeManagementClient(credentials, subscriptionId);
            return computeClient.virtualMachines.listAll();
        })
        .then(vms => {
            done(context, 200, {vms: vms});
        })
        .catch(err => {
            doneWithError(context, err);
        });

SAMPLE CODE