Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:55:55+00:00 2026-06-09T00:55:55+00:00

I am facing a wired issue.. I want to allow certain users to read/write

  • 0

I am facing a wired issue..

I want to allow certain users to read/write file from/to Azure-Container. For this I am using the concept of SharedAccessSignature.

I am generating the shared access signature in a RESTFUL (ASP.NET MVC4) web service which clients call to get the access key ..

  CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
  CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient ();
  CloudBlobContainer container = blobClient.GetContainerReference (containerName);
  container.CreateIfNotExist ();
  BlobContainerPermissions containerPermissions = new BlobContainerPermissions ();
  containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
  container.SetPermissions (containerPermissions);
  string sas = container.GetSharedAccessSignature (new SharedAccessPolicy ()
        {
            SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes (30),
            Permissions = SharedAccessPermissions.Write | SharedAccessPermissions.Read
        });
  //return sas to user

I return sas to the client where he tries to upload a blob using following code

  CloudBlobClient sasBlobClient = new CloudBlobClient ("http://127.0.0.1:10000/devstoreaccount1", new StorageCredentialsSharedAccessSignature (sak));
  CloudBlob blob = sasBlobClient.GetBlobReference (containerName + "/myblob.txt");
  blob.UploadText ("Hello SAS World");

on the last line client throws exception

Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

Inner Exception : {“The remote server returned an error: (403) Forbidden.”}

Interesting part is that if I put the client side code right after getting sas (string sas = container.GetShare....... ) it works without any exception. But if I put my client code in a separate console application (which then retrieves the key through a REST call) it throws exception.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:55:57+00:00Added an answer on June 9, 2026 at 12:55 am

    I tested your code in a Console Application and it works fine (I passed the sas variable to the CloudBlobClient). But then I set up a REST service using the ASP.NET Web API and retrieved the key using a WebClient:

      WebClient wc = new WebClient();
      var sas = wc.DownloadString("http://127.0.0.1:47413/api/values/1");
    

    In both the Web Application and the Console Application I wrote the SAS key to my output window using Trace, and this was the result:

    WebApp: ?se=2012-08-02T19%3A54%3A53Z&sr=c&sp=rw&sig=oWEF7r5HpkEh%2BH1aTVKGR7VF3gbWwq84gv%2BZFbXRhOA%3D

    Client: "?se=2012-08-02T19%3A54%3A53Z&sr=c&sp=rw&sig=oWEF7r5HpkEh%2BH1aTVKGR7VF3gbWwq84gv%2BZFbXRhOA%3D"

    As you can see it looks like the SAS key is being wrapped in double quotes. I don’t know what you’re using to create your REST service, but I’m using the ASP.NET Web API. And here it uses the JSON formatter as default formatter. So the SAS key being returned is correct, the only problem is that it’s being returned in JSON format.

    To get the actual SAS key you’ll need to deserialize it to a string (sounds weird no?), here is an example with Json.NET:

    var correctSAS = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(sas);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I facing a strange issue... I am creating tables dynamically using the data from
Facing some issue in Talend Admin Console, the jobs that are running from IDE
Im facing a strange issue trying to move from sql server to oracle. in
we are facing a strange issue. we have a (custom)file upload control in our
Im facing a problem where i want to schedule a certain java application to
Been Facing this issue,I Have as my view <%= form_for(:pin, :url => {:action =>fees})
Facing problem with every fetch i want to make using EF Query model.Place here
I´m facing this problem: I have a Button that works like a WrapPanel using
I'm facing a problem with IE6. I took the toggle function from this website
Facing an interesting issue when I am using WCF Web API with Hammock and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.