This is using the .NET SDK (and Rest) -- bu this is what we do today to change the computer name of a vm inside a vapp. (vApp is powered off at the time)
Hope this helps get you going...
(code modified a little from what we really run as the code we have does much more)
public void ModifyComputerNames(VM vm, string newName)
{
if (vm.GetGuestCustomizationSection() != null)
{
GuestCustomizationSectionType guestSection = vm.GetGuestCustomizationSection();
//NOTE: the computer name in vCloud must be unique and less than 15 characters
int maxLen = 15 - modifierText.Length;
string computerName = newName;
if (string.IsNullOrEmpty(computerName))
{
computerName = "VM";
}
if (computerName.Length > maxLen)
{
computerName = computerName.Substring(0, maxLen);
}
guestSection.ComputerName = computerName;
vm.UpdateSection(guestSection);
}
}