Use Azure Monitor Metrics to get the average daily compute minutes - azure-web-app-service

in my Azure architecture I would like to scale down a couple of web app services.
I would like to use the D1 tear, which has a limited consumption time of 240 min/daily (as you can see in the picture below).
My question is: how can I use the Azure Monitor Metrics tool to get the average compute time for the last 30 days?
Maybe the CPU Time?
I'm asking that because I don't know if those web services work less then 4 hours a day.
Thanks for reading

Thanks for asking question! You may want to know that Azure App Service provides built-in monitoring functionality for web apps in the Azure portal from the Azure portal, you can review quotas and metrics for an app and App Service plan, and set up alerts and autoscaling rules based metrics.
If the app is hosted in D1 that is Shared plan, the limits on the resources that the app can use are defined by quotas.
Check Understand quotas and Monitoring quotas and metrics in the Azure portal
Let us know if further query.

Related

How can I schedule an Azure app service to only be running (being billed for) working hours

On Azure's payment estimator, I can choose the number of hours that I want an app service to be active/paid for. As my app isn't required out of office hours or at weekends, I could reduce the number of hours and therefore the cost estimate considerably versus paying 24/7. I therefore used the estimator to come up with an (affordable for my organisation) estimate of having the services running for max of 500 hours a month.
What is not clear is how, now I have app services up and running on Azure, do I set the services to run on a schedule that matches the cost estimator? Is there an option or functionality hidden away somewhere to do this?
There is no option to suspend an azure app service plan. You can stop/start a web app running on a plan but that won't save any costs. I agree it is confusing that the pricing calculator makes it seem that you can suspend a web app plan.
The only thing I can think of is to scale down to a free tier plan during out-of-office/weekend hours and scale up to a paid plan but that is limited to some basic tiers (for example, since there are no slots in some lower tiers you will have problem if you want to use those). You will have to script this yourself.
The other option is to delete the whole app service plan and web app and create it / deploy again when needed. You can automate the creation using a bicep or ARM template.
References
https://learn.microsoft.com/en-us/answers/questions/278494/can-we-stop-azure-app-service-to-save-cost
Automate tier scaling
App Service unlike Azure VMs don't have the ability to pause billing. If the App Service exists, it is billing. Please see the below recommendations to control costs.
Optimize costs
At a basic level, App Service apps are charged by the App Service plan that hosts them. The costs associated with your App Service deployment depend on a few main factors:
Pricing tier Otherwise known as the SKU of the App Service plan. Higher tiers provide more CPU cores, memory, storage, or features, or combinations of them.
Instance count dedicated tiers (Basic and above) can be scaled out, and each scaled out instance accrues costs.
Stamp fee In the Isolated tier, a flat fee is accrued on your App Service environment, regardless of how many apps or worker instances are hosted.
An App Service plan can host more than one app. Depending on your deployment, you could save costs hosting more apps on one App Service plans (i.e. hosting your apps on fewer App Service plans).
Source: https://learn.microsoft.com/en-us/azure/app-service/overview-manage-costs

Where to find the total daily compute time for an Azure web app

Azure web apps have plans that can restrict their daily compute time e.g.
F1
Shared infrastructure
1 GB memory
60 minutes/day compute
Where in the Azure Portal do I go to see the current and past days of compute time used?
Where in the Azure Portal do I go to see the current and past days of
compute time used?
You can find this information by looking at metrics of your web application in Azure Portal. The metric you're looking for is CPU Time.
More information about it can be found here: https://learn.microsoft.com/en-us/azure/app-service/web-sites-monitor#cpu-time-vs-cpu-percentage.

How to identify the cause of 90% CPU percentages of app service plan in azure?

I am trying to understand the reason of max CPU percentage/memory utilization of app service plan but unable to find any simple way in azure portal. In my app service plan there are 20 app services created and out of 20 only 2-3 app service I am using for user interface and others are using as web API or as background jobs (like webjobs). My app service plan is in isolated pricing tier and average memory and CPU utilization is good it's about 60% but when I check it for max utilization then I found it's being spike up to 90%. Is there anyway to find out the reason of reaching of app service plan utilization up to 90% ?
I am also using SQL database and database is in premium tier. Will DB utilization can impact app service plan utilization?
Please suggest.
You can check this by using the built-in feature of azure web app(see this doc).
Nav to azure portal -> your azure web app -> in the left panel, click on Diagnose and solve problems -> click on Proactive CPU Monitoring, then you can see what is consuming high CPU resources.
Hope it helps.
Thanks for asking question! To add to this, you may also enable Application Insights for particular app.
In case if you haven’t enabled, follow the below steps.
Go to Web App -> Monitoring -> Application Insights -> enable
If ‘Application Insights’ already enabled, you can find the details under ‘Metrics’ tab.
This will give you a detailed view of what is happening in both server and client side.
For more details, refer to Monitor Azure web app performance

How long does it take for an Azure App Service instance to be available after a scale out?

Context: I am designing the auto-scaling (scale out) configuration for my .NET Framework 4.7 web app hosted on a Microsoft Azure App Service. I am using the P3V2 pricing tier. The application is CPU-bound. The app's 30 day CPU average is 30% usage while running on 2 instances, according to the stats indicated in the App Service plan. We occasionally have traffic spikes which will overwhelm the 2 instances: I want to implement auto-scaling.
I want to take into account the App Service Provisioning + App Startup Time when designing the metrics thresholds that decide when my app service scales out. I need to make my thresholds low enough to give Azure time to spin up a new app service instance but not so low that I am paying unnecessarily for processing power that's not needed. Budget is a significant factor.
Question: How long does it take for an Azure App Service instance to be available after a scale out? In other words, how long does it take for an Azure App Service to scale out?
P.S. I recognize that there is a lot more to scaling in/out that I am not addressing here. I'm trying my best to be succinct. :)
Generally, not long at all. By that I mean typically under one minute, but the time will vary depending on several factors, such as application size, time of day, region of deployment.
You could scale out manually and inspect the run history logs on the scale out tab.
FYI you can also use Azure Monitor to create auto-scale policies, in case this is of any use to you.

Azure quota is exceeded

I'm trying to understand the correct way when hosting a web service using Windows Azure.
After reading some of the documentation available, I have reached these lines:
Windows Azure takes the following actions if a subscription's resource usage quotas are exceeded in a quota interval (24 hours):
Data Out - when this quota is exceeded, Windows Azure stops all web sites for a subscription which are configured to run in Shared mode for the remainder of the current quota interval. Windows Azure will start the web sites at the beginning of the next quota interval.
CPU Time - when this quota is exceeded, Windows Azure stops all web sites for a subscription which are configured to run in Shared mode for the remainder of the current quota interval. Windows Azure will start the web sites at the beginning of the next quota interval.
I was always under the impression that using cloud solution will prevent such events, as I really don't know a head of time what needs my web service will have, and that the cloud will provide the resources as needed (and off-course I will be charged for them) -
is that assumption is wrong?
EDIT
I found this great post that really explains Azure perfectly
Scott Hanselman - my own Q&A about Azure Websites and Pricing
If you are hosting the Windows Azure Website in the Shared mode, although you are paying, there are certain quotas that are in place because in the background you are basically sharing the resources with other websites which are hosted on the same Virtual Machine.
If you are hosting using the Standard mode, then you no longer have quotas and you will not experience this issue. As an added bonus, you can now setup Autoscale to automatically scale out your website under load.
Azure provides you different scalability levels according to the method of hosting you pick. For example if you host your web service on an azure web site you can't scale to thousands of servers. If you host your web services in a cloud service you can scale much further.
In Azure the scalability does not always happen transparently. In the case of a web service your choices are "azure web sites", "azure mobile services" and "azure cloud services". None of these will provide transparent scalability. You will need to define how you want scalability to be processed by azure. Most of the time you can do it in your azure management portal and define "Auto-Scaling" based on your pre-defined metrics as in "total amount of memory used" or "compute power used". Azure helps you gather metrics from a distributed environment, define scaling rules and scale without worrying about the underlying infrastructure but you will need to glue these pieces together as it defines how much you will get billed as well.
Hope this makes sense.

Resources