azure - 有没有办法在 azure 中使用 typescript 列出所有 VM?
问题描述
我正在尝试从我的 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);
});
推荐阅读
- vba - 添加工作表和日期时出错
- c# - 错误 #CS0738“通知”未实现接口成员“IJob.Execute(IJobExecutionContext)”。'Notification.Execute(IJobExecutionContext)'
- c# - DbUpdateConcurrencyException 和 DbConcurrencyException 有什么区别?
- php - 从递归函数返回数据?
- algorithm - 如何从 lcm(a,b) = c 中找到最小的 b?
- python - super().method() 和 self.method() 有什么区别
- ios - 当应用程序在后台 iOS 11 中时,UNNotification 本地通知用户点击不会触发委托
- unit-testing - 需要帮助查明中间件测试中零引用错误的原因(Golang)
- jenkins - 詹金斯可以检测浏览器类型。如果那么我们如何将它传递给自动化脚本来运行?
- c++ - 在 Windows 10 上安装适用于 C++ 的 tesseract