Azure Functions API

To deepen my understanding of how APIs work and to gain hands-on experience , I decided to build my own API using Azure Functions and their serverless architecture. I initially considered doing it with Azure Cosmos, but this took me a few days, and having Azure Cosmos DB running for a few days can be quite expensive. This led me to use Azure Tables instead.

Key Features

  • Retrives all movies in the Azure Table instance
  • Query movies in the Azure Table: This endpoint allows you to query movies in the azure table by either Release Year or Genre
  • Add a movie entry into the Azure Table

The API Endpoints

GetMovies

This endpoint simply returns all the movies in the Azure Table. It uses the HTTP GET Method to do so. Here is the URL:

https://dlvmoviesfunctionapi.azurewebsites.net/api/GetMovies

Here is how you could use it:

curl https://dlvmoviesfunctionapi.azurewebsites.net/api/GetMovies
GetMoviesByYear

This endpoint allows you to query movies that were released in a specific year. For example, lets say you want to find out what movies were released in 2008. This also uses the HTTP GET method. Here is the URL:

https://dlvmoviesfunctionapi.azurewebsites.net/api/GetMoviesByYear?year=<year>

Here is an example:

curlhttps://dlvmoviesfunctionapi.azurewebsites.net/api/GetMoviesByYear?year=2008
GetMoviesByGenre

This endpoint allows youto query movies by a specific genre. For example, you could find movies in the Action genre. This also uses the HTTP GET method. Here is the URL:

https://dlvmoviesfunctionapi.azurewebsites.net/api/GetMoviesByGenre?genre={genre}

Here is an example of how you could use it:

curl https://dlvmoviesfunctionapi.azurewebsites.net/api/GetMoviesByGenre?genre=Action
CreateMovie

This endpoint allows you to create an entry in the Azure Table. It uses the HTTP POST method. Here is the URL:

https://dlvmoviesfunctionapi.azurewebsites.net/api/CreateMovie

Here is an example of how that would work:

curl --location 'https://dlvmoviesfunctionapi.azurewebsites.net/api/CreateMovie' \
--header 'Content-Type: application/json' \
--data '{
"Title": "The LEGO Batman Movie",
"Genre": "Comedy",
"ReleaseYear": "2017",
"posterURL":"https://www.imdb.com/title/tt4116284/mediaviewer/rm2772370432/?ref_=tt_ov_i"
}'

The other endpoints

The rest of these endpoints perform the same exact function as the ones above. The only difference is HOW they do it. These ones utilize Azures Python modules to interact with Azure Tables.

  • GetMoviesByYearWithTableClient
  • GetMoviesByGenreWithAzureTableClient

Leave a Reply

Your email address will not be published. Required fields are marked *