【问题标题】:Azure Create VirtualMachine/Deployment REST APIAzure 创建虚拟机/部署 REST API
【发布时间】:2014-02-24 17:50:00
【问题描述】:

我正在尝试使用 .NET 管理库通过 REST API 创建一个虚拟机,但我总是遇到同样的错误。我尝试了 VirtualMachines 操作的 CreateDeployment 和 CreateAsync,但都导致了相同的结果。 代码如下:

ComputeManagementClient computeClient = CloudContext.Clients.CreateComputeManagementClient(credentials);
        var status = await computeClient.VirtualMachines.CreateDeploymentAsync("testClService",
            new Microsoft.WindowsAzure.Management.Compute.Models.VirtualMachineCreateDeploymentParameters()
            {
                Name = "test-deployment", 
                Roles = new List<Role>
                {  
                    new Role(){
                        OSVirtualHardDisk = new OSVirtualHardDisk()
                    {
                        DiskName = "testDisk"
                    },  
                    RoleType = "PersistentVMRole",
                    RoleName = "testMachine1",
                    RoleSize = "Medium",
                    ConfigurationSets = new List<ConfigurationSet>{ new ConfigurationSet()
                {
                    AdminUserName = "ssadmin",
                    AdminPassword = "testp12334!",
                    ComputerName = "mycomptest", 
                    ConfigurationSetType = "WindowsProvisioningConfiguration"

                }}
                    }
                }, 
                DeploymentSlot = DeploymentSlot.Staging,
                Label = "test-deploymentL"
            });

CloudService 和 Disk 都存在(我什至可以通过 API 获取它们)。我得到的错误是:

错误请求:在名为 testMachine 的虚拟机的 ConfigurationSet 集合中找到了 ProvisioningConfigurationSet。从 OS 磁盘置备虚拟机时,不得指定 ProvisioningConfigurationSet。

我尝试同时删除 OSVirtualHardDisk 和 ConfigurationSetType 参数,但随后出现错误,表明它们都是必需的。所以似乎API告诉我这两个参数都是必需的,但不能同时存在。 任何帮助将不胜感激。

【问题讨论】:

    标签: azure


    【解决方案1】:

    问题在于“ConfigurationSets”参数本身是必需的,而不是 ConfigurationSetType。因此,在创建一个空的 ConfigurationSets 元素后,一切正常: ConfigurationSets = new List&lt;ConfigurationSet&gt;()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 2019-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      • 2019-05-24
      相关资源
      最近更新 更多