Published on

Getting Started with Azure Functions for Beginners

Authors

What Are Azure Functions?

Azure Functions are Microsoft's serverless compute offering that let you run code in the cloud without provisioning or managing infrastructure.

Just like AWS Lambda or Google Cloud Functions, Azure Functions are ideal for building small, event-driven services that scale automatically and only charge you when code is running.


✨ Key Features

  • Serverless: No need to manage servers or VMs.
  • Event-driven: Trigger functions via HTTP requests, queues, timers, blob uploads, and more.
  • Auto-scaling: Grows with your traffic without manual intervention.
  • Multiple languages supported: C#, JavaScript, Python, PowerShell, Java, and more.
  • Flexible hosting: Run functions on a consumption plan, premium plan, or within an app service plan.

🚀 Setting Up Your First Azure Function (with Node.js)

Here’s how to create a simple HTTP-triggered function using Node.js.

🧰 Prerequisites


✅ Step 1: Install Azure Functions Core Tools

npm install -g azure-functions-core-tools@4 --unsafe-perm true

✅ Step 2:Create a New Azure Function Project

func init my-first-function --javascript
cd my-first-function
func new

You’ll be prompted to choose a trigger:

  • Select HTTP trigger
  • Enter a name like helloHttp
  • Choose authorization level: Anonymous

This creates a folder structure with a basic function.

✅ Step 3: Run the Function Locally

To test it on your machine:

func start

You’ll get a local URL like:

http://localhost:7071/api/helloHttp?name=Azure

Open it in your browser or use curl:

curl "http://localhost:7071/api/helloHttp?name=Azure"

Expected output:

{
  "message": "Hello, Azure"
}

✅ Step 4: Log in to Azure

Authenticate your CLI:

az login

This opens a browser window to log in to your Azure account.

✅ Step 5: Create a Resource Group and Storage Account

Run the following to create a resource group:

az group create --name MyResourceGroup --location eastus

Then, create a unique storage account:

az storage account create \
  --name mystorageacct123 \
  --location eastus \
  --resource-group MyResourceGroup \
  --sku Standard_LRS

Note: mystorageacct123 must be globally unique.

✅ Step 6: Create a Function App in Azure

Now create the Azure Function App:

az functionapp create \
  --resource-group MyResourceGroup \
  --consumption-plan-location eastus \
  --runtime node \
  --functions-version 4 \
  --name myfirstazfunc \
  --storage-account mystorageacct123

Replace myfirstazfunc with your own unique name.

✅ Step 7: Deploy the Function to Azure

To publish your function:

func azure functionapp publish myfirstazfunc

You’ll get a live URL like:

https://myfirstazfunc.azurewebsites.net/api/helloHttp

Test it:

curl "https://myfirstazfunc.azurewebsites.net/api/helloHttp?name=Azure"

Expected output:

{
  "message": "Hello, Azure"
}

✅ Summary

In this post, you:

  • Installed Azure Functions Core Tools

  • Created a serverless project with an HTTP endpoint

  • Ran and tested it locally

  • Logged into Azure and set up infrastructure

  • Deployed your function to the cloud


🧠 When to Use Azure Functions

Use Azure Functions when you need:

  • Event-driven logic (HTTP, timers, queues)

  • Lightweight microservices

  • On-demand or scheduled execution

  • Backend logic without managing servers


🏁 Final Thoughts

Azure Functions make it easy to go serverless with minimal setup. They're great for rapid prototyping, automation, and scalable cloud-native APIs.