Update: 28/12/2012
Azure Fluent Management is written by Elastacloud (Richard Conway @azurecoder with some help from Andy Cross @andybareweb).

Currently I’m making lots of breaking interface changes now and intend to a whole heap of functionality within the coming month to get VMs on par with Cloud Services to make Fluent Management a fully functional orchestration library for Azure deployments.

The project is more than a wrapper for the Windows Azure Service Management API. It wraps up functionality similar to Windows Azure Powershell CmdLets in a familiar fluent syntax for C# developers. We use fluent management extensively in our own consultancy life for something that we call “reactive deployments and management”. For us Powershell (and now CLI) is great and easy to setup and control environments but when you need to respond to events in code then Fluent Management allows you to do a number of things such as reacting to a user input by creating a database, storage, cloud service, VM or deployment.

Fluent Management offers control of:

  1. Windows Azure SQL Databases
  2. Windows Azure Storage
  3. Windows Azure Deployments
  4. Windows Azure Cloud Services
  5. Windows Azure Virtual Machines
  6. Windows Azure Mobile Services

All of this can be done in a transaction context as well so if one part of a deployment fails then the rest is rolled back. It is currently in version 0.4.2 and is installable from the nugget package manager console using:

> Install-Package Elastacloud.AzureManagement.Fluent

You can read more on the nuget gallery page here

This wiki chronicles the various functions of Fluent Management and is broken by down by category of Windows Azure.

In order to begin using Fluent Management a call needs to be made to the SubscriptionManager. In the following a SubscriptionManager is created with a valid subscription ID. Currently, all calls to the API are blocking so to facility messaging back based on progress the AzureTaskComplete event fires when a point in reached in the deployment cycle.

var subscriptionManager = new SubscriptionManager(TestConstants.SubscriptionId);
var deploymentManager = subscriptionManager.GetDeploymentManager();
((DeploymentManager)deploymentManager).AzureTaskComplete += TestConstants.TaskComplete;

There are various points (EventPoints) which raise events such as the creation of Sql Azure database, the addition of a firewall rule, addition of a cloud service or the completion of a deployment.

public static void TaskComplete(EventPoint point, string message)
     Debug.WriteLine(message, point.ToString());

In order to perform any Service Management operation the Management Certificate must be provided. Since the transport channel is TLS the authentication is mutual which means that the management certificate must be loaded into Windows Azure and the certificate and private key made available on the machine running Fluent Management. The easiest Certificate Deployment mechanism is using .publishsettings files which can be downloaded from the Microsoft link in Visual Studio. Fluent Management supports manipulation of the .publishsettings file and persistence into the local certificate store of PFX(PKCS#12) structures.

This adds the .pfx to the store.

var cert = PublishSettingsExtractor.AddPublishSettingsToPersonalMachineStore(publishsettings);

And gets the certificate from the store for use.

cert = PublishSettingsExtractor.FromStore(cert.Thumbprint);

Then deletes the certificate from the store if necessary.


Given a .publishsettings files this will extract the available subscriptions in a string list.

var settings = new PublishSettingsExtractor(_filename);
var dictionary = settings.GetSubscriptions();

Only one Management Certificate exists in the file and this will retrieve the thumbprint.

var settings = new PublishSettingsExtractor(_filename);
string thumbprint = settings.GetCertificateThumbprint();

The PublishSettingsExtractor class contains several instance and static methods which enable certificates to be extracted and placed in a store. The GetCertificateFromFile method can be used to check StoreLocations in the local certificate repository. If the certificate does not exist in any of the stores then it will be added to the personal store for the Current User.

Since Fluent Management started the .publishsettings file has gone through an update to Version 2. Fluent Management has been updated to support this so that you can feed it either a v1 or v2 file without it complaining.

There are several xxxManagers which are used in each of the usage patterns in this wiki. They are returned from creating the SubscriptionManager and calling one of the Get….. methods. The following managers are used.

  • DeploymentManager
  • SqlAzureManager
  • StorageManager
  • SubscriptionDetailsManager
  • RoleStatusWatcher
  • RoleContextManager

Fluent Management is dependent on Bouncy Castle (for certificate generation and PKCS#7/CMS packaging for RD), NLog for output logging and NLog Config to provide a grass root configuration file for an application. Recently it has gained a dependency on Newtonsoft.Json as the Service Management API sends back some responses in a JSON format.

Any questions please feel free to contact me at richard@elastacloud.com

Posted in