public string DoExport(ExportDatabaseEventSource log, string blobUri, bool whatIf)
        {
            string requestGuid = null;

            //Setup Web Request for Export Operation
            WebRequest webRequest = WebRequest.Create(this.EndPointUri + @"/Export");
            webRequest.Method = WebRequestMethods.Http.Post;
            webRequest.ContentType = @"application/xml";

            //Create Web Request Inputs - Blob Storage Credentials and Server Connection Info
            ExportInput exportInputs = new ExportInput
            {
                BlobCredentials = new BlobStorageAccessKeyCredentials
                {
                    StorageAccessKey = this.StorageKey,
                    Uri = String.Format(blobUri, this.DatabaseName, DateTime.UtcNow.Ticks.ToString())
                },
                ConnectionInfo = new ConnectionInfo
                {
                    ServerName = this.ServerName,
                    DatabaseName = this.DatabaseName,
                    UserName = this.UserName,
                    Password = this.Password
                }
            };

            //Perform Web Request
            DataContractSerializer dataContractSerializer = new DataContractSerializer(exportInputs.GetType());
            log.RequestUri(webRequest.RequestUri.AbsoluteUri);
            if (whatIf)
            {
                using (var strm = new MemoryStream())
                {
                    dataContractSerializer.WriteObject(strm, exportInputs);
                    strm.Flush();
                    strm.Seek(0, SeekOrigin.Begin);
                    using (var reader = new StreamReader(strm))
                    {
                        log.WouldHaveSent(reader.ReadToEnd());
                    }
                }
                return null;
            }
            else
            {
                using (var strm = new MemoryStream())
                {
                    dataContractSerializer.WriteObject(strm, exportInputs);
                    strm.Flush();
                    strm.Seek(0, SeekOrigin.Begin);
                    using (var reader = new StreamReader(strm))
                    {
                        log.SendingRequest(reader.ReadToEnd());
                    }
                }

                Stream webRequestStream = webRequest.GetRequestStream();
                dataContractSerializer.WriteObject(webRequestStream, exportInputs);
                webRequestStream.Close();

                //Get Response and Extract Request Identifier
                WebResponse webResponse = null;
                XmlReader xmlStreamReader = null;

                try
                {
                    //Initialize the WebResponse to the response from the WebRequest
                    webResponse = webRequest.GetResponse();

                    xmlStreamReader = XmlReader.Create(webResponse.GetResponseStream());
                    xmlStreamReader.ReadToFollowing("guid");
                    requestGuid = xmlStreamReader.ReadElementContentAsString();
                    return requestGuid;
                }
                catch (WebException responseException)
                {
                    log.RequestFailed(responseException.Message);
                    if (responseException.Response != null)
                    {
                        log.ErrorStatusCode((int)(((HttpWebResponse)responseException.Response).StatusCode));
                        log.ErrorStatusDescription(((HttpWebResponse)responseException.Response).StatusDescription);
                    }
                    return null;
                }
            }
        }
        public string DoExport(ExportDatabaseEventSource log, string blobUri, bool whatIf)
        {
            string requestGuid = null;

            //Setup Web Request for Export Operation
            WebRequest webRequest = WebRequest.Create(this.EndPointUri + @"/Export");

            webRequest.Method      = WebRequestMethods.Http.Post;
            webRequest.ContentType = @"application/xml";

            //Create Web Request Inputs - Blob Storage Credentials and Server Connection Info
            ExportInput exportInputs = new ExportInput
            {
                BlobCredentials = new BlobStorageAccessKeyCredentials
                {
                    StorageAccessKey = this.StorageKey,
                    Uri = String.Format(blobUri, this.DatabaseName, DateTime.UtcNow.Ticks.ToString())
                },
                ConnectionInfo = new ConnectionInfo
                {
                    ServerName   = this.ServerName,
                    DatabaseName = this.DatabaseName,
                    UserName     = this.UserName,
                    Password     = this.Password
                }
            };

            //Perform Web Request
            DataContractSerializer dataContractSerializer = new DataContractSerializer(exportInputs.GetType());

            log.RequestUri(webRequest.RequestUri.AbsoluteUri);
            if (whatIf)
            {
                using (var strm = new MemoryStream())
                {
                    dataContractSerializer.WriteObject(strm, exportInputs);
                    strm.Flush();
                    strm.Seek(0, SeekOrigin.Begin);
                    using (var reader = new StreamReader(strm))
                    {
                        log.WouldHaveSent(reader.ReadToEnd());
                    }
                }
                return(null);
            }
            else
            {
                using (var strm = new MemoryStream())
                {
                    dataContractSerializer.WriteObject(strm, exportInputs);
                    strm.Flush();
                    strm.Seek(0, SeekOrigin.Begin);
                    using (var reader = new StreamReader(strm))
                    {
                        log.SendingRequest(reader.ReadToEnd());
                    }
                }

                Stream webRequestStream = webRequest.GetRequestStream();
                dataContractSerializer.WriteObject(webRequestStream, exportInputs);
                webRequestStream.Close();

                //Get Response and Extract Request Identifier
                WebResponse webResponse     = null;
                XmlReader   xmlStreamReader = null;

                try
                {
                    //Initialize the WebResponse to the response from the WebRequest
                    webResponse = webRequest.GetResponse();

                    xmlStreamReader = XmlReader.Create(webResponse.GetResponseStream());
                    xmlStreamReader.ReadToFollowing("guid");
                    requestGuid = xmlStreamReader.ReadElementContentAsString();
                    return(requestGuid);
                }
                catch (WebException responseException)
                {
                    log.RequestFailed(responseException.Message);
                    if (responseException.Response != null)
                    {
                        log.ErrorStatusCode((int)(((HttpWebResponse)responseException.Response).StatusCode));
                        log.ErrorStatusDescription(((HttpWebResponse)responseException.Response).StatusDescription);
                    }
                    return(null);
                }
            }
        }