Skip to content

Cosmos Data Extension GetPropertyValue Fails with Nested Partition Key Path #175

@cf-ehakin

Description

@cf-ehakin

When transferring from Azure Blob Json source to Cosmos DB sink, the following error occurs if partition key path on destination DB is:

/partitionkeyvalue1/partitionkeyvalue2

Sink Settings are

 "SinkSettings": {
                "Container": "CosmosContainer",
                "IncludeMetaDataFields": true,
                "PartitionKeyPath": "/partitionkeyvalue1/partitionkeyvalue2"
            }

Source Json is:

[
  {
    "_segments": [],
    "_executionLogs": [],
    "partitionkeyvalue1": {
		"partitionkeyvalue2": "<GUID>",
		"somevaule4": "<GUID>",
		"UserName": "<username>",
		"othervalue": "<data>",
		"othervalue3": "<data_2>"
    }
  }
]

This produces an error:

  Data transfer failed
    System.AggregateException: One or more errors occurred. (The specified key 'partitionkeyvalue1/partitionkeyvalue2' does not exist in the ExpandoObject.)
     ---> System.Collections.Generic.KeyNotFoundException: The specified key 'partitionkeyvalue1/partitionkeyvalue2' does not exist in the ExpandoObject.
       at System.Dynamic.ExpandoObject.System.Collections.Generic.IDictionary<System.String,System.Object>.get_Item(String key)
       at Cosmos.DataTransfer.CosmosExtension.CosmosDataSinkExtension.GetPropertyValue(ExpandoObject item, String propertyName) in /__w/data-migration-desktop-tool/data-migration-desktop-tool/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosDataSinkExtension.cs:line 211

This seems to be directly related to the GetPropertyValue method:

private static string? GetPropertyValue(ExpandoObject item, string propertyName)
{
    return ((IDictionary<string, object?>)item)[propertyName]?.ToString();
}

Is this something that can be addressed, or are we defining the partition key in a not best practice manner?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions