Skip to content

Instantly share code, notes, and snippets.

@davidobrien1985
Created September 11, 2021 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidobrien1985/afa527c9a8648cafe52043d7dcb5097a to your computer and use it in GitHub Desktop.
Save davidobrien1985/afa527c9a8648cafe52043d7dcb5097a to your computer and use it in GitHub Desktop.
repro
public class InventoryBulkStorage : IInventoryBulkStorage
{
private readonly CosmosContainer _containerId = CosmosContainer.Inventory;
private readonly bool _isBulk = true;
public async Task UpsertBulkAsync(IEnumerable<InventoryResource> resources)
{
var containers = CosmosProvider.Containers
.Where(c => c.ContainerId == _containerId && c.IsBulk == _isBulk)
.ToDictionary(k => k.Region, v => v.Container);
var concurrentTasks = new List<Task>();
foreach (var resource in resources)
{
var region = await AppDataCache.GetCustomerRegionAsync(resource.CustomerId);
concurrentTasks.Add(containers[region].UpsertItemAsync(resource, new PartitionKey(resource.CustomerId), new ItemRequestOptions()
{
EnableContentResponseOnWrite = false,
}));
}
await Task.WhenAll(concurrentTasks);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment