Azure

Azure App Service – Profile A .Internet Core Utility Hosted In Azure App Service – Linux

On this article, we’re going to learn to discover efficiency points in a .Internet Core 3.1 utility hosted in Azure App Service – Linux atmosphere

 

Be aware

Profiling for apps hosted within the Linux app service plan is in preview right now of writing.

 

Create the next providers in a Useful resource Group.

 

Service Kind Feedback
Azure App Service Runtime Stack – .Internet Core 3.1
Azure App Service Plan OS: Linux Pricing Tier: Normal or Greater
Azure Utility Insights As soon as created, Seize the Instrumentation Key from the Overview blade

 

I’ve created the above providers in a Useful resource Group as proven under.

 

Azure App Service – Profile .Internet Core App Service – Linux – Useful resource group – Sources

 

When you all of the providers provisioned, hyperlink the Utility Insights occasion with the App Service in order that the App Service can push the appliance telemetry to the Utility Insights occasion. We will hyperlink each of them by making a Key named APPINSIGHTS_INSTRUMENTATIONKEY and paste the IKey as proven under.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Settings

 

Create a .Internet Core Internet utility and set up the under Nuget Package deal

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – Profiler Nuget Package deal

 

Navigate to the Startup class and register the under service to be able to allow Utility Insights together with the profiler.

  1. providers.AddApplicationInsightsTelemetry();   
  2. providers.AddServiceProfiler();    

The Configure methodology ought to look  like this when you add the above traces of code.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – Configure Providers

 

Let’s now add some code within the utility that simulates some efficiency points. Navigate to any motion methodology and add the under code that makes your app run sluggish.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – Random Sleep

 

The above code added a sleep time between 10 to 20 seconds everytime you entry the Privateness web page. Let’s go forward and deploy the appliance to Azure App Service

As soon as the appliance is deployed, it is best to be capable to navigate to the web page by clicking on the Browse button within the Overview web page of the App Service.

 

You would possibly discover slowness once you navigate to the Privateness web page as we’ve got used Thread. Sleep. Nonetheless, in real-time, there could be varied the explanation why an endpoint can be sluggish. As a developer, one could be all for figuring out the precise methodology which is taking extra time. Allow us to now perceive methods to establish these slow-performing elements.

 

Allow Profiler in Utility Insights

 

Navigate to the Utility Perception’s Efficiency Blade and click on on the Profile button as proven under.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Insights – Efficiency Blade

 

It takes you to a different blade which proven all of the profiling classes. Click on on the Profile Now button to provoke the Profiling course of as proven under.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Insights – Profile Now

 

When you click on on click on on Profile now button, you will note a brand new blade open which provides some data in regards to the progress of the profiling.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Insights – Profiler Session In Progress

 

Whereas that is taking place, you should simulate site visitors in your internet app. Principally, once you provoke the method, the required brokers can be put in on the App Service occasion and the profiler will begin the method of gathering the metrics and it pushes to the Utility Insights occasion. By default, it runs for 120 seconds. So, throughout that interval it collects the metrics of the requests. If there aren’t any requests throughout that interval you don’t see any information.

 

Typically, the Profile course of would get timed out with the message Profiling timeout. Refresh and take a look at once more as proven under.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Insights – Profiler Session – Timed out

 

In such instances, it is best to guarantee that you’re utilizing the Normal Pricing tier or larger for the App Service Plan.

 

Be aware

As per Microsoft, Profiler works from the Fundamental tier onwards. Nonetheless, I couldn’t get it to work with the Fundamental pricing tier.

 

When you guarantee that you’re utilizing the Normal pricing tier, you may retry the Profiling once more. If the profiling is profitable, you then would see the classes within the Profile itemizing as proven under.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Insights – Profiler Session Itemizing

 

Click on on the OnDemandSchedulingPolicy merchandise which can present extra particulars as proven under.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Insights – Profiler Session Examples

 

Clicking on any of the objects proven above will present extra particulars about your complete tree of how the assorted elements are execute as proven under.

 

Azure App Service – Profile a .Net Core Application hosted in Azure App Service – Linux
Azure App Service – Profile .Internet Core App Service – Linux – App Insights – Profiler Session

 

As proven within the above screenshot, it clearly reveals us that the Privateness motion methodology of the HomeController is the offender which is taking lot of time.

 

The above Profile tree clearly supplies us details about which elements are taking extra time. On this manner, we will simply establish the elements which can be taking extra processing time which helps the builders isolate the issue and repair it.

 

That’s it. On this article, we’ve got learnt methods to profile the .web core utility hosted in Linux internet apps. Hope it helps.

 

Completely happy Profiling.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button