Updating a Microsoft Teams resource through Microsoft Graph looks straightforward until two operations try to change the same resource at nearly the same time.

A typical .NET application may read a Teams resource, change one property, and send an update back to Microsoft Graph. That works when the application is the only writer.

The situation changes when multiple users, services, automation jobs, or Teams clients modify the same resource concurrently.

For example:

Code
Application A
    |
    | Read resource
    |
    v
Current state

Application B
    |
    | Update same resource
    |
    v
Resource changed

Application A
    |
    | Send update based on old state
    v
Conflict

A conflict means that the state your application used to build its update is no longer the same state held by the service.

Microsoft Graph uses HTTP status codes and response headers to communicate these situations. For supported APIs, optimistic concurrency can also use ETags and If-Match headers to prevent an application from overwriting a resource that changed after it was read.

The important lesson is that a concurrency conflict is not simply a request failure. It is information that the application must use to decide whether to retry, refresh the resource, merge the change, or ask the user to resolve the conflict.

Why Concurrent Updates Happen

Concurrent updates are common in Teams environments because several actors can interact with the same resource.

For example:

Code
Teams client
       |
       +------+
              |
Administrator --+--> Same Teams resource
              |
Automation ----+
              |
.NET service --+

A resource might be changed by:

  • A Teams user

  • A Teams administrator

  • Another application

  • A background synchronization service

  • A scheduled automation job

  • Microsoft 365 service processes

The problem becomes visible when your application follows a read-modify-write pattern.

For example:

Code
1. Read resource.
2. Change local object.
3. Send complete update.

Between steps 1 and 3, another process may update the resource.

Your application is then working with stale data.

The Lost Update Problem

Consider a Teams resource containing:

Code
Display name = Engineering
Description = Engineering team

Application A reads it.

At the same time, Application B changes the description:

Code
Display name = Engineering
Description = Engineering and Platform team

Application A still has:

Code
Display name = Engineering
Description = Engineering team

Application A changes the display name:

Code
Display name = Product Engineering
Description = Engineering team

If Application A sends the entire object without concurrency protection, it may accidentally replace the newer description with the older value.

This is called a lost update.

The intended change was only the display name.

The unintended side effect was overwriting another application's newer description.

Optimistic Concurrency

The normal solution is optimistic concurrency.

The application does not lock the resource before reading it.

Instead, it reads the resource and records a version identifier, commonly represented by an ETag.

The workflow becomes:

SQL
Read resource
      |
      v
Receive ETag
      |
      v
Modify local state
      |
      v
Send update with If-Match
      |
      +---- Resource unchanged ---> Update succeeds
      |
      +---- Resource changed ----> Conflict

This is different from pessimistic locking.

With pessimistic locking, the application attempts to prevent other writers from changing the resource while it works.

With optimistic concurrency, the application assumes that conflicts are uncommon and checks whether the resource changed before committing the update.

For distributed cloud APIs, optimistic concurrency is generally more practical.

What an ETag Represents

An ETag is a version identifier associated with a particular representation of a resource.

Suppose the API returns:

Code
ETag: "abc123"

Your application stores that value along with the object.

Later, it sends:

Code
If-Match: "abc123"

The service can then determine whether the resource is still based on the same version.

If another operation changed the resource, the ETag no longer matches.

The service can reject the update instead of silently overwriting the newer state.

The exact concurrency behavior depends on the specific Microsoft Graph resource and operation, so developers should check the API documentation for the Teams endpoint they are using.

Why the Conflict Response Matters

One of the most important changes in a production application is how it interprets the response.

A concurrency conflict should not automatically trigger:

Code
Retry
Retry
Retry
Retry

That can make the problem worse.

The correct behavior depends on why the conflict occurred and what your application is trying to change.

For example:

SQL
Conflict
   |
   +-- Refresh resource
   |
   +-- Compare changes
   |
   +-- Reapply safe change
   |
   +-- Retry once
   |
   +-- Ask user if changes overlap

The response therefore becomes part of the application's concurrency algorithm.

Start With the Actual API Contract

Before implementing conflict handling, identify the exact Teams resource and Graph operation.

“Teams update” is not one API.

Your application could be updating:

  • A team

  • A channel

  • A channel membership

  • A team member

  • A message

  • A tab

  • A meeting-related resource

  • A Teams app installation

  • Another Microsoft Graph resource associated with Teams

Each endpoint can have different update semantics.

Do not copy concurrency logic from one Teams endpoint and assume it applies to another.

Read the API contract for the exact operation your application uses.

Use Narrow Updates

One of the best ways to reduce concurrency problems is to update only what the application actually needs to change.

Suppose your application only changes a team's description.

Avoid building a workflow like:

Code
Read entire team
      ↓
Modify local team object
      ↓
Send entire team object

when the API supports a targeted update.

Instead:

Code
Read required state
      ↓
Modify description
      ↓
Send description change

Narrow updates reduce the number of properties that can accidentally overwrite changes made by another writer.

This is especially important when multiple systems share responsibility for the same Teams resource.

A Basic .NET Graph Update Pattern

A .NET application using Microsoft Graph might have a service method similar to:

C#
public async Task UpdateTeamAsync(
    string teamId,
    string description,
    CancellationToken cancellationToken)
{
    var team = await graphClient.Teams[teamId]
        .GetAsync(cancellationToken: cancellationToken);

    if (team == null)
    {
        throw new InvalidOperationException(
            "The Teams resource was not found.");
    }

    var update = new Team
    {
        Description = description
    };

    await graphClient.Teams[teamId]
        .PatchAsync(
            update,
            cancellationToken: cancellationToken);
}

This demonstrates the basic update operation, but it does not yet provide concurrency protection.

A production implementation should consider the versioning and conflict behavior documented for the specific Graph endpoint.

Do Not Blindly Retry 409 Responses

A common implementation mistake is:

C#
for (var i = 0; i < 5; i++)
{
    try
    {
        await UpdateAsync();
        return;
    }
    catch
    {
        await Task.Delay(1000);
    }
}

This is dangerous.

If the failure is a real concurrency conflict, repeating the exact same stale update does not solve the problem.

The application must refresh its state first.

A better conceptual algorithm is:

Code
Attempt update
      |
      v
Conflict?
      |
     Yes
      |
      v
Read latest resource
      |
      v
Recalculate intended update
      |
      v
Try again

The important step is recalculation.

Do not simply resend the same stale object.

Recalculate the Update After a Conflict

Suppose the user changes only the team description.

Your application originally read:

Code
Name: Engineering
Description: Engineering team

Another application changes:

Code
Name: Engineering
Description: Engineering and Platform team

Your user still wants:

Code
Description: Engineering delivery team

After detecting the conflict, refresh the resource:

Code
Current resource:
Name: Engineering
Description: Engineering and Platform team

Then apply only the user's intended change:

Code
Name: Engineering
Description: Engineering delivery team

This preserves the latest name and other changes.

The important distinction is between:

Code
Desired change

and:

Code
Stale copy of the resource

Your application should retry the desired change, not the stale resource snapshot.

Build a Conflict-Aware Service

A clean service can separate these responsibilities.

C#
public async Task UpdateDescriptionAsync(
    string teamId,
    string newDescription,
    CancellationToken cancellationToken)
{
    for (var attempt = 1; attempt <= 2; attempt++)
    {
        var current = await GetTeamAsync(
            teamId,
            cancellationToken);

        try
        {
            await ApplyDescriptionUpdateAsync(
                teamId,
                current,
                newDescription,
                cancellationToken);

            return;
        }
        catch (GraphServiceException ex)
            when (IsConcurrencyConflict(ex) &&
                  attempt == 1)
        {
            continue;
        }
    }

    throw new InvalidOperationException(
        "The Teams resource changed while it was being updated.");
}

The exact Graph exception and response handling should be implemented according to the Graph SDK version and endpoint being used.

The important design decision is the retry limit.

One refresh-and-retry is often much safer than an unlimited retry loop.

When a Retry Is Not Safe

Not every update should automatically be retried.

Suppose the user is editing a complex configuration with several fields:

Code
Name
Description
Owners
Membership settings
Visibility
Custom metadata

Another administrator changes one of those values at the same time.

If your application simply reloads the resource and overwrites everything with the user's local copy, you can still lose changes.

For these scenarios, use explicit conflict resolution.

For example:

Code
Conflict detected

Your change:
Description = Product Engineering

Latest server value:
Description = Platform Engineering

Choose:
[Keep Server]
[Use My Change]
[Review]

This is better than silently selecting one side.

Separate Automatic and Manual Conflict Resolution

A useful rule is:

Code
Non-overlapping change
        |
        v
Automatic merge

Overlapping change
        |
        v
Manual resolution

For example, if one application changes the description and another changes a different property, an automatic merge may be reasonable.

If both applications change the description, the application should consider asking the user.

This requires your application to understand the fields being modified.

That is why keeping update operations narrow is so valuable.

Store the Original State

For complex editing screens, keep the original state when the user begins editing.

For example:

Code
Original:
Name = Engineering
Description = Platform team

User changes:
Name = Product Engineering

Server changes:
Description = Cloud Platform team

When the user submits, the application can compare:

SQL
Original
    |
    +-- Name
    +-- Description

User version
    |
    +-- Name changed
    +-- Description unchanged

Server version
    |
    +-- Name unchanged
    +-- Description changed

The application can then determine that the changes do not overlap.

This is a much better conflict-resolution model than treating the resource as one large object.

Understand the Difference Between 409 and Other Errors

Do not classify every unsuccessful update as a concurrency problem.

A request can fail because of:

  • Authentication

  • Authorization

  • Invalid input

  • Missing resource

  • Unsupported operation

  • Throttling

  • Temporary service failure

  • Concurrency

  • Network failure

A conflict response should be handled according to the documented behavior of the endpoint.

Other errors require different strategies.

For example:

Code
401
Authentication problem

403
Permission problem

404
Resource not found

409
Conflict or resource state problem

429
Throttling

5xx
Service-side failure

The exact meaning of a status code depends on the API operation, so your error handling should also inspect the response body and Graph error information rather than relying only on the numeric status code.

Handle Throttling Separately

Concurrency retry logic and throttling retry logic should not be mixed.

For throttling, Microsoft Graph can return retry-related information that should be respected.

Conceptually:

Code
429
 |
 +-- Read retry information
 |
 +-- Wait appropriate duration
 |
 +-- Retry request

For concurrency:

Code
Conflict
 |
 +-- Refresh resource
 |
 +-- Recalculate update
 |
 +-- Retry safely

These are different failure modes.

Combining them into one generic “retry everything” method usually creates unreliable behavior.

Add Idempotency Where Appropriate

An update operation should ideally be safe to repeat.

Suppose your application wants:

Code
Description = Engineering Platform

Sending that same final value more than once produces the same logical state.

That is much easier to retry safely than an operation such as:

Code
Add 100 points to counter

For administrative Teams operations, prefer state-setting operations where the API supports them rather than designing repeated side effects.

The goal is to make retry behavior predictable.

Use Cancellation Tokens

A conflict-resolution loop should not continue indefinitely if the user closes the application or the request is cancelled.

Use cancellation tokens throughout the Graph operation.

For example:

Code
await graphClient.Teams[teamId]
    .GetAsync(
        cancellationToken: cancellationToken);

and:

Code
await graphClient.Teams[teamId]
    .PatchAsync(
        update,
        cancellationToken: cancellationToken);

This becomes particularly important in web applications where requests can be cancelled by the client.

Add Structured Logging

When a concurrency problem occurs, logs should explain the sequence.

A useful log might contain:

VB.NET
Operation: UpdateTeamDescription
TeamId: 8f3c...
Attempt: 1
Result: Conflict
Action: Refresh resource
Attempt: 2
Result: Success

Avoid logging sensitive content unnecessarily.

The log should make it possible to answer:

  • Which resource was being updated?

  • Which operation was attempted?

  • Was there a conflict?

  • Did the application refresh?

  • Was the retry successful?

  • Did the user eventually receive an error?

This is especially useful when an application occasionally reports “save failed” but developers cannot reproduce the problem locally.

Testing Concurrent Updates

Concurrency bugs are difficult to find if you test only one client.

Create tests with two independent writers.

For example:

Code
Client A
   |
   | Read version 1
   |
   +--------------------+
                        |
Client B                |
   |                    |
   | Read version 1     |
   |                    |
   | Update              |
   v                    |
Version 2                |
                        |
Client A                |
   |                    |
   | Update version 1   |
   v                    |
Conflict <---------------+

Then verify that your application:

  1. Detects the conflict.

  2. Refreshes the resource.

  3. Recalculates its intended change.

  4. Retries when safe.

  5. Preserves unrelated changes.

  6. Reports overlapping conflicts clearly.

Do not rely on manual testing alone.

Concurrency behavior should be covered by automated integration tests where practical.

Common Mistakes

Retrying the same stale request

A stale request does not become correct merely because it was sent again.

Refresh the resource and recalculate the update.

Treating every 409 as identical

Different APIs can use conflict responses differently.

Always check the documentation for the exact endpoint.

Updating the entire resource unnecessarily

Broad updates increase the chance of overwriting another writer's changes.

Prefer narrow updates.

Hiding conflicts from users

For overlapping edits, silently choosing one version can cause data loss.

Give the user a meaningful conflict-resolution experience.

Using unlimited retries

An active conflict can turn into an endless retry loop.

Use bounded retries.

Mixing concurrency and throttling logic

A concurrency conflict requires state refresh.

Throttling requires waiting according to service guidance.

They are different problems.

Testing only with one application instance

Single-writer testing cannot expose many concurrency bugs.

Use multiple independent writers during testing.

A Practical Conflict-Handling Architecture

A production .NET application can structure its update pipeline like this:

SQL
User changes Teams resource
          |
          v
Application validates change
          |
          v
Read current state
          |
          v
Send targeted update
          |
     +----+----+
     |         |
  Success   Conflict
     |         |
     v         v
 Return    Refresh state
              |
              v
        Recalculate change
              |
        +-----+-----+
        |           |
     Safe        Overlapping
     merge          change
        |           |
        v           v
     Retry      Ask user

Around this flow, add:

Code
Authentication
Authorization
Logging
Cancellation
Throttling handling
Validation
Audit

This produces a much more predictable administration system.

When Optimistic Concurrency Is Enough

Optimistic concurrency works particularly well when conflicts are relatively uncommon.

For example:

Code
User opens settings
      |
      v
Edits one property
      |
      v
Saves

If conflicts are rare, checking the version and retrying once is usually enough.

If the same resource is being updated continuously by several services, however, conflicts may become frequent.

At that point, the architecture may need stronger coordination.

Possible approaches include:

  • Partitioning ownership by property

  • Assigning one service as the authoritative writer

  • Serializing updates

  • Moving shared state into a dedicated service

  • Reducing the number of competing writers

Optimistic concurrency detects conflicting writes. It does not eliminate the underlying competition.

Advantages and Disadvantages

Advantages:

  • Prevents many accidental lost updates.

  • Works well in distributed applications.

  • Does not require long-lived resource locks.

  • Can be combined with narrow updates.

  • Allows automatic retry for safe conflicts.

  • Makes concurrent changes visible to the application.

Disadvantages:

  • Conflict handling adds implementation complexity.

  • Not every conflict can be merged automatically.

  • Broad updates make conflict resolution harder.

  • Incorrect retries can still overwrite newer data.

  • Different Microsoft Graph endpoints can have different concurrency semantics.

  • High-contention resources may require architectural changes beyond simple retry logic.

The goal is not to eliminate every conflict.

The goal is to detect conflicts early and handle them without losing valid changes.

Production Checklist

Before deploying a .NET application that updates Teams resources through Microsoft Graph, verify:

  • The exact Teams resource and Graph endpoint are documented.

  • The update operation's concurrency behavior is understood.

  • ETags or version information are used when supported.

  • Updates are as narrow as possible.

  • Conflicts are detected explicitly.

  • Stale updates are not blindly retried.

  • A fresh resource is retrieved after a conflict.

  • The intended user change is recalculated before retrying.

  • Automatic retries are bounded.

  • Overlapping changes can be surfaced to the user.

  • Throttling is handled separately from concurrency conflicts.

  • Cancellation tokens are passed through Graph calls.

  • Structured logging records conflict attempts.

  • Sensitive Teams data is not unnecessarily written to logs.

  • Integration tests include multiple concurrent writers.

  • The application does not assume that every Teams Graph endpoint behaves identically.

Summary

Concurrent updates are a normal part of Microsoft 365 applications.

A .NET application that reads a Teams resource and later writes it back cannot assume that the resource is unchanged. Another user, service, or Teams client may have modified it between those two operations.

The basic safe pattern is:

Code
Read
  ↓
Capture version
  ↓
Make targeted change
  ↓
Update with concurrency protection
  ↓
Success

When a conflict occurs:

Code
Conflict
   ↓
Read latest state
   ↓
Compare changes
   ↓
Reapply only the intended change
   ↓
Retry if safe
   ↓
Ask the user if changes overlap

The key lesson is that a conflict response should change what the application does next. It should not simply trigger another copy of the same stale request.

When Microsoft Graph's concurrency behavior changes or becomes stricter for a particular Teams operation, applications that already have explicit conflict handling are much easier to adapt. The safest design is therefore to keep Graph calls behind a service layer, make updates narrow, treat concurrency as a normal application state, and verify the exact behavior of each API endpoint before implementing retry logic.