
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.
- Prerequisites
- Setup Instructions
- How to Run Locally
- Postman API Requests
- Azure CLI Deployment
- Response Samples
-
Clone the repository:
git clone <repository_url> cd <repository_folder>
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add the following variables:MONGODB_URI=<your_mongodb_connection_string>
-
Install Azure Functions Core Tools if not already installed:
npm install -g azure-functions-core-tools@3 --unsafe-perm true
-
Start the Azure Functions app locally:
func start
-
This will start the server on
http://localhost:7071
. You can make requests to the API endpoints as described in the next section.
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. |
- 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>" }
- 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" } ]
- 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 }
- 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 }
az login
az group create --name <ResourceGroupName> --location <Region>
az functionapp create --resource-group <ResourceGroupName> --consumption-plan-location <Region> --runtime node --runtime-version 14 --functions-version 3 --name <FunctionAppName> --storage-account <StorageAccountName>
Navigate to your project folder and deploy the app:
func azure functionapp publish <FunctionAppName>
Your Azure Functions app should now be live. You can access it via the URL:
https://<FunctionAppName>.azurewebsites.net
{
"timestamp": "2025-02-19T00:00:00.000Z",
"status": "success",
"message": "To-Do Created",
"code": 201,
"todoId": "<generated_todo_id>"
}
{
"timestamp": "2025-02-19T00:00:00.000Z",
"status": "error",
"message": "To-Do Not Found",
"code": 404
}

az login
az group create --name <ResourceGroupName> --location <Region>
az functionapp create --resource-group <ResourceGroupName> --consumption-plan-location <Region> --runtime node --runtime-version 20 --functions-version 4 --name <FunctionAppName>
Run the following command to create a new Azure Functions project:
func init myAzureFunctionApp --worker-runtime node
Generate an HTTP function:
func new --name myHttpFunction --template "HTTP trigger" --authlevel "anonymous"
Navigate to your project folder and deploy the app:
func azure functionapp publish <FunctionAppName>