blog
Ottorino Bruni  

How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Part 1: Basic Email Setup

Introduction

Recently, I needed a simple way to check whether my personal website was up and running at specific times during the day. I started looking into free uptime monitoring services online, but most of them required creating an account something I wasn’t really interested in doing just for a quick check.

As a long-time fan of cloud-native solutions, I decided to build my own lightweight and cost-effective monitor using one of my favorite tools: Azure Functions.

With just a few lines of C# code, I was able to create a scheduled function that pings a URL and sends me an email alert if something goes wrong. No dashboards, no subscriptions, no third-party signups just a clean, serverless solution tailored to my needs.

If you’re new to Azure Functions and want to learn the basics first, check out my beginner-friendly tutorial here: Getting Started with Azure Functions, C#, and Visual Studio Code

In this article, I’ll walk you through the exact steps I followed to build this uptime checker from scratch.

What Is an Uptime Monitoring Service?

An uptime monitoring service regularly checks if a website, API, or any web-accessible endpoint is available and responding correctly. It’s a simple but essential tool for developers and site owners who want to be alerted when something goes wrong — like downtime, slow responses, or HTTP errors.

In this tutorial, we’ll build our own basic uptime checker using Azure Functions and .NET. This tool will let you:

  • Specify the URL you want to monitor (your website or an API endpoint)
  • Define scheduled times for the checks using a CRON expression
  • Receive an email alert if the site is down or returns an error (like HTTP 500)

No dashboards. No accounts. No noise. Just a clean, focused solution you control.

Example: How to Monitor Website and API Uptime Using Azure Functions and .NET

Disclaimer: This example is purely for educational purposes. There are better ways to write code and applications that can optimize this example. Use this as a starting point for learning, but always strive to follow best practices and improve your implementation.

You can also find the full source code on GitHub: FunctionUptime Project

Prerequisites

Before starting, make sure you have the following installed:

  • .NET SDK: Download and install the .NET SDK if you haven’t already.
  • Visual Studio Code (VSCode): Install Visual Studio Code for a lightweight code editor.
  • C# Extension for VSCode: Install the C# extension for VSCode to enable C# support.
  • Azure Functions Extension: Extension to manage Azure Functions directly from VS Code.
  • Azurite Extension: Extension to manage a local emulator for Azure Storage from VS Code
  • An Azure account: You can create one for free at https://azure.microsoft.com/free
How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Azure Functions Extension

Step 1: Create the Function App

  • Open Visual Studio Code
  • Press F1, then search for Azure Functions: Create New Project
  • Choose a folder for your project

Select the following options:

  • Language: C#
  • Template: Timer Trigger
  • Function Name: CheckWebsiteUptime
  • Namespace: FunctionUptime
  • Schedule: 0 0 */12 * * * (runs every 12 hours — you can change this later for testing)

This will generate a starter function like this:

using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace FunctionUptime;

public class CheckWebsiteUptime
{
    private readonly ILogger _logger;

    public CheckWebsiteUptime(ILoggerFactory loggerFactory)
    {
        _logger = loggerFactory.CreateLogger<CheckWebsiteUptime>();
    }

    [Function("CheckWebsiteUptime")]
    public void Run([TimerTrigger("0 0 */12 * * *")] TimerInfo myTimer)
    {
        _logger.LogInformation("C# Timer trigger function executed at: {executionTime}", DateTime.Now);
        
        if (myTimer.ScheduleStatus is not null)
        {
            _logger.LogInformation("Next timer schedule at: {nextSchedule}", myTimer.ScheduleStatus.Next);
        }
    }
}
How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Azure Functions

Why You Need Azurite

Azure Functions with TimerTrigger require an underlying Storage Account to:

  • Track the last execution
  • Ensure timer schedules persist across executions
  • Prevent duplicate invocations

When running in the cloud, Azure uses your configured storage account.
When running locally, you need either:

  • A real Azure Storage Account (with connection string in local.settings.json)
    OR
  • A local emulator like Azurite, with:
"AzureWebJobsStorage": "UseDevelopmentStorage=true"

Logic App Integration – Trigger via HTTP

What is a Logic App?

Azure Logic Apps is a serverless workflow automation service that helps you connect services and automate tasks — without writing backend code. You can visually design workflows that react to events (like an HTTP request), connect to APIs (like Outlook, Gmail, or Teams), and perform actions like sending an email, writing to a database, or posting to a chat.

In our case, we use Logic Apps to send an email alert when our Azure Function detects that a website or API is not reachable.

Why Use Logic Apps Instead of Sending Email Directly?

You might be wondering: Why not just send the email directly from the Azure Function using SMTP or an email library?

Here’s why:

  • Azure does not allow direct outbound SMTP connections due to spam and IP blacklist issues.
  • Logic Apps is a supported, secure, and cloud-native solution that integrates perfectly with services like Outlook, Office 365, Gmail, and even Teams.
  • No need to manage credentials or SMTP security you just sign in once.

Is Logic Apps Free?

Yes for light usage, Logic Apps can be completely free:

  • On the Consumption Plan, the first 4,000 actions per month are free.
  • In our scenario, we only use:
    • 1 trigger (When an HTTP request is received)
    • 1 action (Send an email)

So unless you monitor hundreds of endpoints, you will stay within the free tier.

More pricing info: Azure Logic Apps Pricing

How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Create Logic App

How to Configure Logic App for Email Alerts

Here’s how to set up a simple Logic App that receives a signal from our Function and sends an email using Logic App Designer:

Step 1: Create a Logic App (Consumption Plan)

  • Go to the Azure Portal
  • Create a new Logic App (Consumption)
  • Name it something like UptimeAlertLogicApp

Step 2: Add the HTTP Trigger

  • Choose “When an HTTP request is received”
How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Http request

Step 3: Add the Send Email Action

How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Add Send Email v2
  • Add the action “Send an email (V2)” (via Outlook/Gmail)
  • Create a connection (log in with your Microsoft account)
  • Fill in:
    • To: your email
    • Subject: Uptime Alert – Website Unreachable
    • Body: The website or API you are monitoring did not respond correctly at the scheduled check.
How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Send Email Parameters

Step 4: Copy the HTTP POST URL

  • After saving the Logic App, copy the generated HTTP endpoint URL
  • This is what your Azure Function will call to trigger the email
How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Logic App Designer

Writing the Azure Function Code

Here’s the full code:

using System.Text;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace FunctionUptime;

public class CheckWebsiteUptime
{
    private readonly ILogger _logger;

    public CheckWebsiteUptime(ILoggerFactory loggerFactory)
    {
        _logger = loggerFactory.CreateLogger<CheckWebsiteUptime>();
    }

    [Function("CheckWebsiteUptime")]
    public async Task RunAsync([TimerTrigger("0 0 */12 * * *")] TimerInfo myTimer)
    {
        var urlToCheck = "YOUR_WEBSITE";
        var logicAppUrl = "Replace with your actual Logic App URL";
        var httpClient = new HttpClient();

        try
        {
            var response = await httpClient.GetAsync(urlToCheck);
            if (!response.IsSuccessStatusCode)
            {
                _logger.LogWarning($"Website is not reachable. Status code: {response.StatusCode}");

                await httpClient.PostAsync(logicAppUrl, null);
            }
            else
            {
                _logger.LogInformation($"Website responded successfully at {DateTime.Now}");
            }
        }
        catch (Exception ex)
        {
            _logger.LogError($"Error checking website: {ex.Message}");

            await httpClient.PostAsync(logicAppUrl, null);
        }
    }
}
How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Source Code

How It Works

  • The function runs every 12 hours ("0 * */12 * * *").
  • It tries to perform an HTTP GET request to the specified URL.
  • If the response is not successful (IsSuccessStatusCode is false), or an error occurs, it calls your Logic App by sending an empty HTTP POST.
  • The Logic App will then send an email alert.
How to Monitor Website and API Uptime Using Azure Functions, Logic Apps and .NET – Uptime Alert

Conclusion

As we’ve seen in this tutorial, building useful tools with Azure is easier than you might think and often free to try.
Using Azure Functions and Logic Apps, we created a simple yet effective uptime monitoring service that can check if a website or API is reachable, and notify us if it isn’t.

With just a few lines of C# code and a Logic App workflow, we now have:

  • A scheduled Azure Function running every minute
  • An HTTP check to verify the health of a given URL
  • An automatic email alert if the site is down

These kinds of small, targeted services can become powerful helpers in your daily workflow — whether for monitoring, automation, or learning cloud technologies hands-on.

Best of all, both Azure Functions and Logic Apps offer generous free tiers, making them perfect for experimenting and building side projects like this one.

Stay tuned for Part 2: Improving the Uptime Monitor with Configuration and Logging!

If you think your friends or network would find this article useful, please consider sharing it with them. Your support is greatly appreciated.

Thanks for reading!

🚀 Discover CodeSwissKnife, your all-in-one, offline toolkit for developers!

Click to explore CodeSwissKnife 👉

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.