Eleviant is to Elevate & Scale. Eleviant Tech symbolizes business transformation and reinforces our mission to help clients elevate and scale their business.
Guide on Azure Serverless Computing: Functions
Azure Functions is a serverless computing solution that allows organizations to run code on-demand without managing infrastructure or hosting it on a server. It helps to easily run the small pieces of code or functions in the cloud. Developers can concentrate on writing the function to solve the business problem without worrying about the infrastructure.
Some of the major benefits of serverless computing that need to be considered:
- Serverless coding platform (Function as a Service-FaaS)
- Specifically designed for nano-service and event-based applications
- Price is super cheap as it is a pay-per-use model
- Developers can use their dependencies through NPM or NuGet
- Highly secure as it is integrated into Azure active directory
- Flexible development – Develop in Azure portal or visual studio code or any other IDEs
- Integration with Github, Azure DevOps, etc. for automated deployments
Function app flow
Components of a function app:
To execute the piece of code, we need something called a trigger. A trigger defines when the function should be executed, and the associated data is often provided as input for the function. A function must have exactly one trigger.
Bindings are a way to connect another resource to the function – it can be connected as input bindings, output bindings, or both. Binding data is provided as input for the function to execute code or the processed output sent to an output binding.
Example scenarios on how to implement different functions:
|Trigger||Scenario||Input Binding||Output binding|
|HTTP||Persist the data payload sent over HTTP into Azure SQL database||None||Azure SQL|
|CosmosDB Trigger||Persist the Cosmos document changes into Azure SQL transactional database||None||Azure SQL|
|BlobTrigger||Whenever a new blob is created process the file and move it to an archive location||Blob Storage||Blob Storage|
|Timer||A scheduled job reads data from Azure SQL and sends out a report email||Azure SQL||None|
Here are some of the bindings supported by Azure functions runtime version 2.X
The hosting plan influences the function executions’ performance, reliability, and cost. The following hosting plans are available for Function apps:
- Fully serverless hosting option
- Scales automatically based on the events
- Function execution times out after a configurable time
- Billing based on number of executions, execution time, and memory used
- Premium plans scale dynamically based on the number of events
- Avoid cold starts with perpetually warm instances
- Virtual network connectivity
- Unlimited execution duration, with 60 minutes guaranteed
- Premium instance sizes
- More predictable pricing
Dedicated (App service) plan
- Run Functions at regular App Service plan rates
- Good fit for long running operations
- Good fit for predictive scaling and costs
The best practices to follow when writing function code that helps with the performance and availability of your functions;
- Avoid long-running functions that cause timeout issues
- Write functions to be stateless
- Write defensive functions
- Follow retry patterns
- Avoid a lot of dependencies as it will cause cold start problems
Function app limitations
|Resource||Consumption plan||Premium plan||App service plan|
|Timeout duration (Min)||Default=5, Max=10||Default=30, Max=Unlimited||Default=900, Max=Unlimited|
|Max request size (MB)||100||100||100|
|Azure compute unit per instance||100||210-840||100-840|
|Function apps per plan||100||100||Unlimited|
|Custom domains per app||500||500||500|
Free Grant (per month)
$0.20 per million executions
1 million executions
A trigger-based service, Azure Functions, ensures running a script or piece of code in response to various situations. It can be used to achieve decoupling, high throughput and reusability.
To know more about serverless computing and the services Azure offer, follow our series on the Guide to Azure serverless computing options and also get an in-depth understanding from our cloud experts here!
Disclaimer: All the images used in this series of blogs are sourced from the official Microsoft™ Azure Serverless computing charts and pictography.