Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dadude999 opened this issue Nov 27, 2024 · 0 comments
Labels
bug Something isn't working.

Comments

@dadude999
Copy link

dadude999 commented Nov 27, 2024

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
}
@dadude999 dadude999 added the bug Something isn't working. label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

1 participant