To use a storage profile for a virtual machine, specify a VirtualMachineDefinedProfileSpec object for the VirtualMachineConfigSpec.vmProfile property.

The following code fragment sets the storage profile and creates the virtual machine. The profile (spbmProfile) is a VirtualMachineDefinedProfileSpec. See Retrieve an Existing Storage Profile from the Server.

Associating a Storage Profile with a Virtual Machine

[...]
VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();
// Set SPBM profile
configSpec.getVmProfile().add(spbmProfile);
[...]
ManagedObjectReference taskmor =
     connection.getVimPort().createVMTask(vmFolderMor, vmConfigSpec, resourcepoolmor, hostmor);

The following figure shows how a storage profile is integrated into a virtual machine configuration specification. Your client establishes the link between the storage profile (PbmCapabilityProfile) and the VirtualMachineDefinedProfileSpec by setting the profileId property in the VirtualMachineDefinedProfileSpec. The Server sets the profileData property when it configures the virtual machine.

Figure 1. Using a Storage Profile for Virtual Machine Provisioning
Diagram shows virtual machine provisioning objects.