title: Azure Create VirtualMachine/Deployment REST API
body: <p>I am trying to create a Virtual Machine through the REST API, using the .NET Management Library but I am always getting to the same error. I tried with both the CreateDeployment and CreateAsync of the VirtualMachines operations, but both lead to the same result.
  Here's the code:</p>
  
  <pre><code>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&lt;Role&gt;
                  {  
                      new Role(){
                          OSVirtualHardDisk = new OSVirtualHardDisk()
                      {
                          DiskName = "testDisk"
                      },  
                      RoleType = "PersistentVMRole",
                      RoleName = "testMachine1",
                      RoleSize = "Medium",
                      ConfigurationSets = new List&lt;ConfigurationSet&gt;{ new ConfigurationSet()
                  {
                      AdminUserName = "ssadmin",
                      AdminPassword = "testp12334!",
                      ComputerName = "mycomptest", 
                      ConfigurationSetType = "WindowsProvisioningConfiguration"
  
                  }}
                      }
                  }, 
                  DeploymentSlot = DeploymentSlot.Staging,
                  Label = "test-deploymentL"
              });
  </code></pre>
  
  <p>Both the CloudService and the Disk are existing (I can even get them through the API). The error that I am getting is:</p>
  
  <p><strong>BadRequest: ProvisioningConfigurationSet is found in ConfigurationSet collection of the virtual machine with name testMachine. When provisioning a virtual machine from an OS disk, ProvisioningConfigurationSet must not be specified.</strong></p>
  
  <p>I tried removing both the OSVirtualHardDisk and the ConfigurationSetType paremeters, but then I am getting errors that they are both required. So it seems that the API is telling me the two parameters are both required but cannot exist together at the same time.
  Any help would be highly appreciated. </p>