How does the Windows Azure Fabric controller do that?

Kevin Williamson has a great post on the overall flow of things from the point of publishing of your package up on the Windows Azure Developer Portal to Run().

These are good things to know as many times you need to inject steps, tasks, context at various stages of your service instance’s lifetime.

http://blogs.msdn.com/b/kwill/archive/2011/05/05/windows-azure-role-architecture.aspx

Windows Azure Role Architecture - Windows Azure - Troubleshooting & Debugging - Site Home - MSDN Blogs