Azure Function / C# / Azure Table: cannot store my data

I’m trying to store some monitoring data into an Azure Table.

I’ve added the Azure Table Client to my C# Azure Function (running on .NET 6, isolated), and I’m trying to store this data into my Azure Table:

public class AlertsData : ITableEntity
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }

    public DateTimeOffset? Timestamp { get; set; }
    public ETag ETag { get; set; }

    public DateTime LastCheck { get; set; }

    public List<AlertDataItem> DataItems { get; set; }

    public AlertsData()
    {
        DataItems = new List<AlertDataItem>();
        Timestamp = DateTimeOffset.UtcNow;
    }
}

public class AlertDataItem
{
    public string Name { get; set; }
    public int Measure { get; set; }
    public DateTime LastCheck { get; set; }

    public AlertDataItem(string name, int measure)
    {
        Name = name;
        Measure = measure;
        LastCheck = DateTime.UtcNow;
    }
}

I get my data from my system, set the partition and row key fields, and then I try to save my data:

However, when I do

await _tblClient.AddEntityAsync<AlertsData>(data);

I just simply get a not very helpful

Not supported type Bfh.Dynamics365.Monitoring.Service.Models.AlertDataItem

Any ideas WHY this type isn’t supported? Seems harmless enough ….

>Solution :

The error message doesn’t seem to match the reason, but I would expect the culprit is the DataItems property. Table storage doesn’t support List-typed properties; how would it know what to name the columns?

From the documentation:

The Table service supports a subset of data types defined by the OData Protocol Specification.

The table lists the following CLR types as supported:

byte[], bool, DateTime, double, Guid, Int32 or int, Int64 or long, String

Leave a Reply