Files
spring-cloud-function/spring-cloud-function-samples/function-sample-azure/README.adoc
Anthony Lofton 75019ab281 function-sample-azure cleanup
Cleaned up pom to use java.version instead of the compiler.source and
compiler.target
Added version properties for azure-functions-java-library and
azure-functions-maven-plugin
Updated the properties to be the latest recommended from Azure Functions
Used stagingDirectory in maven-resources-plugin
Updated README.adoc to say port 7071 instead of 8080
2019-12-12 13:00:29 -06:00

36 lines
1.4 KiB
Plaintext

You can run this sample locally, just like the other Spring Cloud Function samples:
----
mvn spring-boot:run
----
and `curl -H "Content-Type: application/json" localhost:7071/uppercase -d '{"value": "hello foobar"}'`.
Given that our function takes POJO `Function<Foo, Bar> uppercase()` and it's input is JSON we need to
provide the appropriate content-type (in this case `application/json`).
To run locally on top of Azure Functions, and to deploy to your live Azure environment, you will need the Azure Functions Core Tools installed along with the Azure CLI (see https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven for more details).
Run Azure Function locally:
----
mvn azure-functions:run
----
To deploy the function on your live Azure environment:
----
$ az login
$ mvn azure-functions:deploy
----
On another terminal try this: `curl https://<azure-function-url-from-the-log>/api/uppercase -d '{"value": "hello foobar!"}'`. Please ensure that you use the right URL for the function above. Alternatively you can test the function in the Azure Dashboard UI (click on the function name, go to the right hand side and click "Test" and to the bottom right, "Run").
The input type for the function in the Azure sample is a Foo with a single property called "value". So you need this to test it with something like below:
----
{
"value": "foobar"
}
----