I have an API deployed as an Azure Website (not a worker role). The code for the site has Trace statements dotted through it that I would like to capture in an Azure Table via the Azure Diagnostics.
I'm using Trace.TraceError, Trace.TraceInformation, etc.
I've followed the instructions here, which essentially say that all that is required is to flick the switch in the management portal and set a location for Application Diagnostics: https://azure.microsoft.com/en-us/documentation/articles/web-sites-enable-diagnostic-log/
I have ensured that the Microsoft.WindowsAzure.Diagnostics reference is added to the project, and I have also tried adding the following to the Web.config (even though the instructions don't say this is necessary):
<system.diagnostics>
<trace autoflush="true" indentsize="4" >
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics" />
</listeners>
</trace>
</system.diagnostics>
Despite this, the only output I get to the Azure Blob and/or Table (that I specified in the portal) is the following:
24/06/2015 14:02:49 AlasdairOTCDev Verbose SnapshotHelper::RestoreSnapshotInternal SUCCESS - process 11284 -1
24/06/2015 14:02:48 AlasdairOTCDev Verbose SnapshotHelper::RestoreSnapshotInternal SUCCESS - File.Copy 11284 -1
Trace levels are set to Verbose in the portal.
What am I doing wrong, and how can I debug this?
Many thanks for any assistance that can be provided as I'm rapidly running out of hair to pull out...
It turns out the root of the problem was with our build.
There was an issue where our build script was not compiling the TRACE symbol. Builds compiled locally did include this (which is why it all appeared to work locally) but when we built and deployed to Azure it was being missed out.
Without the TRACE symbol, none of the logging statements were activated.
You don't need the reference to Microsoft.WindowsAzure.Diagnostics in your project. That is for Cloud Services and the article you referenced does not mention it since it is for Azure Web Apps (formerly Websites).
Assuming you are using an Azure Web App (not a cloud service web role), then you have to use the current Azure Management portal at https://manage.windowsazure.com if you want to configure your web app to store application diagnostics to an Azure Storage Table or Azure Storage Blob Container. In the configure page for the web app, your configuration should look like this for a table storage.
(Currently, the preview portal at https://portal.azure.com only lets you configure application diagnostics logging using the web app's file system)
For anyone who still encounters this problem, besides for the excellent answers given on this page (enable tracing on azure, and making sure TRACE is set to true in your build), make sure you actually flush the traces!
In your code you need something like this:
System.Diagnostics.Trace.TraceError("Can you see me?");
System.Diagnostics.Trace.Flush();
Or
System.Diagnostics.Trace.AutoFlush = true;
System.Diagnostics.Trace.TraceError("Can you see me?");
Related
I have an azure cloud service and I am struggling and feel I have exhausted all avenues on trying to identify what is going wrong. When I try hit one of the actions I get an internal server 500 however I can't see no stack trace of this at all!
I have enabled diagnostics via the setting:
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics" />
</listeners>
</trace>
</system.diagnostics>
And within azure portal I have setup the connection string which I am monitoring via Azure Management Studio. However, for the life of me I cannot see whats going wrong.
I have remoted onto the box to and tried it locally and nothing is seen in the event log, no exception.
What I have done, is change the setting via portal to another value and back to the original and for some reason that seems to make the app work. However, this workaround is unacceptable and for future reference I would like to see the error it is throwing.
Cheers, DS.
From my experience with Cloud Services, I'd advice you to set up a free NewRelic account, add the NewRelic package to your Cloud Service, and check NewRelic's findings.
It's extremely helpful and it will dig up and tell you exactly in which part of your code is the error and the stack trace.
Debugging Apps in the Cloud without something like NewRelic or AppInsights feels almost like shooting in the dark.
I have an azure web site i created to test azure and a web site. So far I like azure but i've run into a problem.
I am trying to run RavenDB embedded database in my website, as I'm not yet ready to get a full database.
RavenDB requires that the app pool is set to Disable Overlapped Recycle.
I followed the steps from this stack overflow article to achieve that:
Disable pool recycling on Azure Websites
When I download the applicationHost.config file i can see the line:
<recycling disallowOverlappingRotation="true" />
Which tells me the overlapped recycling should be disabled.
But i am still getting errors with my ravenDB database, which relates to the overlapped recycling.
Is there any other way to confirm that overlapped recycling is disabled or be able to modify my azure app pool. Without having to get a full support plan or something like that?
My application is Microsoft.Owin, so there is no global.asax or app_start folder. There is a startup class.
I was reading how we can detect request queueing problem in our Azure Service irrespective of level in our service at which it is queued.
http://blog.leansentry.com/2013/07/all-about-iis-asp-net-request-queues/
After reading the above mentioned article, I feel that setting up a monitoring on Http Service Request Queues\CurrentQueueSize performance counter is what I actually want. But now the question is how can I enable logging of this counter in Azure Diagnostics? I read over internet and didn't got much. Any idea?
When you create your project in Visual Studio you will see that you get a <Import moduleName="Diagnostics" /> in your ServiceDefinition.csdef file. This is what enables Windows Azure Diagnostics (WAD) in your deployment.
You will also see a diagnostics.wadcfg file in your Cloud Service project if you expand your Roles. In that wadcfg you can add any perf counters you want, and you will see some examples in there that you can use as a template. For the HTTP queue you would add something like:
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT3M" />
Once you do this then the perf counter will be in your storage account and you can query it using any standard storage tool, or one of the WAD tools such as Cerebrata, or you can configure Verbose monitoring from the management portal and then see the counter in the Monitor tab on the management portal.
Also note that Windows Azure Diagnostics 1.2 has just been released and is a good option if you haven't already enabled WAD 1.0 in your project. For more info see http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/.
I am trying to deploy a large web site to Azure as a Web Role. However, Azure on the Instances tab of the Azure dashboard, it tells me it suffers an error during start up, causing it to restart over and over again.
Where can I find log files that will tell me what specifically is going wrong? The manage.windowsazure.com site doesn't seem to have any.
First, debug on your dev machine. Make sure you deployed the right .cscfg file, you don't have any broken connection strings, you're referencing the right version of the DLLs (the same as Azure's VMs) or are copying newer versions to Azure. If those fail, read this topic on WindowsAzure.com and the topics in this node on MSDN. The Hello World code sample also has a basic demonstration of diagnostics that should be helpful.
The basics of diagnostics in Windows Azure:
Must be manually enabled for each role by importing the Diagnostics module in your ServiceDefinition.csdef file
A storage location needs to be configured for the resulting logs in your ServiceConfiguration.cscfg file, such as the storage emulator, or a Windows Azure Storage account. Depending on the types of logs, they are stored in either blobs or tables.
You can either configure diagnostics collection programmatically or with a file that is read when your role starts and can be updated on-the-fly
You can set up and control how often diagnostics data is downloaded to your storage account (important because transactions/transfer/storage costs money), performance counters, or other metrics you need
There are a series of 4 blog posts at http://blogs.msdn.com/b/kwill/archive/2013/08/09/windows-azure-paas-compute-diagnostics-data.aspx which will walk you through step by step how to troubleshoot a role startup failure including log file locations, etc.
Is it possible to a custom configuration section inside of an Azure Cloud Service Configuration, the same way you would in a regular ASP.NET website?
I.e in a regular ASP.NET site your Web.Config would have something like this:
<configuration>
<configSections>
<section name="myCustomConfig" type="MyNamespace.MyType" />
</configSections>
<myCustomConfig someProperty="someValue" />
</configuration>
How is this done in Cloud Services and shared across multiple different roles?
At this time I do not believe this is possible. There is a post for it on user voice you can vote up: http://www.mygreatwindowsazureidea.com/forums/169386-cloud-services-web-and-worker-role-/suggestions/459944-enable-custom-configuration-sections-in-csdef-cscf.
As a way around this you could put configuration into a file that is stored in BLOB storage. On start up, or when it is needed, all instances could then go pull the file to get the configuration. To deal with changes to the configuration you could either have the instances pulling the configuration from time to time as a refresher, or you could tap into the environment changed event in RoleEntryPoint that is used to detect changes to the Service Configuration. Add a setting to the service configuration that is a version number of your shared config file or something, just anything that could be modified to trigger the RoleEnvironment.Changing event.