I am using version 4.3.0 for Windows Azure libraries for .NET. In my ATS repository class, I have several batch removal methods that look like this:
public async Task DeleteAsync(IEnumerable<T> entities) { await ExecuteAsBatch(entities, (batch, entity) => batch.Delete(entity)); } private async Task ExecuteAsBatch(IEnumerable<T> entities, Action<TableBatchOperation, T> batchAction) { var byPartition = entities.GroupBy(x => x.PartitionKey).ToList(); await byPartition.ForEachParallel(async group => {
Elsewhere in my code, this DeleteAsync() method works correctly. However, in one specific place, I get this error message while executing a package:
Unexpected Response Code for Operation: 0
Here's the call site:
private async Task MergeAtsOrganizationUserEvents(int organizationId, IEnumerable<CustomerUserEvent> fromEvents, CustomerUser to) { var toDelete = (await fromEvents.SelectParallel(async fromEvent => { var pkey = AtsOrganizationUserEventByMinute.GetPartitionKey(organizationId, fromEvent.OccurredOn); var rkey = AtsOrganizationUserEventByMinute.GetRowKey(fromEvent.OccurredOn, fromEvent.CustomerUserEventId); return await Ats.OrganizationUserEventByMinute.FindByPartitionRowAsync(pkey, rkey); })).Where(x => x != null).ToList(); var toInsert = toDelete .Select(x => AtsOrganizationUserEventByMinute.FromBase(x.OrganizationId, x.OccurredOn, x.CookieId, to.CustomerUserId, x)) .ToList(); try { await Ats.OrganizationUserEventByMinute.UpsertAsync(toInsert); await Ats.OrganizationUserEventByMinute.DeleteAsync(toDelete); } catch (Exception ex) { _logger.Error("Unable to merge {0} AtsOrganizationEvents for org {1}, to customer user {2}: {3}", toInsert.Count, organizationId, to.CustomerUserId, ex.CompleteMessage()); throw; } }
UpsertAsync() method UpsertAsync() , but DeleteAsync() fails. Please note that it does not delete exactly the same objects that FindByPartitionRowAsync() retrieved from the table, so I cannot imagine how this could have anything to do with distorted objects or anything from this file.
Here is an example of one of the "toDelete" objects (in JSON format):
{ "CookieId":null, "CustomerUserId":185766, "CustomerUserEventId":3568687, "OrganizationId":4190, "EventName":"event1", "SessionId":null, "OccurredOn":"2014-10-20T18:17:09.9971379Z", "UrlId":null, "Url":null, "ReferrerUrlId":null, "ReferrerUrl":null, "IsSynthetic":false, "IpAddress":null, "PartitionKey":"4190.2014.10.20", "RowKey":"18.17.3568687", "Timestamp":"2014-10-20T18:17:11.237+00:00", "ETag":"W/\\" datetime'2014-10-20T18%3A17%3A11.237Z'\\"" }
Azure Storage error messages are known and impressively useless, and Googling did not respond that batch deletes did not run with this particular error.
This does not work when using the local development repository, or during the production process.
Any thoughts?