Enterprise Autoscale Application Block (WASABi) <scale> up by a variable amount

55 Views Asked by At

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!

1

There are 1 best solutions below

3
On BEST ANSWER

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));
}