private void SetupObjectContainerHeader()
        {
            // This method needs to set up the writer to do it's thing.
            // There are two use cases for this writer.
            // 1.  This is a brand new, "in-memory" representation of the writer.
            // 2.  This is an existing blob, so we need to get the object container from blob storage.

            // First, we need to check if the blob exists.
            if (!this.blockBlob.Exists())
            {
                // The blob does not exist, we just create a new header and we are good
                this.syncMarker = new byte[16];
                new Random().NextBytes(syncMarker);
                this.header = new ObjectContainerHeader(syncMarker)
                {
                    CodecName = this.codec.Name,
                    Schema    = this.serializer.WriterSchema.ToString()
                };

                // Since we are treating everything as in memory, we're going to fake the block list since we know there are none as of now.
                this.blockNames = new List <string>();
            }
            else
            {
                // If the blob exists, we need to fetch our stuff so we can read
                this.ReadObjectContainerHeaderFromBlob();
            }
        }
        private void ReadObjectContainerHeaderFromBlob()
        {
            this.blockBlob.FetchAttributes();


            // Deserialize the header from blob storage.  We will only download the size of the header from blob storage.
            using (var stream = this.blockBlob.OpenRead())
            {
                using (var decoder = new BinaryDecoder(stream, true))
                {
                    this.header = ObjectContainerHeader.Read(decoder);
                }
            }

            // We also need to set up the block list for appending.  Since we already have it, let's use it.
            // Get the existing block list.
            var blockList = this.blockBlob.DownloadBlockList(BlockListingFilter.Committed);

            this.blockNames = blockList
                              .Select(lbi => lbi.Name)
                              .ToList();

            // Set this so the writer doesn't try to write the header again.
            this.isHeaderWritten = true;
        }