Breaking changes! Well I did say that this was a beta. So we’re now in v0.3 and we’ve added creation of new storage accounts. The fluent interface has been tidied up as well so that the subscription is now at the root of every activity you want to perform. As such there are 3 types of manager:
- DeploymentManager
- StorageManager
- SqlAzureManager
These 3 managers contain functionality to deploy, create storage accounts and create databases respectively. If you’ve been using v0.1-0.2 for the past week you should update. Unfortunately the interface will be changing over the next month or so. We’re writing this from the perspective of what we need from our projects and will retrofit that back into the library for everyone to use.
Feel free to comment with anything you think would be useful for you and we’ll attempt to add this to subsequent iterations given available time.
Another change is that in the previous library all activity was synchronous but in this version we’ve added a handler which generates enum values and messages to let you know when the subactivities have completed. Useful if you want to build a GUI on top of this and update a message box or status bar.
Just a short note to say that in the next version we’ll look at allowing a dictionary of settings values to be added to the config for each role as well. Probably more useful to us than anyone else as we’re looking to dynamically add a range of plugin settings values to our config. But hey …
The following can be used to create a deployment:
var subscriptionManager = new SubscriptionManager("");
var deploymentManager = subscriptionManager.GetDeploymentManager();
deploymentManager.AzureTaskComplete += sqlAzureManager_AzureTaskComplete;
deploymentManager.ForNewDeployment("hellocloud")
.AddCertificateFromStore("AA4EF678D0961B6A6C51D4AC657B0ADB71BB3354")
.WithExistingHostedService("pastagrid")
.WithPackageConfigDirectory(@"C:\Projects\Tech Projects\London Windows Azure User Group\HelloCloud\HelloCloud\bin\Release\app.publish\")
.WithStorageConnectionStringName("DataConnectionString")
.AddDescription("My new hosted services")
.AddEnvironment(DeploymentSlot.Production)
.AddLocation(DeploymentManager.LocationNorthEurope)
.AddParams(DeploymentParams.StartImmediately)
.ForRole("HelloCloud.Web")
.WithInstanceCount(3)
.Go();
This can be used to create a server and database with admin users (I’ve just cut and paste the test code so as you can see from the Assert you would get a set of populated properties returned from these operations):
var subscriptionManager = new SubscriptionManager("");
var sqlAzureManager = subscriptionManager.GetSqlAzureManager();
sqlAzureManager.AzureTaskComplete += new EventReached(sqlAzureManager_AzureTaskComplete);
sqlAzureManager.AddNewServer(DeploymentManager.LocationWestEurope)
.AddCertificateFromStore("AA4EF678D0961B6A6C51D4AC657B0ADB71BB3354")
.AddNewFirewallRule("myofficeip", "10.27.27.253", "10.27.27.254")
.AddNewFirewallRull("anotherip", "10.27.28.11", "10.27.28.254")
.AddNewFirewallRuleForWindowsAzureHostedService()
.AddNewFirewallRuleWithMyIp("myhomeip")
.WithSqlAzureCredentials("ukwaug", "<a href="mailto:M@cc0mputer">M@cc0mputer</a>")
.AddNewDatabase("test")
.AddNewDatabaseAdminUser("ukwaugdb", "<a href="mailto:M@cc0mputer">M@cc0mputer</a>")
.ExecuteScripts(@"C:\Projects\Tech Projects\Elastacloud")
.Go();
Assert.IsNotNull(sqlAzureManager.SqlAzureServerName);
This is the new operation to enable the creation of a storage account:
var subscriptionManager = new SubscriptionManager("");
var storageManager = subscriptionManager.GetStorageManager();
storageManager.AzureTaskComplete += sqlAzureManager_AzureTaskComplete;
storageManager.CreateNew("elastastorage2")
.AddCertificateFromStore("AA4EF678D0961B6A6C51D4AC657B0ADB71BB3354")
.WithDescription("my new storage")
.WithLocation(DeploymentManager.LocationWestEurope)
.Go();
Assert.IsNotNull(storageManager.StorageAccountPrimaryKey);
Assert.IsNotNull(storageManager.StorageAccountSecondaryKey);
Just for completeness here is the callback method’s signature:
void sqlAzureManager_AzureTaskComplete(EventPoint point, string message) {
Debug.WriteLine(message, point.ToString());
}
If you like this library please follow either me (@azurecoder) or @andybareweb, @elastacloud or @ukwaug as we’ll be tweeting updates through these channels and there may be other breaking changes going forward. Remember you can install via Nuget as Elastacloud.AzureManagement.Fluent.