Git Product home page Git Product logo

apisix-manage-serverless-apis's Introduction

Manage serverless APIs with Apache APISIX and Azure Functions

This repo shows with the simple example how to manage Java-based serverless APIs build with Azure functions. It uses azure-functions plugin to integrate APISIX with Azure Serverless Function as a dynamic upstream to proxy all requests for a particular URI to the Microsoft Azure Cloud.

Note that the same plugin can be used with other serverless solutions.

This repo demonstrates followings:

  • Expose serverless APIs as upstream services.
  • Secure serverless APIs with Apache APISIX authentication plugins.
  • Apply rate limiting policies.

Project structure

  • apisix_conf - This folder contains Apache APISIX configuration file.
  • apisix_log - Apache APISIX log files are generated in this folder.
  • cmds - All curl commands examples can be found in this folder.
  • etcd_conf - APISIX etcd storage configuration file.
  • upstream - The folder has Java project with two functions source code: Products and Reviews.

Prerequisites

Setup

To run Apache APISIX and Azure functions locally, you can follow these steps:

  1. Run docker compose up command from the root folder of the project:
docker compose up -d

Above command will run Apache APISIX and etcd together with Docker.

  1. Then, navigate to /upstream folder:
mvn clean install
mvn azure-functions:run

The two functions will start in a terminal window. You can request both serverless APIs in your browser:

For example:

http://localhost:7071/api/products
http://localhost:7071/api/reviews
  1. Next, we deploy functions code to Azure Function App by running below cmd
mvn azure-functions:deploy

Or you can simply follow this tutorial on how to deploy the function project to Azure

Note that the function app name is randomly generated based on your artifactId, appended with a randomly generated number. In the tutorial cmds, the function app name serverless-apis is mentioned.

Just to make sure our function works, we can test an invocation call directly requesting it URL in the browser:

https://serverless-apis.azurewebsites.net/api/products
https://serverless-apis.azurewebsites.net/api/reviews

Clean up Azure resources when you are finished:

az group delete --name java-functions-group

Key concepts

For more details, see the text version of full tutotial https://api7.ai/blog/manage-serverless-apis-with-apache-apisix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.