WindowsAzure/azure-sdk-for-net — pull request #95 by tquinn86 (2012-06-15 17:40:31+00:00)
Title: Add Management API client library

There have been sample client libraries for the Mangement API floating around for a while now. It is time to add an official one.

This one is based on my work on the Continous Integration feature of TFS in the cloud (tfspreview.com).

I needed a production quality client for the management API to do deployments form TFS build machines in the cloud: so I wrote one.

This client library is based upon the HttpClient class in the ASP.NET Web API (so there is a dependency on the MVC4 RC).

The main class in the library is the AzureHttpClient class. It contains a method for each REST API (that I have implemented, see notes below). These methods are of the form:

Task {ApiName}Async(CancellationToken token);

So things like:

Task GetDeploymentAsync(string cloudServiceName, DeploymentSlot slot, CancellationToken token);

or

Task CreateAffinityGroupAsync(string name, string label, string description, string location, CancellationToken token);

This follows the standard TPL pattern as well as the pattern established in HttpClient.

Please look at the tests to see how these can be used.

*NOTES*
-- This does *not* yet cover the entire breadth of the Management API. It does cover everything necessary to do deployments, plus some more (as evidenced by the tests). I plan to continue to fill in the rest of the API. Each new one is fairly simple to implement.

-- As noted this uses the new Task-based async pattern. I have not implemented old-style Begin\End pairs for the API. These are trivial to implement on top of the Task-based APIs if they are desired in addition (and then sync API can easily be written on top of those).

So for a particular API we could have these variations (likely on different classes) if desired:

Task GetDeploymentAsync(string cloudServiceName, DeploymentSlot slot, CancellationToken token);
IAsyncResult BegiGetDeployment(string cloudServiceName, DeploymentSlot, object state, AsyncCallback callback);
Deployment EndGetDeployment(IAsyncResult result);
Deployment GetDeployment(string cloudServiceName, DeploymentSlot);

But for now I'm sticking with the modern style.

-- I have re-used the same copyright\license template for the top of each source file.

-- I have doc comments for each public class and member.

Thanks for your consideration.