If you have been involved in moving ASP.NET 2.0 Web applications to Windows Azure, you probably have faced some compatibility issues related with the IIS Pipeline mode used by default in a web role.
Windows Azure by default uses integrated mode, but for the sake of simplicity, in some migration scenarios, you could also use Classic mode, that will give you the chance to keep your components as they are.
In order to do that, follow the next steps:
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Microsoft.WindowsAzure
Imports Microsoft.WindowsAzure.Diagnostics
Imports Microsoft.WindowsAzure.ServiceRuntime
Imports Microsoft.Web.Administration
Public Class WebRole
Inherits RoleEntryPoint
Public Overrides Function OnStart() As Boolean
'Configure Azure Tracing
ConfigureTracing()
'Configure Azure Pipeline
SetClassicIISPipelineMode()
Return MyBase.OnStart()
End Function
''' <summary>
''' Set IIS Pipeline mode to Classic
''' Only use that method when the app needs backward compatibility
''' </summary>
''' <remarks></remarks>
Private Sub SetClassicIISPipelineMode()
Dim srvManager As New ServerManager()
Try
Trace.WriteLine("SetClassicIISPipelineMode starting...")
Dim appSite = (From site In srvManager.Sites
Where site.Name.Contains(RoleEnvironment.CurrentRoleInstance.Role.Name)).FirstOrDefault()
If Not appSite Is Nothing Then
Trace.WriteLine("AppSite reference retreived")
Dim appPool = (From pool In srvManager.ApplicationPools
Where pool.Name = appSite.Applications(0).ApplicationPoolName).FirstOrDefault()
If (Not appPool Is Nothing) Then
Trace.WriteLine("AppPool reference retreived. Changing mode...")
appPool.ManagedPipelineMode = ManagedPipelineMode.Classic
srvManager.CommitChanges()
Trace.WriteLine("Changes Commited")
End If
Else
Trace.WriteLine("Unable to get AppSite reference")
Catch ex As Exception
Trace.WriteLine("SetClassicIISPipelineMode Exception: " + ex.ToString())
Finally
srvManager.Dispose()
End Try
End Sub
Private Sub ConfigureTracing()
System.Diagnostics.Trace.Listeners.Add(New Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener())
'The Config is Done using the diagnostics.wadcfg file
End Class
And that's it, after these changes, your application will run under IIS classic pipeline mode and you won't have to modify any of your components based on classic pipeline mode.
I remember when I started to work with early CTPs of Windows Azure; I really thought that because of its unique functionalities and because Microsoft commitment to Cloud Computing, Windows Azure was going to be the most productive and cost effective platform very soon. And now we have a lot of enterprise customers using Windows Azure services, the rhythm of Windows Azure innovation is incredible fast, so that's why I have decided that it is time to be fully dedicated to Windows Azure. So After more than 4 years working as a Senior Consultant in Microsoft Consulting Services based in Spain, I have started my new role as Windows Azure Technical Sales Professional based in the UK.
I really look forward to working with all of you; one of my objectives for this year is to help the community as much as possible, so stay tuned!!