MSBA-273 · Lesson 7 of 12 · 20 min
Batch and bulk operations
▶ Video coming soon A video version of this lesson is on the way.
Kwabena's team had a one-time job ahead of them: loading 250,000 historical work orders from the old Facilities database into an archive table so that the research team could study ten years of maintenance history alongside the current data. Wiremu's first test sent one Create request per row from a single loop. It ran for twenty minutes, created 30,000 rows, and then began receiving 429 responses. He had met the service protection limits. The seventh session was about moving large numbers of rows into and out of Dataverse efficiently, without harming everyone else using the environment.
Why volume needs a different approach
Every request to Dataverse has a fixed cost: the network round trip, authentication, the platform's processing of the message, the event pipeline, and the write to storage. For a person saving a form, the fixed cost is invisible. For a job writing a quarter of a million rows, it dominates. Sending rows one at a time wastes most of the time on round trips, and running many loops in parallel to compensate quickly hits the limits Dataverse uses to protect the shared service.
Service protection limits in detail
Dataverse evaluates service protection limits per user, which for integrations usually means per application user, over a sliding window of five minutes. There are three limits: 6,000 requests, 20 minutes of combined execution time, and 52 concurrent requests. When any limit is exceeded, Dataverse returns 429 Too Many Requests for the Web API, or a matching fault for the SDK, with a Retry-After value saying how long to wait. The limits exist so that one client cannot degrade the environment for everyone else; they are not an error to be worked around but a signal to slow down.
The right response to a 429 is to wait at least as long as Retry-After says and then try again. A client that retries immediately makes things worse, because its retries count as further requests. ServiceClient in the SDK for .NET handles these responses automatically for most operations, waiting and retrying up to a configurable number of times. Code that calls the Web API directly must implement the same behaviour itself.
// C#: a Web API call that respects Retry-After (simplified; real code also caps total wait).
async Task<HttpResponseMessage> SendWithRetryAsync(Func<HttpRequestMessage> build, int maxAttempts = 5)
{
for (var attempt = 1; ; attempt++)
{
var response = await http.SendAsync(build());
if ((int)response.StatusCode != 429 || attempt == maxAttempts) return response;
var wait = response.Headers.RetryAfter?.Delta ?? TimeSpan.FromSeconds(Math.Pow(2, attempt));
log.LogWarning("Throttled; waiting {Seconds} s before attempt {Next}", wait.TotalSeconds, attempt + 1);
await Task.Delay(wait);
}
}Dataverse also tells clients how much parallelism it can handle. Responses carry a header with a recommended degree of parallelism for the environment, which ServiceClient exposes as a property. A job that runs that many requests at once, and no more, usually achieves the best throughput without throttling. Wiremu's original loop had used one thread, which was too few; his second attempt used forty, which was too many.
Three ways to send many operations
Dataverse offers three mechanisms for sending many operations with fewer round trips. They differ in what they save and how they behave on errors.
| Mechanism | Interface | Size | Counts against request limit as | Transaction |
|---|---|---|---|---|
| Batch | Web API batch endpoint | Up to 1,000 requests | Each inner request | Per change set |
| ExecuteMultiple | SDK for .NET | Up to 1,000 requests | Each inner request | None; each request separate |
| ExecuteTransaction | SDK for .NET | Up to 1,000 requests | Each inner request | All or nothing |
| Bulk operation messages | Both | Configurable; see below | One request | Standard tables: all or nothing; elastic: partial success |
Batch and ExecuteMultiple save round trips but not platform work: each inner operation is processed separately and counts as a request. The bulk operation messages are different. CreateMultiple, UpdateMultiple, UpsertMultiple and DeleteMultiple send a collection of rows of one table in a single message, which the platform processes as a set. Microsoft's documentation describes them as giving the best throughput for high-volume work.
The bulk operation messages
Microsoft's documentation, updated in October 2026, sets out where each message applies. CreateMultiple and UpdateMultiple are available for custom tables, many standard tables and all elastic tables. UpsertMultiple is available for standard tables only where both CreateMultiple and UpdateMultiple are supported. DeleteMultiple is available for elastic tables only; for standard tables, large deletions use the BulkDelete operation, which runs as a background job.
// C#: create 500 archive rows in one CreateMultiple request.
var targets = new EntityCollection { EntityName = "lcc_workorderarchive" };
foreach (var r in chunk) // chunk: up to 500 source rows
{
targets.Entities.Add(new Entity("lcc_workorderarchive")
{
["lcc_legacyid"] = r.LegacyId, // alternate key from the old system
["lcc_building"] = r.BuildingCode,
["lcc_opened"] = r.Opened,
["lcc_closed"] = r.Closed,
["lcc_category"] = r.Category
});
}
var response = (CreateMultipleResponse)client.Execute(new CreateMultipleRequest { Targets = targets });
log.LogInformation("Created {Count} rows", response.Ids.Length);POST https://lumenvale.crm3.dynamics.com/api/data/v9.2/lcc_workorderarchives/Microsoft.Dynamics.CRM.UpsertMultiple
Content-Type: application/json
{
"Targets": [
{
"@odata.type": "Microsoft.Dynamics.CRM.lcc_workorderarchive",
"@odata.id": "lcc_workorderarchives(lcc_legacyid='FW-2016-00412')",
"lcc_building": "DTN",
"lcc_category": "Plumbing"
},
…
]
}Choosing a batch size
There is no single best batch size. For standard tables, Microsoft's guidance is to start with somewhere between 100 and 1,000 rows per request and make the size configurable, because the right number depends on how many columns each row has, how much plug-in logic runs and how long each request takes. For elastic tables the guidance is to send about 100 rows per request and to send requests in parallel. Larger requests take longer and come closer to the client's timeout; ServiceClient's default timeout is four minutes, compared with two minutes for the older CrmServiceClient.
Size matters in a second way. When a plug-in is registered for the operation, a request larger than about 116.85 megabytes can fail. Requests that are allowed to bypass custom plug-in logic, using the optional parameter for that purpose and a caller with the privilege it requires, are not subject to that size limit. Bypassing plug-ins is a deliberate decision, not a performance trick: it also bypasses the business rules those plug-ins enforce, so it belongs only in jobs such as historical migrations where the rules were enforced in the source system or are checked separately.
Worked problem
Estimating the archive load
Wiremu must load 250,000 archive rows. With one Create per row, how many requests is that, and at most 6,000 requests per five minutes for one application user, what is the least time the request limit allows? With CreateMultiple at 500 rows per request, how many requests are needed?
Show solution
- One row per request: 250,000 requests.
- 250,000 divided by 6,000 is about 41.7 windows of five minutes, so at least about 208 minutes, nearly three and a half hours, even before execution-time limits.
- With 500 rows per CreateMultiple request: 250,000 divided by 500 is 500 requests, far below the request limit.
Answer: 250,000 single requests needing at least about 208 minutes by the request limit alone, against 500 bulk requests. Execution time then becomes the main constraint, which is why the batch size is tuned by testing.
Errors and transactions
Error behaviour differs by table type, and the difference matters for design. On standard tables a bulk request is a single transaction: if any row fails, for example because of a validation error in a plug-in, the whole request is rolled back and no rows in it are written. The client must find and fix the bad row, or split the batch and retry the parts. On elastic tables, bulk requests can partly succeed: the response reports which rows failed and why, and the rest are written. A job writing to elastic tables must read the error details and retry or log only the failed rows.
Wiremu's archive job handled the standard-table case by validating every row before sending it, writing rows that failed validation to an error file, and splitting any batch that still failed into halves until the failing row was isolated. The approach meant that one bad record cost a few extra requests rather than the whole run.
Bulk operations and plug-ins
The event pipelines for single and bulk operations are merged. When a client calls CreateMultiple, Dataverse also raises the single-row Create event for each row, so plug-ins registered on Create still run for every row. Plug-ins can also be registered on the bulk messages themselves; such a plug-in runs once per request and receives the whole collection, which can be much more efficient. The consequence is a warning in Microsoft's guidance: if the same logic is registered on both the single and the bulk message, it runs twice. Teams should choose one place for each piece of logic. Bulk messages cannot be called from inside plug-ins.
Signe reviewed Lumenvale's plug-ins with that in mind. The work-order validation plug-in from the earlier series was registered on Update of a single row, which was correct for forms and flows. If the archive job later needed the same validation, the plug-in would run once per row through the merged pipeline, which was acceptable for 500-row batches, and no duplicate registration on UpdateMultiple was needed.
Request limits versus entitlements
Two different counters apply to integration traffic, and they are easy to confuse. Service protection limits protect the service in real time, per user, over five minutes; a bulk request counts as one request against them. Power Platform request entitlements are a licensing measure of how many requests each licence or application user may make over a day; for entitlements, each row in a bulk request counts. Bulk operations therefore make jobs faster and less likely to be throttled, but they do not reduce the volume counted for licensing. Rupert's team tracked integration volumes against entitlements in the admin centre's reports.
Reading large volumes
Reading has its own tools. Queries should select only needed columns and page with the next link, as Lesson 1 described. Very large exports for analytics should not page through the Web API at all; Lesson 8 covers Azure Synapse Link and Link to Microsoft Fabric, which exist for exactly that purpose. Reading should also avoid patterns that look efficient but are not, such as retrieving each row's related rows one at a time; an expand option or a single FetchXML query with a join usually does the same work in one request.
Running a large job responsibly
| Practice | Reason |
|---|---|
| Run in the evening or at weekends where possible | Leaves capacity for people during working hours |
| Use a dedicated application user | Its limits are separate from people's and its changes are identifiable |
| Use the recommended degree of parallelism | Best throughput without throttling |
| Respect Retry-After | Immediate retries only add to the load |
| Make batch size and parallelism configurable | They can be tuned without a code change |
| Log progress and make the job restartable | A failure halfway does not mean starting again |
| Test first in a sandbox with production-like volume | Limits and timeouts only appear at volume |
The archive load ran over a weekend in Wiremu's test environment first and then, after review, was scheduled for the research team's archive. Wiremu kept the job's settings in configuration, with a batch size of 500 and the recommended parallelism, and the job wrote its progress to a log so that it could resume from the last completed batch.
Testing at realistic volume
Most problems with large jobs only appear at volume. A job that works with fifty test rows may time out with five hundred per batch, hit an execution-time limit when plug-ins run on every row, or slow down sharply when a lookup has no index. Wiremu's test plan for the archive load copied a realistic slice of the old database, 25,000 rows, into a sandbox and ran the job with three batch sizes, recording the duration and the number of 429 responses for each. The middle setting gave the best result, and the numbers went into the job's documentation so that the next person to tune it would not start from guesswork.
He also measured what the job did to everyone else. While the test ran, Signe opened the Facilities app in the same sandbox and timed a few common actions. Because the job used its own application user and the recommended parallelism, forms opened at their usual speed; the platform shared capacity fairly between users.
Common mistakes
MistakeRetrying immediately after a 429 response.
InsteadWait for the Retry-After interval, then retry.
MistakeAssuming a batch request avoids service protection limits.
InsteadEach request inside a batch counts; use bulk operation messages for volume.
MistakeRegistering the same plug-in logic on Create and on CreateMultiple.
InsteadChoose one; the pipelines are merged and duplicate logic runs twice.
MistakeHard-coding a batch size of 1,000.
InsteadMake it configurable and tune it by testing.
MistakeBypassing plug-ins to speed up any large job.
InsteadBypass only when the business rules are enforced elsewhere and the caller is authorized.
MistakeExpecting bulk operations to reduce licensing request counts.
InsteadEach row still counts toward request entitlements.
Summary and key terms
- Service protection limits are 6,000 requests, 20 minutes of execution time and 52 concurrent requests per user over five minutes; exceeding them returns 429 with Retry-After.
- Batch and ExecuteMultiple save round trips, but each inner request counts against limits.
- CreateMultiple, UpdateMultiple, UpsertMultiple and DeleteMultiple process sets of rows in one message and count as one request against service protection limits.
- Start with 100 to 1,000 rows per request for standard tables and about 100 for elastic tables, configurable and tuned by testing.
- Bulk requests on standard tables roll back entirely on error; on elastic tables they can partly succeed.
- Single and bulk pipelines are merged; avoid registering the same logic on both.
- Service protection limits
- Per-user limits on requests, execution time and concurrency that Dataverse enforces over a sliding window to protect the service.
- Retry-After
- A response header that tells a throttled client how long to wait before retrying.
- ExecuteMultiple
- An SDK message that sends up to 1,000 requests together, each processed separately.
- CreateMultiple
- A bulk operation message that creates many rows of one table in a single request.
- BulkDelete
- A background job that deletes large numbers of rows in standard tables.
- Request entitlements
- The licensing allowance of Power Platform requests per user or application over a day.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why did Wiremu's single-row loop start receiving 429 responses?
Show answer
It exceeded a service protection limit for its user over the five-minute window.
Which bulk message would you use to delete a million rows from a standard table?
Show answer
BulkDelete, because DeleteMultiple is for elastic tables only.
A CreateMultiple request of 500 rows on a standard table fails because one row is invalid. How many rows were created?
Show answer
None; the whole request is rolled back.
Does a bulk request reduce the count toward request entitlements?
Show answer
No; each row counts toward entitlements even though the request counts once for service protection.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.