private static RESTCommand <IList <TableResult> > BatchImpl(TableBatchOperation batch, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { RESTCommand <IList <TableResult> > batchCmd = new RESTCommand <IList <TableResult> >(client.Credentials, client.StorageUri); requestOptions.ApplyToStorageCommand(batchCmd); List <TableResult> results = new List <TableResult>(); batchCmd.CommandLocationMode = batch.ContainsWrites ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; batchCmd.RetrieveResponseStream = true; batchCmd.SignRequest = client.AuthenticationHandler.SignRequest; batchCmd.ParseError = ODataErrorHelper.ReadFromStreamUsingODataLib; batchCmd.BuildRequestDelegate = (uri, builder, timeout, useVersionHeader, ctx) => { Tuple <HttpWebRequest, Stream> res = TableOperationHttpWebRequestFactory.BuildRequestForTableBatchOperation(uri, builder, client.BufferManager, timeout, table.Name, batch, useVersionHeader, ctx, requestOptions); batchCmd.SendStream = res.Item2; batchCmd.StreamToDispose = res.Item2; return(res.Item1); }; batchCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp != null ? resp.StatusCode : HttpStatusCode.Unused, results, cmd, ex); batchCmd.PostProcessResponse = (cmd, resp, ctx) => TableOperationHttpResponseParsers.TableBatchOperationPostProcess(results, batch, cmd, resp, ctx, requestOptions, client.AccountName); batchCmd.PostProcessResponseAsync = async(cmd, resp, ctx) => await TableOperationHttpResponseParsers.TableBatchOperationPostProcessAsync(results, batch, cmd, resp, ctx, requestOptions, client.AccountName, System.Threading.CancellationToken.None); batchCmd.RecoveryAction = (cmd, ex, ctx) => results.Clear(); return(batchCmd); }