/// <summary>Gets a blob from Azure Storage as just raw bytes with metadata</summary>
        /// <param name="containerName">container name</param>
        /// <param name="blobName">blob name</param>
        /// <returns>Wrapped raw bytes with some metadata</returns>
        public RawFileWrapper GetRawBlob(string containerName, string blobName)
        {
            RawFileWrapper results = new RawFileWrapper();

            // validate input
            if (String.IsNullOrWhiteSpace(containerName) || String.IsNullOrWhiteSpace(blobName))
            {
                return(results);
            }

            containerName = containerName.Trim();
            blobName      = blobName.Trim();

            // Get a reference to a share and then create it
            BlobContainerClient container = new BlobContainerClient(this.ConnectionString, containerName);

            // check the container exists
            Response <bool> exists = container.Exists();

            if (!exists.Value)
            {
                return(results);
            }

            // set options
            BlobOpenReadOptions op = new BlobOpenReadOptions(false);

            // read the blob to an array
            BlobClient blob = container.GetBlobClient(blobName);

            using Stream stream = blob.OpenRead(op);
            results.Data        = new byte[stream.Length];
            stream.Read(results.Data, 0, results.Data.Length);
            stream.Close();

            // get the properties
            BlobProperties props = blob.GetProperties().Value;

            if (props == null)
            {
                return(results);
            }

            results.ContentType = props.ContentType;

            // get a filename
            if (props.Metadata.ContainsKey("filename"))
            {
                results.Filename = props.Metadata["filename"].ToString();
            }
            else
            {
                results.Filename = blob.Name;
            }

            return(results);
        }
        /// <summary>Gets a blob from Azure Storage BASE64 encoded and wrapped in JSON</summary>
        /// <param name="containerName">container name</param>
        /// <param name="blobName">blob name</param>
        /// <returns>The encoded blob with metadata</returns>
        public JSONFileWrapper GetWrappedBlob(string containerName, string blobName)
        {
            JSONFileWrapper results = new JSONFileWrapper();

            // get the blob
            RawFileWrapper data = this.GetRawBlob(containerName, blobName);

            // validate
            if (!data.IsValid)
            {
                return(results);
            }

            // convert to BASE64
            results.Data = Convert.ToBase64String(data.Data, Base64FormattingOptions.None);

            // get the properties
            results.ContentType = data.ContentType;
            results.Filename    = data.Filename;

            return(results);
        }