What are Azure Functions?
Azure Functions is Microsoft’s serverless compute service that lets you run event‑driven code without having to provision or manage infrastructure. Write code in your favorite language, define triggers, and let Azure handle scaling.
Setup & Prerequisites
Before you begin, ensure you have the following:
- Azure subscription (free tier works for starters)
- Visual Studio Code with the Azure Functions extension
- Node.js (v18+), .NET SDK (6.0+), or Python (3.10+)
- Azure CLI installed
Your First Function
Open VS Code, press F1, and select Azure Functions: Create New Project…. Choose a folder, select JavaScript, and pick the HTTP trigger** template.
// index.js
module.exports = async function (context, req) {
context.log('HTTP trigger processed a request.');
const name = (req.query.name || (req.body && req.body.name));
if (name) {
context.res = {
// status: 200, /* Defaults to 200 */
body: `Hello, ${name}!`
};
} else {
context.res = {
status: 400,
body: "Please pass a name on the query string or in the request body"
};
}
};
Triggers & Bindings
Triggers start function execution, while bindings simplify input and output handling. Common triggers:
- HTTP
- Timer (CRON)
- Blob storage
- Queue storage
- Event Grid
Example of a Timer trigger (C#):
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
public static class TimerTrigger
{
[FunctionName("TimerTrigger")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
Deployment Options
You can deploy functions using:
- VS Code Deploy to Function App command
- Azure CLI:
az functionapp deployment source config-zip - GitHub Actions for CI/CD pipelines
- Azure DevOps pipelines
Best Practices
- Prefer Azure Storage bindings over SDK calls for simplicity.
- Keep functions small—single responsibility.
- Use Application Settings for secrets; integrate with Azure Key Vault.
- Monitor with Azure Application Insights.
- Set appropriate function timeout and plan (Consumption vs Premium).