Skip to main content

Search the Dev Center

Search tutorials, templates, examples, and more.

Azure Function with Spring Boot Native and GraalVM

Deploys Spring Boot application packaged with GraalVM using Pulumi on Azure from Java definitions

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set azure-java-function-graal-spring
cd pulumi-examples/azure-java-function-graal-spring

Starting point for building Spring Native application hosted in Azure Function.

Inspired by Julien Dubois and Spring Native - Cloud Function Netty example.

Azure Functions custom handlers are used to run the GraalVM binary.

Prerequisites#

  1. Install Pulumi
  2. Configure Azure credentials
  3. Install Java

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):

    Terminal window
    az login
  3. Set the Azure region location:

    Terminal window
    pulumi config set azure-native:location westus
  4. Deploy the stack:

    Terminal window
    pulumi up
    Previewing changes:
    ...
    Performing changes:
    ...
    Resources:
    + X created
    Duration: ...
  5. Check the deployed website endpoint:

    Terminal window
    pulumi stack output endpoint
    curl "$(pulumi stack output endpoint)"
    https://<identifier>.web.core.windows.net/api/hello
    {"message":"Hello from Spring, Pulumi!"}

Running the app locally#

Run the Spring Boot application and send a request:

Terminal window
gradle bootRun
curl localhost:8080

Cleaning up#

Once you’re finished experimenting, you can destroy your stack and remove it to avoid incurring any additional cost:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.