Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Limit bulk enrollment query to return 10 elements
Browse files Browse the repository at this point in the history
  • Loading branch information
abhipsaMisra committed Jan 17, 2020
1 parent b619e51 commit 42f47d0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Azure.Devices.Samples
{
public class CleanUpDevicesSample
{
private const int QueryBatchSize = 1000;
private const int QueryBatchSize = 10000;
private const int DeleteBatchSize = 100;
private RegistryManager _rm;
private List<string> _deleteDeviceWithPrefix =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class RegistryManagerSample
private static string s_primaryThumbprint = Environment.GetEnvironmentVariable("IOTHUB_PFX_X509_THUMBPRINT");
private static string s_secondaryThumbprint = Environment.GetEnvironmentVariable("IOTHUB_PFX_X509_THUMBPRINT2");

// Maximum number of elements per query.
private const int QueryPageSize = 100;

private readonly RegistryManager _registryManager;

public RegistryManagerSample(RegistryManager registryManager)
Expand Down Expand Up @@ -63,7 +66,7 @@ public async Task EnumerateTwinsAsync()
{
Console.WriteLine("Querying devices:");

var query = _registryManager.CreateQuery("select * from devices");
var query = _registryManager.CreateQuery("select * from devices", QueryPageSize);

while (query.HasMoreResults)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class BulkOperationSample
"yKhZS3dkcvfBisBhP1XH9B33VqHG9SHnbnQXdBUaCgKAfxome8UmBKfe+naTsE5fkvjb/do3/dD6l4sGBwFCnKR" +
"dln4XpM03zLpoHFao8zOwt8l/uP3qUIxmCYv9A7m69Ms+5/pCkTu/rK4mRDsfhZ0QLfbzVI6zQFOKF/rwsfBtFe" +
"WlWtcuJMKlXdD8TXWElTzgh7JS4qhFzreL0c1mI0GCj+Aws0usZh7dLIVPnlgZcBhgy1SSDQMQ==";

// Maximum number of elements per query.
private const int QueryPageSize = 2;
private const int QueryPageSize = 100;

private static IDictionary<string, string> _registrationIds = new Dictionary<string, string>
{
Expand Down Expand Up @@ -85,6 +85,7 @@ public async Task QueryIndividualEnrollmentsAsync()
{
Console.WriteLine("\nCreating a query for enrollments...");
QuerySpecification querySpecification = new QuerySpecification("SELECT * FROM enrollments");

using (Query query = _provisioningServiceClient.CreateIndividualEnrollmentQuery(querySpecification, QueryPageSize))
{
while (query.HasNext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace Microsoft.Azure.Devices.Provisioning.Service.Samples
public class CleanupEnrollmentsSample
{
private ProvisioningServiceClient _provisioningServiceClient;
// Maximum number of elements per query.
private const int QueryPageSize = 100;
// Maximum number of elements per query - DPS has a limit of 10.
private const int QueryPageSize = 10;
private static int _individualEnrollmentsDeleted;
private static int _enrollmentGroupsDeleted;
private List<string> individualEnrollmentsToBeRetained =
Expand Down Expand Up @@ -66,6 +66,8 @@ private async Task QueryAndDeleteIndividualEnrollments()
{
await DeleteBulkIndividualEnrollments(individualEnrollments).ConfigureAwait(false);
}

await Task.Delay(1000).ConfigureAwait(false);
}
}
}
Expand Down

0 comments on commit 42f47d0

Please sign in to comment.