Partilhar via


Adding the Autoscaling Application Block to a Host

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

The Autoscaling Application Block enables you to add autoscaling behavior to your Microsoft Azure application. When you work with the block in your application code, refer to the scenarios in the Key Scenarios sections and select those that best match your requirements.

Typically, you will host the block in its own Azure worker role. This worker role can be in a separate hosted service from the roles that the block will perform autoscaling operations on. You can also host the Autoscaling Application Block in an on-premises application. In both these scenarios, the block will monitor your Azure application and apply your autoscaling rules to it.

Note

You can also host the Autoscaling Application Block in the same worker role as the application.

Before you can use the Autoscaling Application Block in your Visual Studio project, you will need to obtain the Autoscaling Application Block binaries and add references to them in your project. This topic describes how you can use the NuGet package management system to add everything you need to your project. For more information about NuGet, and how to use the NuGet Visual Studio extension, see the NuGet website.

To prepare your application

  1. Add a reference to the Autoscaling Application Block assembly. In Microsoft Visual Studio, right-click your project node in Solution Explorer, and then click Manage NuGet Packages.

  2. Click the Online button, and then in the Search Online box, type WASABi.

  3. Click the Install button for the Enterprise Library 5.0 – Azure Autoscaling Application Block package.

  4. Read and accept the license terms for the packages listed.

  5. After NuGet has finished installing the packages, click Close.

  6. NuGet has now updated your project with all the necessary assemblies and references that you need to use the Autoscaling Application Block. Your project now includes the XML schema files for the autoscaling rule definitions and autoscaling service information. The project now also includes a readme file that contains important information about the Autoscaling Application Block.

  7. (Optional) To use elements from the Autoscaling Application Block without fully qualifying the element reference, add the following using statements (C#) or Imports statements (Microsoft Visual Basic) to the top of your source code file.

    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
    using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.Autoscaling;
    
    Imports Microsoft.Practices.EnterpriseLibrary.Common.Configuration
    Imports Microsoft.Practices.EnterpriseLibrary.WindowsAzure.Autoscaling
    

Note

You can use the same procedure to configure both C# and Visual Basic projects to use the Autoscaling Application Block.

Next, add the code to instantiate and run the block. Generally, there are three steps to create code that uses the Autoscaling Application Block:

  • Resolve an Autoscaler instance. The Autoscaler class is the main entry point for the Autoscaling Application Block from your host application.
  • Call the appropriate methods to start and stop the autoscaler.
  • Create the configuration data for the autoscaler.

For more information about hosting the block in an Azure worker role, see the topic "Hosting the Autoscaling Application Block in a Worker Role."

For more information about hosting the block in an on-premises application, see the topic "Hosting the Autoscaling Application Block in an On-Premises Application."

For more information about configuring the block, see the topic "Entering Configuration Information."

Next Topic | Previous Topic | Home

Last built: June 7, 2012