Export (0) Print
Expand All
5 out of 10 rated this helpful - Rate this topic

Use the RoleEnvironment.Changed Event

Updated: November 13, 2013

The Changed event occurs after a configuration change is applied to a role instance.

The RoleEnvironmentChangingEventArgs class provides a Changes property that returns the collection of the configuration changes that were applied to the instance. The Changed event is raised after the changes have been applied. The new values for the configuration settings can be retrieved from the RoleEnvironment.GetConfigurationSettingValue method, while the old values are no longer available.

To define the event handler

  1. Open the source file for the role.

  2. Ensure that the project references the Microsoft.WindowsAzure.ServiceRuntime.dll file and that the following using statement is added to the file:

    using Microsoft.WindowsAzure.ServiceRuntime;
  3. Add the following code to specify the event handler:

    RoleEnvironment.Changed += (sender, args) =>
       if (args.Changes.Any(chg => chg is RoleEnvironmentTopologyChange)) 
          // Perform an action, for example, you can initialize a client, 
          // or you can recycle the role
  4. Save the file.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.