Runs code that initializes a role instance.
Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)
Public Overridable Function OnStart As Boolean
if initialization succeeds; otherwise, false
. The default return value is true
Override the OnStart method to run initialization code for your role. The following code example shows how to override the OnStart method:
No code example is currently available or this language may not be supported.
Before the OnStart method returns, the status of the role instance is set to Busy and the instance is not available through the load balancer.
If the OnStart method returns false, the role instance is immediately stopped. If the method returns true, Windows Azure starts the role by calling the Run method. In general, you should avoid returning false from the OnStart method.
A web role can include initialization code in the ASP.NET Application_Start method instead of the OnStart method. The Application_Start method is called after the OnStart method. For more information about the Application_Start method, see ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0.
For more information about life cycle management, see Overview of Building an Application that Runs in a Hosted Service.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows Vista, Windows 7 and Windows Server 2008