Azure REST API

None of my REST API successfully executes and responds.

Either I get 404 excpetion that URI not found etc or 400 Exceotion.

I exactly follow the notes in the REST API provided on azure site, still not able to catch why none of requests working!

I want information on my azure storage cloud information. like what is the total space used on the storage and what is left over

March 14th, 2012 4:43am

 I am trying to enable storage analytics using REST API provided here:

http://msdn.microsoft.com/en-us/library/hh360996.aspx

and i get Status code 404 for resource does not exist....

Could anyone please help me on this?

Free Windows Admin Tool Kit Click here and download it now
March 14th, 2012 5:10am

Will it be possible for you to share your source code? That will help identify the problem. Also, please note that it may take some time for the analytics data to populate after enabling the analytics on your storage account. A good way to test would be to check the presence of tables and blob containers starting with "$" e.g. $logs blob container.

Hope this helps.

Thanks

Gaurav Mantri

Cerebrata Software

http://www.cerebrata.com

March 14th, 2012 5:43am

Hi,

Can Azure Storage Explorer find your blob or table resources? Does your resources has been uploaded successfully?

Following the Windows Azure Trainning course to make a simple test with you local or cloud storage:

http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_ExploringWindowsAzureStorageVS2010

Hope it can help you.

Free Windows Admin Tool Kit Click here and download it now
March 14th, 2012 9:11am

Hi,

Can Azure Storage Explorer find your blob or table resources? Does your resources has been uploaded successfully?

Following the Windows Azure Trainning course to make a simple test with you local or cloud storage:

http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_ExploringWindowsAzureStorageVS2010

Hope it can hel

March 14th, 2012 9:29am

Hi,

Right, I give that link because Dhwani says none of REST Management services API can excute successfully, so i suggest he use simple Blob storage API for testing.

For Enabling and Configuring Storage Analytics, try to use following code snippets to see if it works:

            CloudStorageAccount account = CloudStorageAccount.Parse("<Connection String>");
            CloudBlobClient client = account.CreateCloudBlobClient();
            client.SetServiceProperties(new ServiceProperties() { Logging = new LoggingProperties() { Version = "1.0", LoggingOperations = LoggingOperations.Write, RetentionDays = 7 }, Metrics = new MetricsProperties() { Version = "1.0", RetentionDays = 7, MetricsLevel = MetricsLevel.ServiceAndApi } });
            ServiceProperties service = client.GetServiceProperties();

Free Windows Admin Tool Kit Click here and download it now
March 14th, 2012 10:24am

I am using a REST service client plugin in Mozilla firefox to execute the REST URI for rnabling storage analytics. Also I tried  to execute the REST URI using a java program. but both give me now 403  error - Forbidden for the authentication failure.

The other thing is, i want to do all these things using java client libs of azure and not the .net or c#.  

Also, as one of the folks asked me abt azure storage explorere -let me clear here that i am able to exploere my storage account using Azure storage explorer. that is not a problem. there is no confusion on that. 

I am using following request properties in my REST service call in order to enable the storage analytic

{"requestUrl":"http://<myaccount>.table.core.windows.net/?restype=service&comp=properties",

"requestMethod":"PUT",

"requestBody":"

<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<StorageServiceProperties>\n    <Logging>\n        <Version>1.0</Version>\n              <Delete>true</Delete>\n        <Read>false</Read>\n        <Write>true</Write>\n        <RetentionPolicy>\n            <Enabled>true</Enabled>\n            <Days>7</Days>\n        </RetentionPolicy>\n    </Logging>\n    <Metrics>\n        <Version>1.0</Version>\n        <Enabled>true</Enabled>\n        <IncludeAPIs>false</IncludeAPIs>\n        <RetentionPolicy>\n            <Enabled>true</Enabled>\n            <Days>7</Days>\n        </RetentionPolicy>\n    </Metrics>\n</StorageServiceProperties>","headers":["Authorization","SharedKey <myaccountname>:<myaccountkey>","x-ms-version","2011-08-18","x-ms-date","Sun, 25 Sep 2011 22:50:32 GMT","Range","","If-Unmodified-Since","","If-None-Match","","If-Match","","If-Modified-Since","","Date","","Content-Type","","Content-MD5","","Content-Length","","Content-Language","","Content-Encoding",""]}

I tried to use fiddler for checking my http request -response details..did not get a root cause yet..I get 403 forbidden with the message of "Authentication failed..." while the same credentials do work for azure storage explorer.

I am not sure if i am making any mistakes on calling the REST API..

Please do ask for the details if you need to resolve my problem

March 14th, 2012 11:03am

There is an issue with your "Authorization" header and that's why you're getting 403 error. Please refer to http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx for how to create proper authorization header.

Hope this helps.

Free Windows Admin Tool Kit Click here and download it now
March 14th, 2012 12:22pm

I am exactly following the authorization refering the link you provided. Earlier i created the header using this only. Also tried the secondary key but no luck.

are my azure account and storage account names can be different?

March 15th, 2012 12:35pm

Hi,

Of course, Windows Azure account and storage names can be different.

Do you ever following the sample headers of Storage Analytics service?

PUT http://myaccount.table.core.windows.net/?restype=service&comp=properties HTTP/1.1
x-ms-version: 2011-08-18
x-ms-date: Tue, 27 Aug 2011 04:28:19 GMT
Authorization: SharedKey
myaccount:Z1lTLDwtq5o1UYQluucdsXk6/iB7YxEu0m6VofAEkUE=
Host: myaccount.table.core.windows.net
Hope it can help you.

Free Windows Admin Tool Kit Click here and download it now
March 16th, 2012 2:34am

Sorry this does not help me. I user REST client for creating the REST request call. Is that causing something?

Cause when I exactly followed the above thing, I get 400 code, which says that Authentication header is not in proper format.

Does Authorization header value contain everything like:

SharedKey<space>myaccountname:<keyvalue><space>Host:<hostname>

or it is divided into multiple headers?

Could you please clarify this?

March 16th, 2012 9:26am

Hi - sorry this was not resolved.  If you look at the link to "authentication schemes", there's a section called "Constructing the signature string", which contains the information you are looking for.  The authorization header does not include the key value itself, since that would be dangerous.  Instead, the key is used to sign a canonicalized string.  Please go through the "constructing the signature string" section in the link Guarav shared, and see if that works.  Thanks!

Free Windows Admin Tool Kit Click here and download it now
May 21st, 2012 6:26am

Hi Dhavnika,

Have you found the solution ? I am facing the same issue you explained above.

Regards,

KS

November 7th, 2012 11:15pm

Hi,

You can use Azure Rest Api as follows (same for function you need)

static void Main(string[] args)
 {
    //load this from your configuration file
    var payLoadSettings = new PayLoadSettings()
    {
        CloudServiceUrlFormat = "https://management.core.windows.net/{0}/services/hostedservices",
        SubscriptionId = "92533879-88c9-41fe-b24e-5251bcf49a8f",//fake subscription id - please provide yours
        Thumbprint = "3a f6 67 24 d8 d8 b3 71 b0 c4 d3 00 c2 04 0d 62 e5 30 76 1c", //fake cert thumbprint - please provide yours
        ServiceName = "newService1234567",//name your new service
        Label = "newService1234567", //give it a tracking label
        Description = "My new cloud service", //service description
        Location = "North Europe",//select centre
        AffinityGroup = "", //not created yet
        VersionId = "2011-10-01"//api version
    };
 
    var api = new RestAPIHelper(payLoadSettings);
 
    try
    {
        var requestId = api.CreateCloudService();
 
        Console.WriteLine("Cloud service has been created successfully :)" + Environment.NewLine + "Request id: " + requestId);
        Console.ReadLine();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        Console.ReadLine();
    }
}

Full source code available here:

http://www.dotnet-geek.co.uk/index.php/using-windows-azure-service-management-rest-api-in-automated-tasks/


Free Windows Admin Tool Kit Click here and download it now
June 20th, 2013 2:53pm

Hi Dhvanika,

How did you resolve this? I also got the same issue.

Regards,

Santhi

May 4th, 2015 4:05am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics