azure - 有没有办法在 azure 中使用 typescript 列出所有虚拟机?

标签 azure azure-pipelines-build-task

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

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

关于azure - 有没有办法在 azure 中使用 typescript 列出所有虚拟机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61537175/

相关文章:

azure - 此虚拟机规模集已被池使用

MSBuild 属性作为 VSTS 生成定义中的变量

Django 将 azure-storage 形式的 blob 返回为可下载文件

c# - 如何从 Microsoft.Azure.Management.Fluent api 方法获得成功响应

azure - 如何使用 YAML 配置文件在 VSTS 中的 VS2017 代理中启动 Azure 存储模拟器

azure - VSTS Coder Coverage 未显示 HTML 报告

azure-pipelines - VSTS 构建任务输入类型

azure - 是否有任何选项可以为 Azure 仪表板的导出编写脚本?

c# - 部署在本地sql server management studio的azure数据库的数据库备份

spring - 如何减少Spring Boot发送到Azure Active Directory的标准范围授权请求