/// <summary>
        /// Increment the sequence number of the event stream
        /// </summary>
        private async Task IncrementSequence(string writeStreamLeaseId = "")
        {
            if (null != EventStreamBlob)
            {
                bool exists = await EventStreamBlob.ExistsAsync();

                if (exists)
                {
                    await EventStreamBlob.FetchAttributesAsync();

                    int sequenceNumber;
                    if (int.TryParse(EventStreamBlob.Metadata[METADATA_SEQUENCE], out sequenceNumber))
                    {
                        sequenceNumber += 1;
                        EventStreamBlob.Metadata[METADATA_SEQUENCE] = $"{sequenceNumber }";
                        // and commit it back
                        AccessCondition condition = AccessCondition.GenerateEmptyCondition();
                        if (!string.IsNullOrWhiteSpace(writeStreamLeaseId))
                        {
                            condition.LeaseId = writeStreamLeaseId;
                        }
                        await EventStreamBlob.SetMetadataAsync(condition, null, new Microsoft.Azure.Storage.OperationContext());
                    }
                }
            }
        }
        /// <summary>
        /// Make sure the blob info attributes are up to date
        /// </summary>
        /// <remarks>
        /// This is similar in concept to FileSystemInfo.Refresh
        /// </remarks>
        public async Task Refresh()
        {
            if (EventStreamBlob != null)
            {
                bool exists = await EventStreamBlob.ExistsAsync();

                if (exists)
                {
                    // just refresh the attributes
                    await EventStreamBlob.FetchAttributesAsync();
                }
                else
                {
                    exists = await EventStreamBlob.Container.ExistsAsync();

                    if (!exists)
                    {
                        await EventStreamBlob.Container.CreateAsync();
                    }
                    await EventStreamBlob.CreateOrReplaceAsync();

                    // Set the original metadata
                    EventStreamBlob.Metadata[METATDATA_DOMAIN]          = DomainName;
                    EventStreamBlob.Metadata[METADATA_ENTITY_TYPE_NAME] = EntityTypeName;
                    EventStreamBlob.Metadata[METADATA_INSTANCE_KEY]     = InstanceKey;
                    EventStreamBlob.Metadata[METADATA_SEQUENCE]         = @"0";
                    EventStreamBlob.Metadata[METADATA_DATE_CREATED]     = DateTime.UtcNow.ToString("O");
                    // and commit it back
                    await EventStreamBlob.SetMetadataAsync();
                }
            }
        }