Skip to content

Latest commit

 

History

History

function-sample-azure-web

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Spring Azure Web Adapter Demo

This sample implements a standard Spring Boot Web application, with a REST API for managing a list of country entities. Later are persisted with JPA and H2 database.

The spring-cloud-function-adapter-azure-web adapter provides a light-weight Azure Function forwarding proxy which allows deploying the existing Spring Boot Web application as a Azure Function.

Usage

Build

./mvnw clean install

Run Locally

./mvnw azure-functions:run

Then use curl to interact with the rest application:

curl -X GET http://localhost:7072/api/AzureWebAdapter/

will output result like Country Count: 0.

Then add few Countries:

curl -X POST -H 'Content-Type:application/json' http://localhost:7072/api/AzureWebAdapter/countries -d '{"name" : "Bulgaria"}'
curl -X POST -H 'Content-Type:application/json' http://localhost:7072/api/AzureWebAdapter/countries -d '{"name" : "Netherlands"}'
curl -X POST -H 'Content-Type:application/json' http://localhost:7072/api/AzureWebAdapter/countries -d '{"name" : "Ukraine"}'

And check the count again:

curl -X GET http://localhost:7072/api/AzureWebAdapter/

now the output is Country Count: 3 and curl -X GET http://localhost:7072/api/AzureWebAdapter/countries will output: Countries: Country{id=1, name='Bulgaria'}Country{id=2, name='Netherlands'}Country{id=3, name='Ukraine'}.

Running on Azure

Make sure you are logged in your Azure account.

az login

and deploy

./mvnw azure-functions:deploy