private void EnsureSizeOrResize(int bytes) { // since lucene does not do random writes, we can safely assume // that there have been no bytes written beyond the last recorded // blob position when the blob has been already sized to be large // enough to accomodate the minSize bytes specified. // this would only be from a previous resize operation having // grown the file to a large enough size and not all bytes being // used up thereafter. if (_lastPageOffset > _currPagePosition + bytes) { // no need to resize. return; } // calculate number of new pages to add w/ a buffer of 512KB. long newLastPageOffset = GetCurrentPageOffset() + ((bytes / PageSize) * PageSize) + 512; // resize blob. _ = _pageBlobClient.Resize(newLastPageOffset); // save actual bytes required. _metadata["actuallength"] = bytes.ToString(); _pageBlobClient.SetMetadata(_metadata); // record the new offset for the last page. _lastPageOffset = newLastPageOffset; }