Search code examples
azure-storage

"Authentication not in correct format" when setting Azure Blob Service Properties (REST API)


I am trying to set CORS rules on my Azure Blob Storage account by following these instructions.

This is the error I receive after making my request:

400 Authentication information is not given in the correct format. Check the value of Authorization header

Request URL:

PUT https://[MyAccountName].blob.core.windows.net/?restype=service&comp=properties

Request header:

x-ms-version: 2013-08-15
x-ms-date: Tue, 25 Feb 2014 13:02:00 GMT
Authorization: SharedKey
[MyAccountName]: [MyAccountKey]
Content-Length: 329
Host: [MyAccountName].blob.core.windows.net

Request body:

<?xml version="1.0" encoding="utf-8"?>
<StorageServiceProperties>
    <Cors>   
          <CorsRule>
                <AllowedOrigins>http://www.example.com</AllowedOrigins>
                <AllowedMethods>GET</AllowedMethods>
                <ExposedHeaders>x-ms-meta-data*,x-ms-meta*</ExposedHeaders>
                <AllowedHeaders>x-ms-meta-target*,x-ms-meta*</AllowedHeaders>
                <MaxAgeInSeconds>200</MaxAgeInSeconds>
        </CorsRule>
    <Cors>
</StorageServiceProperties>

Solution

  • The request has an incomplete Authorization header. It needs to contain the authentication scheme, storage account name, and signature. For example;

    Authorization: SharedKey myaccount:Z1lTLDwtq5o1UYQluucdsXk6/iB7YxEu0m6VofAEkUE=
    

    For more information, see Authentication for the Windows Azure Storage Services. On the other hand, if you use one of the Windows Azure Storage Client Libraries, it will handle the authentication for you. For .NET library, please see our NuGet package.