How to access event log from window azure - azure

I would like to fetch window event logs from Azure webrole's instance. when i connect to RDP of instance then by Event viewer i am able to see Window Event Logs of "Application" & "Error" type. Is there any way to directly access that logs using API or something else or i need to use Diagnostic to enable that log data to transfer in to storage and from there i can access?

IF you want to directly access the Azure VM Event logs, the best option is to use use Azure Diagnostics and Azure Cmdlets to access Event Log details. In my understand this one is very easy to setup and once you have access to Event logs, you can download and save it to your local machine. The method is described as below:
http://michaelwasham.com/2011/09/20/windows-event-logs-with-windows-azure-diagnostics-and-powershell/
There is another simple method is that you can create an ASP page and use Event Log API to simply access the event log directly on your web role and customize it the way you would want to see. You can find several examples on net on how to do it i.e. this one. This is a very simple way to get what you are looking for and the only drawback to this approach is that the ASP page will be available on website, unless you find some ways to protect it.
Although you can use any of the above method, setting up Windows Azure Diagnostics to collect Event log from the machine and send to Windows Azure Storage, is best and preferred method. The steps are described here, in case you don't know:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb427443(v=vs.85).aspx
Any other method to collect these logs (using Azure Connect and Remoting etc) would be complex and troublesome.

Should be possible using http://technet.microsoft.com/en-us/library/cc766438.aspx
Although the port will be blocked by default, you will need to change the firewall settings.
See this article for the port numbers (search event log) http://support.microsoft.com/kb/832017/en

Related

Push notification from azure blobstore to arbitrary number of webapps

I use data stored in in a blob for some configuration for some azure web apps, and I'd like to react to changes to it in near realtime. Currently I just set a timed event and periodically check if the etag of the blob has changed, and if it has then download the new blob.
This is ok, but I don't want to poll the blob too often, and I also want to be reactive. The devs changing the values in the blob want to be able to test the new values quickly.
The web app scales up and down, and each instance of the web app needs to download the config file. So, as far as I can tell, I can't just use the event system that azure storage has, as that would only send a notification to one instance.
Is there a recommended way to do this?
Per my understanding, you want to centralize manage your azure web apps. Once some config has been changed, your app services should reload configs on time automatically. Actually, Azure App Configuration provides this kind of functionality.
You can also config the condition to reload all configs in code. This is a .net core sample here. And you find other samples under the Enable dynamic configuration blade.

Monitor if service on VM is up integrated in Azure

I have a VM running a service which I connect to from my application. Let's say it's a MongoDB service.
I would like to monitor with one of Azure's existing tools if the MongoDB service is up. The easiest way to accomplish this seems to be a simple tcpconnect on the MongoDB port (27017), and if it fails say 3 times, send an alert. I can't figure out how to configure this with either:
Operation Management Suite (OMS)
Log Analytics
Network Watcher.
Is it possible to configure this kind of monitoring/alerts with these services? Or is there another service that is managed by Azure which I can use to accomplish this?
I spent some time researching and trying to find some answer, since I haven't set this up personally.
Easiest I think would be to configure Log Analytics to read any custom logs your application creates and let it ingest them. Then create a log search with an alert that either alerts you or automatically run some custom logic.
I could not find any way to monitor if a port is open, e.g. how you can do with "psping www.google.com:80" for TCP 80.
In other words, to me seems easiest would be to:
Set up custom log collection in log analytics
Create a log search for the events you want to monitor
Set up an alert for the custom search

Is there any other method for exporting data from Microsoft Application Insight other than 'Continuous Export'?

Is there any other method for exporting data from Microsoft Application Insight other than 'Continuous Export' ?
Any server side API for Application Insight for our resource on Azure that can be consumed.
No, Continuous Export is the only supported way at this time. Please continue checking Application Insights blog from time to time for new feature announcements.
If you are using Azure app service & using any logging then,
First, go to Azure portal then go inside your specific app service which logs you want to export continuously.
Then see the menu, there you find "Diagnostics logs", go inside the "Diagnostics logs".
Here you find "Application Logging (Blob)", make it on (by default it's off) and add your storage at storage settings.
Here you also find log level and Retention Period. Change it with your convenient value.
Yes, You can use API to export the data from Azure Application Insights. https://dev.applicationinsights.io/
There are some limitation:
https://dev.applicationinsights.io/documentation/Authorization/Rate-limits
https://learn.microsoft.com/en-us/azure/data-explorer/kusto/concepts/querylimits
To overcome the limitation,I wrote a python script to export the data by limiting the data.
https://gist.github.com/satheeshpayoda/92065d9fbaf5b0158728a8537d79af0e

is azure diagnostics only available through code?

Is Azure diagnostics only implemented through code? Windows has the Event Viewer where various types of information can be accessed. ASP.Net websites have a Trace.axd file at the root that can viewed for trace information.
I was thinking that something similar might exist in Azure. However, based on the following url, Azure Diagnostics appears to require a custom code implementation:
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/#overview
Is there an easier, more built-in way to access Azure diagnostics like I described for other systems above? Or does a custom Worker role need to be created to capture and process this information?
Azure Worker Roles have extensive diagnostics that you can configure up.
You get to them via the Role configuration:
Then, through the various tabs, you can configure up specific types of diagnostics and have them periodically transferred to a Table Storage account for later analysis.
You can also enable a transfer of application specific logs, which is handy and something that I use to avoid having to remote into the service to view logs:
(here, I transfer all files under the AppRoot\logs folder to a blob container named wad-processor-logs, and do so every minute.)
If you go through the tabs, you will find that you have the ability to extensively monitor quite a bit of detail, including custom Performance Counters.
Finally, you can also connect to your cloud service via the Server Explorer, and dig into the same information:
Right-click on the instance, and select View Diagnostics Data.
(a recent deployment, so not much to see)
So, yes, you can get access to Event Logs, IIS Logs and custom application logs without writing custom code. Additionally, you can implement custom code to capture additional Performance Counters and other trace logging if you wish.
"Azure diagnostics" is a bit vague since there are a variety of services in Azure, each with potentially different diagnostic experiences. The article you linked to talks about Cloud Services, but are you restricted to using Cloud Services?
Another popular option is Azure App Service, which allows you many more options for capturing logs, including streaming them, etc. Here is an article which goes into more details: https://azure.microsoft.com/en-us/documentation/articles/web-sites-enable-diagnostic-log/

What hooks can I use to detect a VM Shutdown event with Azure IaaS?

I'm working on an automation tool whereby I need to trap events that are occurring within an Azure subscription.
Taking an Azure VM as an example - how can I trap a shutdown event for a single VM so that for example, a web service is called?
Azure Scheduled Events (in Preview at time of post) is your best bet. This is built upon the Azure Instance Metadata Service (also in Preview at time of post) which surfaces historic and up-coming information from within the VM, allowing you to proactively react to events.
To my knowledge, there's no way to monitor for events such as this from outside the VM, however this article provides some great code examples which could be run from within the VM that you could use to trigger an alert/action outside the VM if you needed to.

Resources