0
votes

I'm developing an Azure IoT web application in .NET Core 3.0 and I use the Microsoft.Azure.Devices.RegistryManager to get the device twins. However, I always get the metadata sent along with it. It takes up more than half the size of the device twin and I don't have needs for it. When getting a bunch of device twins, this means a lot of traffic and I want to reduce it.

Can I get the device twins without getting the metadata??

Anyone?

Anyone?

1

1 Answers

0
votes

You can use Projection Queries, since IoT Hub provides a SQL-like language to retrieve information regarding device twins.

Example:

var query = registryManager.CreateQuery("SELECT LastActivityTime FROM devices WHERE status = 'enabled'");
while (query.HasMoreResults)
{
    var page = await query.GetNextAsTwinAsync();
    foreach (var twin in page)
    {
        // do work on twin object
    }
}

More info here: IoT Hub query language for device and module twins, jobs, and message routing