0

I was looking at the WASABi documentation and I am confused about a particular aspect of this library.

I need to create a custom reactive rule. Say, this rule runs every minute and the "scale" action of this rule should be to scale up by "x" amount. It seems that as though I can set the "scale" action to a particular number (say 1 or 2), but not pass in a variable computed by, say my custom operand.

I understand that I can create a custom operand to check my condition, but I want the custom operand to compute how much the "scale" action should scale the target Worker Role by and then pass this value to the "scale" action.

Is there someway to define these rules outside the XML to achieve this?

Any help would be greatly appreciated!

Taha Ahmad
  • 559
  • 4
  • 16
  • As far as I remember, actions can increment or decrement the count by a number or by a proportion. So if you want a dynamic increment or decrement I think you will need to [create a custom action](https://msdn.microsoft.com/en-us/library/hh680921(v=pandp.50).aspx). I think you could pull out the info you need from the `IRuleEvaluationContext`. – Randy Levy Feb 19 '16 at 16:44
  • Also, I would just note that WASABi is pretty old now and wasn't included with the last version of EntLib because Azure added a lot of built-in Autoscaling functionality. In addition, I know azure SDK releases tended to cause headaches with WASABi so I'm not sure how well it works with the current versions. Just a caution -- I haven't used it in a while so you probably have more experience with that than me. – Randy Levy Feb 19 '16 at 16:51
  • I just started looking into it and have never used it before. Hopefully, it just works with the latest version – Taha Ahmad Feb 20 '16 at 01:24
  • In my custom action, how do I actually scale up? What is the class for that? – Taha Ahmad Feb 20 '16 at 03:07
  • The Autoscaling block looks like it's been retired. If you are starting from scratch then you should read this recent posting: https://azure.microsoft.com/en-us/documentation/articles/best-practices-auto-scaling/ . – Randy Levy Feb 20 '16 at 05:52
  • @RandyLevy: I did read that and one recommendation is to use a custom solution and scale using Service Management API and it then says that the "Autoscaling Application Block" used this method. My point of view is that even though the block is retired, if it can be used effectively, why not use it? Do you know from the top of your head if this block is compatible with the more recent changes in Azure. I will do a prototype over the weekend, but if you know about it, a heads up would be good :) – Taha Ahmad Feb 20 '16 at 08:36
  • Haven't used the block in a at least a couple of years. – Randy Levy Feb 20 '16 at 19:48

1 Answers1

1

Actions can increment or decrement the count by a number or by a proportion. So if you want a dynamic increment or decrement I think you will need to create a custom action. I think you could pull out the info you need from the IRuleEvaluationContext.

To change the instance count you will need to change the deployment configuration. See https://social.msdn.microsoft.com/forums/azure/en-US/dbbf14d1-fd40-4aa3-8c65-a2424702816b/few-question-regarding-changing-instance-count-programmatically?forum=windowsazuredevelopment&prof=required for some discussion.

You should be able to do that using the Azure Management Libraries for .NET and the ComputeManagementClient. Something like:

using (ComputeManagementClient client = new ComputeManagementClient(credentials))
{
    var response = await client.Deployments.GetBySlotAsync(serviceName, slot);

    XDocument config = XDocument.Parse(response.Configuration);

    // Change the config

    StringBuilder builder = new StringBuilder();

    using (TextWriter writer = new StringWriter(builder))
    {
        config.Save(writer);
    }

    string newConfig = builder.ToString();

    await client.Deployments.BeginChangingConfigurationBySlotAsync(serviceName, slot, new DeploymentChangeConfigurationParameters(newConfig));
}
Randy Levy
  • 22,566
  • 4
  • 68
  • 94
  • Thank you for this!! The Enterprise Autoscale Block doesn't seem to work with the latest version of the SDK, but this gem of an information, essentially lets me roll out my own scaling solution. To Rany Levy's credit, he suggested something similar! edit: Didn't realize, you were Randy Levy :) – Taha Ahmad Feb 21 '16 at 16:20
  • When I autoscale, the configuration change causes all instances to restart. Is there someway to prevent this restart from happening (either through code or through some strategy of moving roles into separate Availability Sets)? – Taha Ahmad Feb 21 '16 at 16:23
  • Not sure. I did read something about using the staging slot and then doing a swap. – Randy Levy Feb 26 '16 at 04:28