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
June 16, 2022
Prabhu Perumal Renita Joan
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
- Supports multiple languages – .NET, Core Java, JavaScript (NodeJS), Python, PowerShell & TypeScript
- 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:
Trigger
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
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 |
Supported Bindings:
Here are some of the bindings supported by Azure functions runtime version 2.X
Trigger Type | Trigger | Input | Output |
Blob Storage | Yes | Yes | Yes |
Cosmos DB | Yes | Yes | Yes |
Azure SQL | Yes | Yes | |
Event Grid | Yes | Yes | |
HTTP | Yes | Yes | |
Service Bus | Yes | Yes | |
Timer | Yes | ||
Twilio | Yes |
Hosting plans
The hosting plan influences the function executions’ performance, reliability, and cost. The following hosting plans are available for Function apps:
Consumption plan
- 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 plan
- 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
Best Practices
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 |
Max instances | 200 | 20 | 10-20 |
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 |
Storage | 1GB | 250GB | 500-1000GB |
Custom domains per app | 500 | 500 | 500 |
Pricing
Consumption plan
Meter | Price | Free Grant (per month) |
Execution Time | $0.000016/GB-s | 400000 GB-s |
Total Executions | $0.20 per million executions | 1 million executions |
Premium plan
Meter | Price |
vCPU duration | $0.173 vCPU/hour |
Memory duration | $0.0123 GB/hour |
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.
Get in touch with our Digital consultants to Elevate & Scale your business
Free ConsultationReady to get interesting insights of Eleviant? Subscribe to our Newsletter
SubscribeRelated Posts
Emerging Tech Microsoft SharePoint
Maximizing SharePoint Potential with Azure AI...
Digital Transformation Emerging Tech Modern Web
The Power of Business Intelligence in Manufac...
Cloud Digital Transformation Emerging Tech
5 Key Considerations to Successful Cloud Mode...
Get in touch with our Digital consultants to Elevate & Scale your business
Free ConsultationReady to get interesting insights of Eleviant? Subscribe to our Newsletter
Subscribe