使用Node SDK从映像创建azure VM

时间:2014-07-16 06:39:40

标签: node.js azure virtual-machine

我正在尝试使用azure sdk(azure-sdk-for-node)根据我已保存的图像创建虚拟机。我也已经创建了这项服务。

这就是我所拥有的:

// Create a virtual machine in the cloud service.
computeManagementClient.virtualMachines.createDeployment('prerender-pro', {
  name: "prerender-pro",
  deploymentSlot: "Production",
  label: "for heavy duty caching",
  roles: [{
    roleName: "prerender-pro",
    roleType: "PersistentVMRole",
    label: "for heavy duty caching",
    oSVirtualHardDisk: {
      sourceImageName: "prerender-os-2014-07-16",
      mediaLink: "https://XXXXXXX.blob.core.windows.net/vhds/prerender-os-2014-07-16.vhd"
    },
    dataVirtualHardDisks: [],
    configurationSets: [{
      configurationSetType: "LinuxProvisioningConfiguration",
      adminUserName: "Blah",
      adminPassword: "Blahblah2014!",
      computerName: 'prerender-pro',
      enableAutomaticUpdates: true,
      resetPasswordOnFirstLogon: false,
      storedCertificateSettings: [],
      inputEndpoints: []
    }, {
      configurationSetType: "NetworkConfiguration",
      subnetNames: [],
      storedCertificateSettings: [],
      inputEndpoints: [{
        localPort: 3389,
        protocol: "tcp",
        name: "RemoteDesktop"
      }]
    }]
  }]
}, function (err, result) {
  if (err) {
    console.error(err);
  } else {
    console.info(result);
  }
});

我得到的错误就是这个。我几乎完全按照github自述文件中的示例进行操作。不确定为什么这是一个问题。

{ [Error: A computer name must be specified.]
  code: 'BadRequest',
  statusCode: 400,
  requestId: '9206ea1e591eb4dd8ea21a9196da5d74' }

谢谢!

1 个答案:

答案 0 :(得分:0)

事实证明错误信息不准确。部署Linux实例时,定义配置集时只需要“HostName”。 “ComputerName”仅适用于Windows实例。这是C#代码的一个例子:

ConfigurationSet configSet = new ConfigurationSet
        {
            HostName = "VMTest",
            UserName="xxxxx",
            UserPassword="xxxx",
            ConfigurationSetType = ConfigurationSetTypes.LinuxProvisioningConfiguration
         }