Skip to content

[Bug Report] DPS query API does not populate enrollment assignment information #3478

@dadude999

Description

@dadude999

Context

  • OS, version, SKU and CPU architecture used: Windows 10 Desktop x64, Azure App Service (Linux based)
  • Application's .NET Target Framework : net8.0
  • SDK version used: Microsoft.Azure.Devices.Provisioning.Service 1.18.4

Description of the issue

The DPS SDK contains wrapper methods around two DPS APIs:
(a) query all enrollments for a DPS instance
(b) get a single enrollment from the DPS instance

Method (b) works correctly, but when using version (a), the enrollment objects are all missing the RegistrationState information. This causes us to have to retrieve each individual enrollment rather than querying the list once and using the information as-is.

Code sample exhibiting the issue

ProvisioningServiceClient provisioningServiceClient =
    ProvisioningServiceClient.CreateFromConnectionString("<insert_connection_string_here>");

IndividualEnrollment goodResult = await provisioningServiceClient.GetIndividualEnrollmentAsync("<pick_a_regstration_id>");
// here, goodResult.RegistrationState is a valid object containing IoT Hub assignment details

Query query = provisioningServiceClient.CreateIndividualEnrollmentQuery(new QuerySpecification(string.Empty));
while(query.HasNext())
{
    QueryResult result = await query.NextAsync();
    IReadOnlyList<DeviceRegistrationState> badResults = result.Items.OfType<IndividualEnrollment>()
        .Select(enrollment => enrollment.RegistrationState).ToList();
   // here, every item in badResults will be null
}

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