| page_type | sample | |
|---|---|---|
| languages |
|
|
| products |
|
|
| description | This is a sample applicaiton to showcase the use of Spring Cloud Function on top of Azure Functions. | |
| urlFragment | hello-spring-function-azure |
This is the user account service for the Math-Dojo platform. It is deployed as a serverless function on Azure.
This is just a "Hello, world", but it uses domain objects so it's easy to extend to do something more complex.
- Java SDK 1.8+ - The project uses maven wrapper.
- Docker - The project requires a working mongoDb installation. By default it will look for a database on localhost:27017.
- Clone the project
- Grab the mongo image from Docker:
docker pull mongo - Start the container on 27017:
docker run -p 27017:27017 --name user-acc-svc-mongo -d mongo:latest- Build the project and run its unit tests for windows
$env:SPRING_DATA_MONGODB_URI = 'mongodb://localhost:27017/test'; .\mvnw -ntp clean package- Build the project and run its unit tests for linux
export SPRING_DATA_MONGODB_URI='mongodb://localhost:27017/test' && ./mvnw -ntp clean packageNote: the src\main\azure\local.settings.json file is not read during unit tests, this why the mongoUri needs to be passed in as a separate environment variable.
Once the application is built, you can run it locally using the Azure Function Maven plug-in:
./mvnw azure-functions:run❗❗❗ IMPORTANT ❗❗❗ - The Azure Functions Worker will take any environment vars in the current shell session into the app. These will take precedence over anything set in src\main\azure\local.settings.json.
And you can test it using a cURL command:
curl --location --request PUT 'http://localhost:7071/api/organisations/unknownOrganisationId/users/knownUserId/permissions' \
--header 'Content-Type: application/json' \
--data-raw '{
"permissions": ["CONSUMER", "CREATOR"]
}'This is done via the Azure Pipelines yaml file in the root