SALES: 1-800-867-1380

Use the RoleEnvironment.Changed Event

Updated: October 24, 2014

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.

  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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft