Monitoring Azure WebJob & Function App Failures - azure

I'm currently acting as the SharePoint admin for a company that has some code jobs (mix of WebJobs and Function Apps) running in the background of an O365 site, performing some misc tasks like ensuring the webhook sub is still active, cloning sites, and populating clones with info from a form in SharePoint.
These jobs are mission critical as they are linked to a crisis management site so I've been asked to put in some monitoring for assurance that we'll be alerted if any fail, either as part of a schedule or on-demand (again there is a mix of these).
The problem is I don't really understand much of Azure, other than it replaces the farm solutions in SP as a place to run back-end code, especially with the plethora of names for things that seem to me to be pretty similar.
Can anyone reccomend an easy way I can set up some sort of monitoring trigger for the individual webjobs and functions for a failure, ideally just using the built in Azure control panel (i.e. without having to deploy any code - I'm really not a C# and the like coder).

For both Function and webjob, you all could use Application Insight to monitor them.
For Function, Ivan has linked the official doc: Monitor Function, and for webjob official doc actually has a tutorial about configuring Application Insight:Add Application Insights logging.
Also you could refer to my answer about using application insight. Use this package:Microsoft.Azure.WebJobs.Logging.ApplicationInsights and add JobHostConfiguration.
string instrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
if (!string.IsNullOrEmpty(instrumentationKey))
{
// build up a LoggerFactory with ApplicationInsights and a Console Logger
config.LoggerFactory = new LoggerFactory().AddApplicationInsights(instrumentationKey, null).AddConsole();
config.Tracing.ConsoleLevel = TraceLevel.Off;
}
Then you will be able to add webjob logs. Hope this could help you.

Related

Logging from an azure console app as a web job

I am in search for a good way to log various messages while being able to use functions, logic, monitoring, etc to get notified or run a certain task to fix a problem and notify someone.
What I have in mind is something like "If a specific error happens send me a notification or restart a service"
What I currently already have is an app service that holds 10 web jobs(continuous, triggered). Two of them use the Azure Web job SDK and the rest of them are plain .net core console apps. All of them generate structured logs using serilog and are saved to blob storage.
Is there something I am missing? I don't want to reinvent the wheel here.
You can use application insights with webjobs, more details are here.
You can also set an alert in application insights if error occurs, refer to this doc.
Any more questions please let me know.

Azure function application insight configuration

I would like to customize the application insight configuration for an azure function by creating telemetry initializer. My current scope of work is to identify a way to correlate messages sent from an HTTP triggered azure function to another HTTP triggered azure function and for that was trying to follow the help at dzimchuk.net. However I do not see an ApplicationInsights.config in my azure function project. I found the GitHub project that includes an app insight configuration file, and hence not sure how that project was created. Any help would be much appreciated.
Functions v2 has the capability to do this, but it isn't directly supported.
Warning
Do not add AddApplicationInsightsTelemetry() to the services collection as it registers services that conflict with services provided by the environment.
Do not register your own TelemetryConfiguration or TelemetryClient if you are using the built-in Application Insights functionality.
Closest I've gotten is this comment on a github issue which tries to preserve the existing functionality.
There are a few others I've seen around but many of them break integrations with Azure Portal such as the Quick Pulse (Live metrics feed) and performance metrics.

Monitoring the Azure app services

I was wondering if someone can shed some lights on the application monitoring and alerting solution that's being used to specifically monitor the Azure app service. We have multiple API apps running on App service service and we would like to monitor certain metrics (ex: Availability, response time, number of request received, etc). I enabled the application insight on each of these apps and the result is quite promising, it fulfills all my requirement, but there's one small issue: I need to scroll through each app to see their performance. I can't aggregate them all in one space. I would like to create a centralized dashboard for all aforementioned metrics and have them displayed. I tried using OMS but it seems to be lacking a lot of functionality.
Any pointer would be very appreciated.
I wrote recently about it on our blog: http://predica.pl/blog/azure-monitoring-and-auditing/ - you will find link to MS documentation also there.
If you are using App Insights already you should be able to pick things from App Insights and put it on the Azure portal dashboard. Other than that probably getting data into Power Bi application insight is your best shot - https://powerbi.microsoft.com/en-us/documentation/powerbi-content-pack-application-insights/

Azure Websites Application Insights - switching config

I have an Azure Website. For the sake of this question, the production version of the website runs on example.com, and a test version of the website runs on sandbox.example.com.
The only difference between the two is that they have different configuration.
At present, they are running under different websites, and I deploy the same website to each azure website via git.
I'd like to separate out the Application Insights data. Is there a technique or process that anyone uses - apart from editing the ApplicationInsights.config file in the sandbox environment post deploy?
Or would using a deployment slot handle this in some way?
There was a new blog post about exactly this today: Application Insights Support for Multiple Environments, Stamps and App Versions.
The destination of the telemetry is determined by the instrumentation
key (iKey), which is sent along with every telemetry message. In the
Application Insights portal, similar events and metrics with the same
iKey are aggregated to give you charts of average durations, event
counts, the sum of users, and so on. The iKey appears in two places in
your project. One is in ApplicationInsights.config:
<InstrumentationKey>94843456-2345-3456-4567-324562759284</InstrumentationKey>
If your application has web pages, the iKey also appears in a script
in the head of every web page. Usually, it’s only coded once in a
master page such as Views\Shared\_Layout.cshtml.
To direct telemetry to different application resources, we can create
several resources with different iKeys. Then we only have to change
the iKeys in the application at each transition in its lifecycle –
along with other configuration data such as connection strings,
certificates, and subscriptions.
The article then goes on how to do this in code, confg, etc:
1) Add iKey as a property in Web.config:
2) Instead of using the iKey from ApplicationInsights.config, we’ll
set it in the code. In global.asax.cs.
To avoid confusion, remove the <InstrumentationKey> node from
ApplicationInsights.config.
3) Configure the web pages to pick up instrumentationKey: "#Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey". This is
the script usually found in View\Shared\_Layout.cshtml.
4) Don’t forget to update your Web.config with appropriate iKey
configuration during the deployment process. You might devise a way of
setting it appropriately as part of your build, but I’ll leave that to
you.
Found this semi-related question: How to support multiple Azure subscriptions for a single application with application insights this is for using by cloud services, and it works!
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["appInsightsKey"];
I have done this in my unity registertypes method, it works there.
In the Azure portal for websites, on the config tab there is a section called App Settings. You can put your different configuration settings here. When publishing, azure will inject those settings into web.config.
Then just use WebConfigurationManager.AppSettings as you would normally and it will pull the injected values.

Saving complete azure configuration to file?

Is there any way to save the complete state of my azure configuration?
Basically, I just created a demo for a project I'm working on. This demo has a website/webjob, scheduler, storage queue, storage blob, redis cache and documentDB. I have configured these components in terms of size/scale/schedules but now the demo is done.
I don't want to pay for these services and I don't need them online for now. However, I don't want to have to recreate and reconfigure them if I need to relaunch the demo in a month.
Is there a way to save my current azure configurations to a file and then to be able to recreate all the services again automatically (with a script or a small program)?
Thanks!
This is a very good question, that sums up a historical problem we're in the process of making easier and more flexible. I'll answer this question with two parts.
First and foremost, you have tools like the PowerShell cmdlets now, that you can script out the creation of an entire "world" in Azure and then re-run whenever you want, against a subscription, to scaffold out a whole architecture. You can also use the management libraries for .NET to do this from a .NET application. When we embarked on the VS WebJobs tooling, for instance, I worked up a prototype for my developers on using MAML to create WebJobs and scheduler job collections. You can see the demo code for that here: https://github.com/bradygaster/maml-demo-scheduled-webjob-creator
We've also recently embarked on new mission of re-creating a lot of the management APIs so that they support the notion of templates and resource groups, to marry up with the new portal experience. Here's a great MSDN article that discusses how the PowerShell cmdlets for the Gallery could be used to pull down a list of the various templates that could then be pushed back up as fully-baked architectures running in Azure. You have the capability of building these templates yourself, then you could use these cmdlets to fan out and create things that you write up in your own custom templates. http://msdn.microsoft.com/en-us/library/dn654596.aspx
Hope this helps!
For Azure websites you can use the Back and Restore option to store the site and restore it back when you want to demo again, But all you have to do is Stop the services and you should be able to keep the demo without incurring cost.

Resources