0

Version: 1.1.0

I am creating a VM using a market place image. My code looks something like this

VirtualMachine linuxVM = azure.virtualMachines().define(name)
                .withRegion(Region.US_WEST)
                .withExistingResourceGroup(myRg)
                .withExistingPrimaryNetwork(network)
                .withSubnet("subnet1")
                .withPrimaryPrivateIPAddressDynamic()
                .withNewPrimaryPublicIPAddress("ip-" + name)
                .withLatestLinuxImage("publisher", "offer", "sku")
                .withRootUsername("root")
                .withRootPassword("some password")
                .withSize(VirtualMachineSizeTypes.BASIC_A0)
                .create();

I get an error as follows.

Async operation failed with provisioning state: Failed: Creating a virtual machine from Marketplace image requires Plan information in the request. OS disk name is '<name>'

How do I add plan information?

nwarriorch
  • 337
  • 6
  • 16
  • I tried to replace "publisher", "offer", "sku" with "OpenLogic", "CentOS", "7.3" to run the code that you provide normally without exception of the Plan. Would you please provide your "publisher", "offer", "sku" specific parameters and other important parameters, so that I could help you find the solutions for the issue. – Jay Gong Aug 24 '17 at 08:39

1 Answers1

1

It looks like plan information can be added to the VM create, after spending some time with the source code. The following code works with 1.1.0.

PurchasePlan plan = new PurchasePlan();
plan.withName("name");
plan.withPublisher("publisher");
plan.withProduct("prodcut");

VirtualMachine linuxVM = azure.virtualMachines().define(name)
                .withRegion(Region.US_WEST)
                .withExistingResourceGroup(myRg)
                .withExistingPrimaryNetwork(network)
                .withSubnet("subnet1")
                .withPrimaryPrivateIPAddressDynamic()
                .withNewPrimaryPublicIPAddress("ip-" + name)
                .withLatestLinuxImage("publisher", "offer", "sku")
                .withRootUsername("root")
                .withRootPassword("some password")
                .withSize(VirtualMachineSizeTypes.BASIC_A0)
                .withPlan(plan)
                .create();
nwarriorch
  • 337
  • 6
  • 16