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 8639169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:56:02+00:00 2026-06-12T10:56:02+00:00

I am trying to use WindowsAzure REST API for inserting Entity in azure table.

  • 0

I am trying to use WindowsAzure REST API for inserting Entity in azure table. But i am getting the following WebException :

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code>AuthenticationFailed</code>
  <message xml:lang="en-US">
                            Server failed to authenticate the request. Make sure the 
                            value of Authorization header is formed correctly including 
                            the signature.
                            RequestId:bbcf614e-6a12-4fb0-be68-16246853111d
                            Time:2012-10-03T08:21:46.3010154Z
  </message>
 </error>

And the following code creates the authorization header :

private String CreateAuthorizationHeader(String canonicalizedString)
{
    String signature = string.Empty;
    using (HMACSHA256 hmacSha256 = new HMACSHA256(Encoding.UTF8.GetBytes(AzureStorageConstants.Key)))
    {
        Byte[] dataToHmac = Encoding.UTF8.GetBytes(canonicalizedString);
        signature = Convert.ToBase64String(hmacSha256.ComputeHash(dataToHmac));
    }

    String authorizationHeader = String.Format(
          CultureInfo.InvariantCulture,
          "{0} {1}:{2}",
          AzureStorageConstants.SharedKeyAuthorizationScheme,
          AzureStorageConstants.Account,
          signature);

    return authorizationHeader;
}

Code for generating canonicalizedString

   public void InsertEntity(string tablename, string artist, string title)
   {
    string requestmethod = "POST";
    string urlpath = tablename;
    string storageserviceversion = "2009-09-19";
    string dateinrfc1123format = DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture);
    string contentmd5 = string.Empty;
    string contenttype = "application/atom+xml";
    String canonicalizedresource = string.Format("/{0}/{1}", AzureStorageConstants.Account, urlpath);
    String stringtosign = String.Format(
      "{0}\n{1}\n{2}\n{3}\n{4}",
      requestmethod,
      contentmd5,
      contenttype,
      dateinrfc1123format,
      canonicalizedresource);

    String authorizationHeader = CreateAuthorizationHeader(stringtosign);
    ...
    ...
   }

Can anybody please tell me what i am doing wrong ?

  • 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-12T10:56:03+00:00Added an answer on June 12, 2026 at 10:56 am

    Please change the following line of code:

    using (HMACSHA256 hmacSha256 = new HMACSHA256(Encoding.UTF8.GetBytes(AzureStorageConstants.Key)))
    {
        Byte[] dataToHmac = Encoding.UTF8.GetBytes(canonicalizedString);
        signature = Convert.ToBase64String(hmacSha256.ComputeHash(dataToHmac));
    }
    

    to

    using (HMACSHA256 hmacSha256 = new HMACSHA256(Convert.FromBase64String(AzureStorageConstants.Key)))
    {
        Byte[] dataToHmac = Encoding.UTF8.GetBytes(canonicalizedString);
        signature = Convert.ToBase64String(hmacSha256.ComputeHash(dataToHmac));
    }
    

    Basically your code was failing because you were using Encoding.UTF8.GetBytes(accountKey). We would need to use Convert.FromBase64String(accountKey)

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use WindowsAzure shared cache and the Increment operator of the DataCache
I'm trying to evaluate the use of Windows Azure storage/media/cdn services to host the
i'm trying use facebook API to upload photo in my fan page. I downloaded
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying use filehelpers class builder but I am kinda confused on what
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
I was trying use svn to find a checkin using svn log, but it
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use the Sum method in a lambda expression for a comparison, but
I am trying use cursor for pagination. Forwarding pagination work fine, but I can

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.