This question is more on the logging to AI from Azure Functions and from the WebAPI. In WebAPI we need to provide the Instrumentation Key while initializing the Logger from the Startup.cs. But in functions, it's been taken Automatically and the logs are getting logged on to the AIs automatically. Why is the difference in behavior for logging data from different kind of applications on to the AI in Azure. I was trying to figure out the same and most of the people gave an answer which says the function contains the inbuilt logger and it is more of a serverless. I am not getting satisfied with this answer as WebAPI also runs in the context of the AppServices in Azure. It will be helpful if some one can throw some light on this issue.
Regards,
Ram
The answer "the function contains the inbuilt logger and it is more of a serverless." is actually the answer.
The azure function has an extension Microsoft.Azure.WebJobs.Logging.ApplicationInsights running background which is used to read Instrumentation key and write logs to Application insights. So you just provide an Instrumentation key for function is ok. You can also find more via the source code.
But web api does not have such built-in extensions, we need to configure AI by ourselves.
Related
I have a Node.js functions app running in azure and it is processing thousands of requests every minute, I would like to enable Application Insights using the Azure Portal in order to diagnose an issue but I fear this may interrupt the function while it configures itself.
Is this a valid concern?
All the documentation I have found regarding Application Insights does not mention the impact on any running applications.
Adding AI integration is only a matter of adding a key to app settings, but any edits to app settings require a function app to restart, so yes it will affect your function.
I did some tests, and I made a request to it after enabling Application Insights. It will indeed be affected for a few seconds because it will change the app settings and then restart the Azure function.
Our organization have developers from language background and each would write Function App in their own language of comfort(C#, Java or Python). All these function Apps are exposed as API in APIM. By default payloads are not captured in application insights. I have seen blogs talking about adding custom Telemetry Intializers to do this, but all at backend(i.e ASP.NET or Function app). Is there a way to add this intializer in APIM level? Or is there any other alternative way to achieve this?
Here’s the doc on how to set up logging to Application Insights in APIM (including setting up headers/body logging): https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-app-insights
I would like to profile a .Net Core Azure Function such that I can see a breakdown of how long each method invocation takes within the call stack. I believe that Application Insights does not provide such detail.
I have searched for different profilers on the web and it appears that none have support for Azure Functions in consumption mode. Stackify has released Retrace with support for Azure Functions in App Service Plan mode only (https://stackify.com/announcing-retrace-azure-functions-preview/). I have tried to use JetBrain's dotTrace to run my Function App exe file to no success.
Are there any profilers that can be used to profile .Net Core Azure Functions in consumption mode?
Currently we do not have a profiler for function apps. You could try to use the output of the logs and do some post processing to figure each method invocations in your function app.
If you want to make a feature request for Azure Functions you can leave that feedback here: https://feedback.azure.com/forums/355860-azure-functions
Is it possible to use the application insights profiler on azure functions? Either via the portal or a more manual means.
I haven't found a way in the portal and I haven't seen explicit documentation stating either way nor github tickets.
I'd assume probably not, as many of the automagic features of application insights don't seem to be supported yet.
If it's not possible, out of interest is it because of the azure functions sandbox not giving enough permissions for profiling?
If it's not possible, out of interest is it because of the azure functions sandbox not giving enough permissions for profiling?
The application insights profiler is just supported in web app. The Azure function belongs to function app. So you can not use profiler in Azure function.
Profiler currently works for ASP.NET and ASP.NET Core web apps that are running on Web Apps.
If you want to suggest Microsoft to add some new features like app insights profiler in app insights in azure function, you could put your suggestion in Github.
Next steps
Application Insights is now GA’d and ready for production workloads. We’re also listening for any feedback you have. Please file it on our GitHub. We’ll be adding some new features like better sampling controls and automatic dependency tracking soon.
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.