I have an Azure function to call the SpeechToText cognitive server. I need to ensure that no more than 4 instances of the function spin up. Is there any way to set the degree of parallelism?
You could try modifying the app's service plan: https://learn.microsoft.com/en-us/azure/app-service/azure-web-sites-web-hosting-plans-in-depth-overview
Navigate to the function app that you want to update.
In the Menu, look for the App Service Plan section.
Select Change App Service plan to start the process.
Navigate to scale out.
Enable autoscale.
Set the desired instance limits.
Related
When hosting an Azure Function in an App Service Plan, are there any significant differences compared with using an App Service (EDIT: for a restful API) associated with the same App Service Plan? I assume the only difference is that the Function offers additional out of the box triggers. Any differences I'm missing that would lead to preferring one over the other?
I'd also like to confirm that hosting Azure Functions in an App Service Plan can actually limit scalability if scaling is not configured on the App Service Plan. As I understand it, Functions automatically scale as needed when using Consumption or Premium hosting without additional configuration.
When hosting an Azure Function in an App Service Plan, are there any significant differences compared with using an App Service associated with the same App Service Plan? I assume the only difference is that the Function offers additional out of the box triggers. Any differences I'm missing that would lead to preferring one over the other?
Well, an Azure Function is a different beast than an App Service. An Azure function is triggered by an external event or a timer. It then executes the code of the function. When hosted on a consumption plan this execution is allowed to run for 5 or 10 minutes max. When you need a longer execution time you need to run it on an App Service Plan.
An App Service can host any app you've created. Like a website (that runs continuously and doesn't need to be triggered before it starts doing something) or an api for example.
I'd also like to confirm that hosting Azure Functions in an App Service Plan can actually limit scalability if scaling is not configured on the App Service Plan. As I understand it, Functions automatically scale as needed when using Consumption or Premium hosting without additional configuration.
Correct, when hosting Azure Functions in an App Service Plan you are responsible for making sure the app service is scaled to allow the function to perform well under load. Thats why the consumption plan is designed to handle this so the developer can focus on the functionality and does not need to worry about the infrastructure.
So, for integration scenario's azure functions are a very natural fit. For web sites an App Service might be the best solution.
To address your comment:
I should have mentioned that this question was in the context of hosting a restful API and not a UI application. In this scenario, I'm not seeing much difference between a Function and App Service, but please correct me if I'm missing something
A couple of things: For one, there is a certain sweet spot. If traffic is heavy enough a consumption plan based azure function might be more costly than having a dedicated app service plan. That depends of course on a lot of factors (CPU usage, request duration etc.). Also, you won't be able to use things like Asp.Net Core Middleware out of the box.
Finally, I'd argue that if your api is becoming large enough managing a single asp.net core solution may be easier than having to manage a lot of azure functions with small functions or one azure function project with lots and lots of functions, but hey, that's just my opinion (haven't actually dealt with it to be honest)
Some resources to consider:
https://www.taztopia.com/single-post/2019/07/28/azure-function-vs-web-app-aka-serverless-vs-paas
https://dasith.me/2018/01/20/using-azure-functions-httptrigger-as-web-api/
The main difference is in how you pay for it:
Azure Functions Consumption plan you pay per execution
Azure Functions in an App Service (dedicated plan) you pay for the allocated hardware per minute.
You also have control of which VNET your functions run in when you use an app service plan. You may have security requirements that make this important.
You are correct that if you run it in an app service that is not configured to scale, then throughput will be limited by the allocated hardware.
For details see: https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale
If you are having limited and predictable workload then deploy az function in AppService plan with supports VNET integration for private compute otherwise go for Premium plan which will provide autoscaling capability of your compute environment.
I have a web app hosted in app service in Azure with auto scale out rules defined and it works as expected - when the memory usage reaches the threshold. An VM instance is added automatically
The problem is that, we discovered that when a new VM instance is added, a new instance of our web app is also added - we do not want this, as our web app is not designed to be horizontally scaled out. We only want one instance of the app.
On Azure portal when I click on Scale up (App service plan), I can only choose another app service plan, it seems to me there is no way I can do something like when a threshold is reached, automatically scale up to the next level of app service plan but keep the number of VM instance.
I am wondering why there is no such option available in Azure?
Or even our conclusion that when scale out, the number of web app instance also increases is true?
You're right, there's no automatic way to scale up and when you scale out, the number of web app instance also increases.
Yes, there is no out of the box option for this and that could be because there is a chance to have latency issues during the scale up / down operation and Azure might want the consumer to make this decision consciously. Having said that, I use the below approach to achieve the vertical scaling you are looking for.
Step 1: Create an Automation account
Step 2: Create a PowerShell Runbook in the automation account you created in previous step. This script would scale up your app service
plan
Step 3: Create an alert rule using the Azure Monitor for your criteria. say, alert
to be fired when Memory usage % is more that 40% or CPU utilization more than 5%)
Step 4: Create an action group that will invoke a runbook you created in
Step #2
Step 5: Associate this action group to the alert you have created in Step #3.
This will do what you are looking for. when the memory utilization is over 40% the alert is triggered which in turn will call you runbook to scale up your app service plan.
You can refer to my article here for detailed description of how to create an automation account and also for the PowerShell script to scale up an app service plan
I need to create a few Azure Function in the same region and same resourge group in Azure.
On the docs I read:
Function apps in the same region can be assigned to the same Consumption plan
But when I´m creating a new Functio App there´s no option to assign the new function to the same consumption plan that was created before.
As you can see, there´s no option to select an existing plan, even in the same region.
How can I prevent to create a new AppServicePlan(consumption) for each new function that I create?
This is not possible through the Azure portal, so you'll need to use the Azure CLI, powershell or ARM templates if you want the function to use an existing App Plan.
However, this doesn't really matter for this case, since you chose the "Consumption" plan type, no additional costs will be charged by creating a new plan of this type.
You only pay for the execution times of your functions.
Sharing the app service plan between Azure Functions (or other app service types) only makes sense if you are (already) using a dedicated app service plan for some services.
With this type, you basically provision a virtual machine that is hosting your functions. You pay a fixed amount for this (whether your functions are running or not), so to save costs, it would make sense to host multiple app services in the same plan, if the server can handle the load (whether they are Azure Functions or other Azure App Service types).
More info: https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale
EDIT: maybe also good to add, is that you can add multiple functions in the Function app. So you don't need to create a new Azure Function App for each function. You could just group them together in the same Azure Function App
just dont use the portal and thats it. use arm templates, use azure powershell, use az cli, etc.
I am new to Microsoft Azure / Google Cloud and I am currently comparing these two different cloud solution providers, before starting a new project. I am planning to write a web application using either Google Cloud App Engine or Azure App Service.
I want to start with a very basic service instance, which I want to call via HTTPS. To reduce charges it would be nice to only pay for used service minutes resp. that the instance only runs, when needed.
Google Cloud offers dynamic instances, where compute instances are shutdown, when idle and started for incoming requests. Which seems way cheaper for a seldom used prototype and first usage of cloud services.
Instances are resident or dynamic. A dynamic instance starts up and shuts down automatically based on the current needs. [...] When an application is not being used at all, App Engine turns off its associated dynamic instances, but readily reloads them as soon as they are needed.
Unfortunately, I found in the Azure documentation only an Overview of autoscale in Microsoft Azure Virtual Machines, Cloud Services, and Web Apps, which does not cover my question of an automatic instance shutdown in idle state. Also Start/Stop VMs during off-hours solution in Azure Automation does not satisfy my information need, because I am looking only for a compute instance and not a full VM.
Is there an equivalent in the Azure domain, that allows to automatically start up and shut down app service instances, based on the usage resp. incoming requests?
Depending on the functionality of the two cloud service provider, I am deciding which one to use. Has anybody experience with this matter in the Azure domain? Thank you.
You can't do that with Azure App Service alone as of now (24-Feb-2019). But you could combine an Azure function to fire up a App Service instance and then forward all incoming traffic to an app hosted in this App Service via an Azure function proxy, see this description on learn.microsoft.com. I was planning to try this for while now too. In theory it should work... From experience, App Service instances fire up quickly, so the warm up time should be acceptable. Even better, you could keep free or shared App Service plan instance with your app running and forward the Azure function calls to it by default. On increasing load, move the app to a pre-configured plan which supports auto scaling.
Of course you could try to implement the entire app via a set of Azure functions which are fully "dynamic" using your terminology. Depending on the architecture of your application, this might actually be the best choice.
The Autoscale feature of Azure offers you to scale out/scale in based on configurable criterias, take a look here. You are limited by your pricing tier. Maybe this example will help you get an insight.
I am creating a demo where I need to be able to scale up my cloud service deployment from a WebAPI.
I went over the rest API documentation and didn't seem to find what I need.
Is it possible to use Service Management API to scale a cloud service up and down ?
Alternative I will just enable auto scale on a queue and then post messages to the queue to get it to scale up :)
As such there's no such function in Service Management REST API for scaling. Since the number of instances for a particular role is stored in the service configuration file, what you would need to do is read this configuration information using Get Deployment operation, locate the Instances node and change the value of count attribute. Then you would need to call Change Deployment Configuration for new instance count to be effective.