Access your Azure Websites logs

November 3, 2015 at 7:00 am in Azure, Azure Web Apps by Florent

Last week, I tried to deploy a new website in Azure Websites. The deployment was done successfully, but when I browsed the web page, I had the following error:

image

To investigate to see where the problem is, I need to get the IIS logs. Thanks to this MSDN blog post, I found that we can get log files from the FTP. I will explain to you how to do this.

First, connect to https://portal.azure.com and navigate to your web app:

SNAGHTML1e8214ad

Go to the Deployment credentials and choose a unique username. Click on Save:

image

Now, go to the Dignostics logs section. Here, you will have your login credentials to connect with an FTP client. You can manage which logs that you want to activate/deactivate:

image

Open your FTP Client and provides the information that you get just before. Don’t forget to provide the site name in front of your username:

image

I’m now connected and I have access to these 3 folders:

image

If you go on site > wwwroot, you will see your deployment:

image

I would like to take log files. Go to the LogFiles folder, in the root. You have an eventlog.xml file. This file contains logs that are extracted from the event viewer in the server where the web apps is running. I downloaded it and opened it:

image

I checked each <data> in the file and I found an interesting line in the log:

<Event><System><Provider Name=”ASP.NET 4.0.30319.0″/><EventID>1310</EventID><Level>2</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime=”2015-10-30T11:31:22Z”/><EventRecordID>200681015</EventRecordID><Channel>Application</Channel><Computer>RD000D3A22D7A5</Computer><Security/></System><EventData><Data>3007</Data><Data>A compilation error has occurred.</Data><Data>10/30/2015 11:31:22 AM</Data><Data>10/30/2015 11:31:22 AM</Data><Data>8f0c8ce90d1e452dbe8957048d3c26f8</Data><Data>8</Data><Data>1</Data><Data>0</Data><Data>/LM/W3SVC/367992338/ROOT-3-130906782805054017</Data><Data>Full</Data><Data>/</Data><Data>D:\home\site\wwwroot\</Data><Data>RD000D3A22D7A5</Data><Data></Data><Data>7728</Data><Data>w3wp.exe</Data><Data>IIS APPPOOL\scugbe</Data><Data>HttpCompileException</Data><Data>(0): error CS1617: Invalid option ‘6’ for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)

</Data>

The problem here is that the /langversion parameter in the Web.config is 6 and it’s an invalid option with this deployment. It must be ISO-1, ISO-2, 3, 4, 5 or Default. So I modified this value to 5 in my Web.config then I redeployed the web app and it now works after a simple refresh:

image

It is very cool to have the access of log file to debug Sourire