Error when VMs that are managed by Windows Azure Pack have names that are longer than 64 characters

Applies to: Windows Azure Pack (on Windows Server 2012 R2)System Center 2012 Virtual Machine ManagerMicrosoft System Center 2012 R2 Virtual Machine Manager

Symptoms


You discover that usage data is not being updated for virtual machines (VMs) that are managed by Windows Azure Pack (WAP). In this situation, an event that resembles the following is logged by the Service Provider Foundation services:

Log Name: Microsoft-ServiceProviderFoundation/Analytic
Source: Microsoft-ServiceProviderFoundation
Event ID: 11
Task Category: (65523)
Level: Error
Keywords: None
Description:
Component: 7

Activity [WebAuthentication Call, id {0f4f34b4-aa65-499d-b894-c62862a06ef6}]
Parent activity [none, id {00000000-0000-0000-0000-000000000000}]

Elapsed: 0ms
Context: {82c0e5a7-5ffa-49a6-8599-83eb4115c91c}

The SPF Usage Metering Retriever encountered an error while attempting to retrieve usage data. All SCSPFDB database changes have been rolled back. Failure information: The given value of type String from the data source cannot be converted to type nvarchar of the specified target column.

Additionally, SPF debug logs show an entry that resembles the following:
[1]27D4.2DF0::‎2015‎-‎04‎-‎28 10:15:32.241 [Microsoft-ServiceProviderFoundation]Component: 7 Activity [WebAuthentication Call, id {7caa052f-24f8-4b5d-a179-a0c40dad26d9}] Parent activity [none, id {00000000-0000-0000-0000-000000000000}] Elapsed: 0ms Context: {14953dc8-a8a6-4be6-9faf-312f23695b55} The SPF Usage Metering Retriever encountered an error while attempting to retrieve usage data. All SCSPFDB database changes have been rolled back. Failure information: Specified argument was out of the range of valid values. Parameter name: eventId.

Cause


Usage data may fail to update in WAP if a VM in the Operations Manager database has a display name set to a string of longer than 64 characters. You can detect this state by running the following query against the Operations Manager database:

USE OperationsManager
GO
Select displayname, len(displayname) as [No. of Chars]
from basemanagedentity
where FullName LIKE 'Microsoft.SystemCenter.VirtualMachineManager.2012.VirtualMachine:%'and len(displayname)>64

This limitation is caused by the SQL schema in the Service Provider Foundation (SPF) database (SCSPFDB). This schema defines the [scspf].[SpfUsageRecordProperties].Value and [scspf].[SpfUsageRecordResources].Value properties as nvarchar(64). The DisplayName property of the VirtualMachine object is synched with the OM environment through the SCVMM provider and is not expected to exceed this length.

Resolution


To resolve this issue and to allow usage data to be populated for the virtual machine, rename the virtual machine in either the VMM Admin Console or in Hyper-V Manager. Make sure that you give it a name of fewer than 64 characters. After you've done this, usage data will start being collected on the next usage polling cycle.

More Information


You cannot create a VM through the VMM console by using a VM name that's longer than 64 characters. However, you can have longer VM names by editing them either in the VMM Admin Console or in Hyper-V Manager.

This is a known issue with Service Provider Foundation for System Center 2012 R2 Update Rollup 6 (SC 2012 R2 UR6) and earlier versions.