Azure Bot logging - c#

I have a Bot configured for Teams and hosted in Azure. I have a couple of graph api requests sent from the Bot. I would like to log the time between request, response, and other related exceptions thrown. Where is this log best kept for an Azure hosted Bot?

This can be done automatically when you choose to integrate Application Insights. See this guide:
Application Insights helps you get actionable insights through application performance management (APM) and instant analytics. Out of the box you get rich performance monitoring, powerful alerting, and easy-to-consume dashboards to help ensure your Bot is available and performing as you expect. You can quickly see if you have a problem, then perform a root cause analysis to find and fix the issue.
You can also keep track of bot messages analytics using Application Insights (source):
Analytics is an extension of Application Insights. Application Insights provides service-level and instrumentation data like traffic, latency, and integrations. Analytics provides conversation-level reporting on user, message, and channel data.

The easiest way (if you re hosting it on Azure App Service), is to enable App logging and then use Stream Logs Service. Of course, on your app you would need to use Trace class and log the events manually.
Check: https://learn.microsoft.com/en-us/azure/app-service/web-sites-enable-diagnostic-log

Related

Azure - Log custom events in azure and load logs to show in Asp.net UI

I wish to leverage the logging services/features available in azure (Azure monitor/App insights/Log Analytics/etc ) and use them to store the custom events arising out of customers' actions in my app. Events like updating a record, adding, or deleting records, within my app, and also wish to leverage the search capabilities provided by the azure services, within my App via REST or SDK.
I wish to show those logs in grid form in my Asp.net UI and let the users visualize the logs and take actions after analyzing them. By providing the abstraction, I can give the user the ability to log anything that he likes while using my application and also have a search ability, but I will provide the interface to store and load the logs.
I am thinking that I can use the azure app insights for the same, but I don't see any SDK code or REST API to load the logs, provide the search capabilities to the user.
Is there a better path that I can take than going for Azure app insights?
Please check if given steps and references help to work around:
am thinking that I can use the azure app insights for the same, but I don't see any SDK code or REST API to load the logs, provide the search capabilities to the user.
You can filter and track the telemetry data before it's sent from the SDK by implementing ITelemetryProcessor.
To get your custom events data, you can use the code like customEvents | summarize sum(itemCount) in Logs Page which comes from the trackEvent(...).
Here is the MS Doc given code in multiple programming languages to track the custom events and metrics in Analytics.
To provide the custom events and metrics data to the end user, there is the data access API from the Azure Portal.
Other ways to extract data include export from Analytics to Power BI and continuous export.
References:
Azure Application Insights doesn't show custom events created in Azure function
Best Practices in Handling the Application Insights Custom Events
I zeroed into using the Log Analytics Workspace's "Custom logs" feature. This provides a REST endpoint to log the data and SDK to retrieve the data. Here is the link.
https://learn.microsoft.com/en-us/azure/azure-monitor/logs/data-collector-api

Best solution to capture all requests/responses of Asp.Net Web API hosted on Azure

My system is an Asp.Net Web API (.Net 5) hosted on Azure kubernetes service. I have a requirement to log all requests/responses for all controllers of the system. Currently, the system logs only exceptions to Application Insights using Middleware and the default logger injected by the framework.
My questions are:
Should I develop the new requirement as the current implementation
of logging exceptions by adding an additional middleware to log all
requests/responses to Application Insights?
Are there any services/configurations on Azure to log all requests/responses so
that I don't need to modify the code?
What are the best practices for that kind of requirement? Is this ok to save all
requests/responses into Application Insights to easily
query/trace/investigate issues later or it should be somewhere else such as databases. etc.?

Is uploading / updating Web.config a good way to change trace level of System.Diagnostic tracing?

Generally, I would inject TraceListeners and adjust trace level through app.config and Web.config. And I understand that IIS will restart the Web app after the Web.config is updated and the last HTTP request is done and new HTTP requests will be pending before the new instance is created. I have been doing this for years no problem.
However, if I deploy the Web app to Azure managed services, or I have many (clustered) instances of the Web app, I am not sure if updating / uploading Web.config to each instance is still a good practice? Is there some alternative/better method to change the trace level for System.Diagnostics.TraceListeners?
And what if I deploy to AWS or alike for clustered services?
You got it right! updating / uploading Web.config to each instance is not bad but could be tedious task,or error prone approach. Rather,
Would recommend to go with Application Insights,an extensible analytics service that monitors your live web application.
Just install a small instrumentation package in your application, and set up an Application Insights resource in the Microsoft Azure portal.
Performance impact would be minimal as,tracking calls are non-blocking, and are batched ; sent in a separate thread.
Telemetry types such as 'Exception traces from both server and client', 'Diagnostic log traces' and many more helps you understand how your app is performing and how it's being used.
Also you can perform Diagnostic search on instances of requests, exceptions, custom events, log traces, page views, dependency and AJAX calls.
For more information do read : Application Insights - introduction
Thanks,
Kasam Shaikh

How do you integrate Application Insights into Service Fabric?

I currently use Azure Application Insights for logging on all of my Web API and MVC applications. Obviously the majority of this logging is automatic which is great. For events that I manually want to capture I have implemented a "LoggingUtility" which has methods like "LogError" and "LogInformation" that simply call Trace.TraceError and Trace.TraceInformation (the thinking is that the implementation of logging could be changed in one place in the future). The Trace is then captured by Application Insights.
I have started to develop some Stateful Services in Azure Service Fabric and cannot seem to find a way to use Application Insights. I have stumbled upon several articles pointing me towards a NuGet package that was in prerelease but has now been removed (https://www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/).
Of course the Service Fabric templates generate the "ServiceEventSource" but firstly I cannot see how this would be useful for Application Insights and ideally I want all logging to be done through my "LoggingUtility" class.
Is it possible to integrate Application Insights into Service Fabric? If so, can I simply continue using Trace (via my "LoggingUtility" class)?
You have two options:
1. Using the Application Insights SDK in your LoggingUtility class to send information directly to AI
2. Using Windows Azure Diagnostics (WAD) to forward Eventsource traces to AI, using the provided EventSource class in the SF project templates. That class you can modify to be your LoggingUtility class implementation.
Considering that you are running your SF cluster in Azure, the second approach is the current recommendation, as Service Fabric system service events are also using Event Tracing.
For configuring Azure Diagnostics to AI, follow the steps outlined in this article: https://azure.microsoft.com/en-us/blog/azure-diagnostics-integration-with-application-insights/
Be aware this article targets Cloud Services and VMs, but just use the VM Scale Set for configuring Azure Diagnostics in stead of a VM. That should work.
The NuGet package is no longer supported: https://social.msdn.microsoft.com/Forums/en-US/f0f1ad78-4d83-48e5-b1da-4a9f0eddb9b2/application-insights-for-service-fabric?forum=AzureServiceFabric
We used the new Microsoft.Extentions.Logging and wrote a insights logger - it gets the service fabric messages via Trace we also pulled out all the ETW stuff it doesnt add much .

Is It Possible To Launch A Lync Session And Invite Tech And External User From A C# Web App?

I'm tasked with writing a web app that will connect an internal employee and an external client while logging Case details. Our company recently switched over to Lync, so I'm a bit lost on the API for doing this.
Ideally, this would be a web app (C# & ASP.NET) so that the customer support department doesn't have to install something to every workstation. It would also mimic the behavior found in this article for sending an email to allow external users to connect.
Is UCMA required for this? We have a generic Lync account that could be used by a service to facilitate these requests if that would be more appropriate. I can also force the issue for using a desktop app if need be.
I'm just having a hell of a time finding the right API calls to make this happen on MSDN so any links to docs or tutorials would be a huge help.
Some research that doesn't quite point out what needs to be done:
UCMA: Chat with users not in AD
How do I Invite a user by email to a Lync 2010 chat session using the API?
you should take a look at this sample located at :%Program Files%Microsoft UCMA 3.0\SDK\Core\Sample Applications\Reference\ContactCenter
You'll find more details here : http://msdn.microsoft.com/en-us/library/hh285604.aspx
Hope that helped.
You should also take a look at UCWA - Microsoft's Unified Communications Web API.
Unified Communications Web API
It's a great platform for adding Lync functionality into your Web application, has an Online Demo with full source code as well.

Categories

Resources