Thanks for all responses.
Neil: I need to issue SAS based on a policy "on a container"; in this way I have control over the signature I issued. But I got the essense from your code on how you try to solve the issue.
Steve: You are correct. Why it didn't work for me? Because I was defining time period twice. First when creating the Shared Access Policy, secondly when creating the SAS based in that policy. Error I was getting is "Server failed to authenticate
the request. Make sure the value of Authorization header is formed correctly including the signature."
I got around it by defining time only in policy and passing an empty SharedAccessPolicy when creating the signature. It worked!!!! Find code below.
Server side code [or I would use some tool to do the same]
CloudStorageAccount cloudStorageAccount1 = CloudStorageAccount.FromConfigurationSetting("DiagnosticsConnectionString");
CloudBlobClient cloudBlobClient = cloudStorageAccount1.CreateCloudBlobClient();
CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("salesdata");
cloudBlobContainer.CreateIfNotExist();
SharedAccessPolicy sap = new SharedAccessPolicy();
sap.Permissions = SharedAccessPermissions.Read | SharedAccessPermissions.Write;
sap.SharedAccessStartTime = DateTime.UtcNow;
sap.SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromDays(100);
BlobContainerPermissions bcp = new BlobContainerPermissions();
bcp.PublicAccess = BlobContainerPublicAccessType.Off;
bcp.SharedAccessPolicies.Clear();
bcp.SharedAccessPolicies.Add("partneraccess", sap);
cloudBlobContainer.SetPermissions(bcp);
var sas = cloudBlobContainer.GetSharedAccessSignature(new SharedAccessPolicy()
{}, "partneraccess");
The SAS should be then passed to the client.
Client side code [or I would use some tool to do the same]
var sasCreds = new StorageCredentialsSharedAccessSignature(sas);
var sasBlob = new CloudBlobClient(strBlobEndpoint, sasCreds).GetBlobReference("salesdata/"+ Guid.NewGuid().ToString());
sasBlob.UploadText("sales data from business partner1");