Azure Functions - HTTP Trigger Samples

A sample Azure Functions - API project to retrieve and create tourist attractions for Marrakech.

Installation

In order to run this project, please follow the steps below:

  • Use a compatible Node.js version (Node.js 14 or 16)
  • Install the Azure Functions Core Tools
brew tap azure/functions
brew install azure-functions-core-tools@4
# if upgrading on a machine that has 2.x or 3.x installed:
brew link --overwrite azure-functions-core-tools@4
  • Install the dependencies: npm i
  • Run the sample: npm start

Note: more information can be found on the Azure Functions Core Tools documentation.

Running the project

Once you completed the above steps, you can run the projects as follows:

  1. npm start: Runs the sample
  2. Press f5: This starts a debugging session in VS Code. Now you are able to set breakpoints and step through the code once you call the API.

Available APIs for you to test

  • GET http://localhost:7071/api/attractions: returns a list of attractions
  • POST http://localhost:7071/api/attractions: creates a new attraction
  • GET http://localhost:7071/api/attractions/{id}: returns a attraction by id

POST attraction example

The body of the POST example show have the following structure:

{
  "name": "Hotel Spa",
  "description": "The perfect place for us to rewind."
}

Important: the name, description fields are required.