Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Azure Shared Access Signature always gives: Forbidden 403
    text
    copied!<p>I am trying to get a shared access signature for a single blob and then download the blob using the REST api. However, I always get a forbidden 403 error message. Both on storage emulator and the cloud. Here is my code:</p> <pre><code>CloudStorageAccount storageAccount = CloudStorageAccount.Parse("myConnectionStringHere..."); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("containerName"); CloudBlob blob = container.GetBlobReference("blobName"); string sasToken = blob.GetSharedAccessSignature(new SharedAccessPolicy() { Permissions = SharedAccessPermission.Read, SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromHours(24) } ); string completeUri = string.Format(CultureInfo.InvariantCulture, "{0}{1}", blob.Uri, sasToken); // now use the uri to make the rest call and download HttpWebRequest request = (HttpWebRequest)WebRequest.Create(completeUri); request.Method = "GET"; using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse()) { using (Stream s = resp.GetResponseStream()) { using (FileStream fs = new FileStream("test.jpg", FileMode.Create, FileAccess.Write)) { byte[] buffer = new byte[8 * 1024]; int len; while ((len = s.Read(buffer, 0, buffer.Length)) &gt; 0) { fs.Write(buffer, 0, len); } } } } </code></pre> <p>I keep getting the 403 error when invoking GetResponse. Any help appreciated!</p> <p>EDIT: forgot to mention: I am using the latest azure sdk (2.0)</p> <p>EDIT 2: I experimented a lot and found a tool called Azure Management Studio. This tool is able to create an SAS token. I did that, and used it with my REST call code. This worked just fine, so the error has to be inside the token creation code I have written. However, the format of the sas string is exactly the same. I don't know what else to try out</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload