private HttpWebRequest GenerateRequestForLeaseContainer(CloudStorageAccount account, string containerName, string targetApiVersion) { // https://msdn.microsoft.com/en-us/library/azure/jj159103.aspx var queryStringValues = new Dictionary <string, string>() { { "restype", "container" }, { "comp", "lease" } }; string url = String.Format("{0}/{1}?{2}", account.BlobEndpoint.AbsoluteUri.ToString().TrimEnd('/'), containerName, String.Join("&", queryStringValues.Select(v => String.Format("{0}={1}", v.Key, v.Value)))); var request = HttpWebRequest.CreateHttp(url); request.Method = "PUT"; request.Headers.Add("x-ms-version", targetApiVersion); request.Headers.Add("x-ms-date", DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture)); request.Headers.Add("x-ms-lease-action", "acquire"); request.Headers.Add("x-ms-lease-duration", "60"); request.ContentLength = 0; request.Headers.Add("Authorization", "SharedKey " + account.Credentials.AccountName + ":" + SharedKey.Get(request, account.Credentials.AccountName, account.Credentials.ExportKey(), queryStringValues, "0")); return(request); }
private HttpWebRequest GenerateRequestForUpdate(CloudStorageAccount account, string queueName, string messageId, string popReceipt, int visibilityTimeout) { string url = String.Format("{0}/{1}/messages/{2}?popreceipt={3}&visibilitytimeout={4}", account.QueueEndpoint.AbsoluteUri.ToString().TrimEnd('/'), queueName, Uri.EscapeDataString(messageId), Uri.EscapeDataString(popReceipt), visibilityTimeout); var queryStringValues = new Dictionary <string, string>() { { "popreceipt", popReceipt }, { "visibilitytimeout", visibilityTimeout.ToString() } }; var request = HttpWebRequest.CreateHttp(url); request.Method = "PUT"; request.ContentLength = 0; request.Headers.Add("x-ms-version", TargetApiVersion); request.Headers.Add("x-ms-date", DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture)); request.Headers.Add("Authorization", "SharedKey " + account.Credentials.AccountName + ":" + SharedKey.Get(request, account.Credentials.AccountName, account.Credentials.ExportKey(), queryStringValues, OverrideStringForZeroContentSize)); return(request); }
private HttpWebRequest GenerateRequestForGetProperties(CloudStorageAccount account, string containerName, string targetApiVersion) { string url = String.Format("{0}/{1}?restype=container", account.BlobEndpoint.AbsoluteUri.ToString().TrimEnd('/'), containerName); var queryStringValues = new Dictionary <string, string>() { { "restype", "container" } }; var request = HttpWebRequest.CreateHttp(url); request.Method = "GET"; request.Headers.Add("x-ms-version", targetApiVersion); request.Headers.Add("x-ms-date", DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture)); request.Headers.Add("Authorization", "SharedKey " + account.Credentials.AccountName + ":" + SharedKey.Get(request, account.Credentials.AccountName, account.Credentials.ExportKey(), queryStringValues)); return(request); }