Selecting a Rules Store

Retired Content

This content and the technology described is outdated and is no longer being maintained. For more information, see Transient Fault Handling.

patterns & practices Developer Center

On this page:
Using Azure Blob Storage | Using Local File Storage | Using a Custom Location

You can configure the Autoscaling Application Block to store rule definitions in Microsoft Azure blob storage (typically when you are hosting the block in Azure), in a local file (typically when you are hosting the block in an on-premises application), or in a custom location.

Using Azure Blob Storage

To store the autoscaling rules in a Azure blob, you should use the BlobXmlFileRulesStore class in the rulesStores element when you configure the block. If you use this rules store, you will also need to provide the names of the blob, the blob container, and the storage account in your configuration data.

You can use a Azure blob to store your autoscaling rules when you host the block in Azure or in an on-premises application.

Using Local File Storage

To store the autoscaling rules in a local file, you should use the LocalXmlFileRulesStore class in the rulesStores element when you configure the block. If you use this rules store, you will also need to provide the name of the file in your configuration data.

You can use a local file to store your autoscaling rules when you host the block in an on-premises application.

Using a Custom Location

To implement a custom rules store, you must create a class that implements the IRulesStore interface. The following code shows a sample custom rules store where the rules are created in code instead of being read from storage.

public class DemoRuleStore : IRulesStore
{
    private readonly List<Rule> rules;

    public DemoRuleStore()
    {
        this.rules = new List<Rule>();

        this.rules.Add(
            new ConstraintRule("Default", "", true, 1, null, 
              new[] { new SetScaleRangeAction("AutoScaling.DemoWebApp", 2, 3) }));

        this.rules.Add(
            new ConstraintRule(
                "Peak time",
                "",
                true,
                10,
                new Timetable(new TimeSpan(10, 05, 0), TimeSpan.FromHours(2), 
                  new RelativeMonthlyRecurrence(RelativeDayOfWeek.Friday, 
                  RelativeDayPosition.Fourth), TimeSpan.FromHours(-6)),
                new[] { new SetScaleRangeAction("AutoScaling.DemoWebApp", 3, 5) }));

    public IEnumerable<Rule> GetRules()
    {
        return this.rules;
    }
}

Next Topic | Previous Topic | Home

Last built: June 7, 2012