Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading