Skip to content

πŸš€ A simple To-Do app built with Azure Functions and MongoDB πŸ“. Perform CRUD operations to manage your tasks with seamless cloud deployment πŸŒπŸ’».❌❌ Due To credit limitation the below URL resources may not be available ❌❌

Notifications You must be signed in to change notification settings

moshclouds/Simple-ToDo-App-With-Azure-Functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Simple Azure Functions Todo App

Image

This repository contains an Azure Functions application that performs CRUD operations for a To-Do list. The app is backed by MongoDB and deployed to Azure.

Table of Contents

  1. Prerequisites
  2. Setup Instructions
  3. How to Run Locally
  4. Postman API Requests
  5. Azure CLI Deployment
  6. Response Samples

Prerequisites

  1. Azure CLI
  2. MongoDB Account
  3. Node.js
  4. Azure Functions Core Tools

Setup Instructions

  1. Clone the repository:

    git clone <repository_url>
    cd <repository_folder>
  2. Install dependencies:

    npm install
  3. Create a .env file in the root directory and add the following variables:

    MONGODB_URI=<your_mongodb_connection_string>
    
  4. Install Azure Functions Core Tools if not already installed:

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

How to Run Locally

  1. Start the Azure Functions app locally:

    func start
  2. This will start the server on http://localhost:7071. You can make requests to the API endpoints as described in the next section.

Azure Functions Used

Below are the API request types and sample URLs:

AZ Function URL Request Type Description
Create Todo https://noob-functions.azurewebsites.net/api/create-todo-function POST Creates a new To-Do entry.
Get Todos https://noob-functions.azurewebsites.net/api/get-todos-function GET Retrieves all To-Do entries.
Get Todo https://noob-functions.azurewebsites.net/api/get-todo-function GET Retrieves Specific To-Do entries.
Update Todo https://noob-functions.azurewebsites.net/api/update-todo-function?id=67b5bc9238c337c4de6f9bfa PUT Updates a specific To-Do entry by ID.
Delete Todo https://noob-functions.azurewebsites.net/api/delete-todo-function?id=67b5bc9238c337c4de6f9bfa DELETE Deletes a specific To-Do entry by ID.

Postman API Requests

1. Create To-Do (POST)

  • URL: http://localhost:7071/api/todo-function
  • Method: POST
  • Body:
    {
      "title": "Learn Azure Functions",
      "description": "Learn how to deploy and use Azure Functions"
    }
  • Response:
    {
      "timestamp": "2025-02-19T00:00:00.000Z",
      "status": "success",
      "message": "To-Do Created",
      "code": 201,
      "todoId": "<generated_todo_id>"
    }

2. Get All To-Dos (GET)

  • URL: http://localhost:7071/api/todo-function
  • Method: GET
  • Response:
    [
      {
        "todoId": "<todo_id>",
        "title": "Learn Azure Functions",
        "description": "Learn how to deploy and use Azure Functions",
        "timestamp": "2025-02-19T00:00:00.000Z"
      }
    ]

3. Update To-Do (PUT)

  • URL: http://localhost:7071/api/todo-function/<todo_id>
  • Method: PUT
  • Body:
    {
      "title": "Learn Azure Functions - Updated",
      "description": "Updated the description"
    }
  • Response:
    {
      "timestamp": "2025-02-19T00:00:00.000Z",
      "status": "success",
      "message": "To-Do Updated",
      "code": 200
    }

4. Delete To-Do (DELETE)

  • URL: http://localhost:7071/api/todo-function/<todo_id>
  • Method: DELETE
  • Response:
    {
      "timestamp": "2025-02-19T00:00:00.000Z",
      "status": "success",
      "message": "To-Do Deleted",
      "code": 200
    }

Azure CLI Deployment

1. Install Azure CLI

Install Azure CLI

2. Login to Azure

az login

3. Create Resource Group

az group create --name <ResourceGroupName> --location <Region>

4. Create Function App

az functionapp create      --resource-group <ResourceGroupName>      --consumption-plan-location <Region>      --runtime node      --runtime-version 14      --functions-version 3      --name <FunctionAppName>      --storage-account <StorageAccountName>

5. Publish the Function App

Navigate to your project folder and deploy the app:

func azure functionapp publish <FunctionAppName>

6. Done!

Your Azure Functions app should now be live. You can access it via the URL:

https://<FunctionAppName>.azurewebsites.net

Response Samples

Sample Success Response:

{
  "timestamp": "2025-02-19T00:00:00.000Z",
  "status": "success",
  "message": "To-Do Created",
  "code": 201,
  "todoId": "<generated_todo_id>"
}

Sample Error Response:

{
  "timestamp": "2025-02-19T00:00:00.000Z",
  "status": "error",
  "message": "To-Do Not Found",
  "code": 404
}

Proofs Of Created Resources

Image

Creating A Simple HTTP Trigger Azure Function From Scratch (Alternative Learning)

1. Install Azure CLI

Install Azure CLI

2. Login to Azure

az login

3. Create Resource Group

az group create --name <ResourceGroupName> --location <Region>

4. Create Function App

az functionapp create  --resource-group <ResourceGroupName> --consumption-plan-location <Region> --runtime node --runtime-version 20 --functions-version 4 --name <FunctionAppName>

5. Create an Azure Functions Project

Run the following command to create a new Azure Functions project:

func init myAzureFunctionApp --worker-runtime node

6. Create a New HTTP-Triggered Function

Generate an HTTP function:

func new --name myHttpFunction --template "HTTP trigger" --authlevel "anonymous"

7. Publish the Function App

Navigate to your project folder and deploy the app:

func azure functionapp publish <FunctionAppName>

About

πŸš€ A simple To-Do app built with Azure Functions and MongoDB πŸ“. Perform CRUD operations to manage your tasks with seamless cloud deployment πŸŒπŸ’».❌❌ Due To credit limitation the below URL resources may not be available ❌❌

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published