Spring Boot on GCP
Search…
Introduction
Getting Started
Google Cloud Platform
Cloud Shell
gcloud CLI
Hello World!
Cloud Shell
App Engine
Cloud Run
Kubernetes Engine
Compute Engine
Cloud Functions
Application Development
Development Tools
Spring Cloud GCP
Cloud Services
Observability
DevOps
Deployment
Runtime Environments
Container
Kubernetes
Istio
Additional Resources
Code Labs
Presentations / Videos
Cheat Sheets
Powered By
GitBook
Cloud Functions
Deploy a simple HTTP function.
​
Cloud Function
is a scalable, pay as you go, Functions-as-a-Service (FaaS).
Spring Cloud Functions has pre-GA support for Cloud Functions for Java 11. See
Spring Cloud Functions Reference Documentation
for more details.
This guide currently uses a non-Spring example for Cloud Functions.
Getting Started
Clone
1
cd
$HOME
2
git
clone https://github.com/GoogleCloudPlatform/java-docs-samples
3
cd
java-docs-samples/functions/helloworld/helloworld
Copied!
Build
1
mvn package
Copied!
Run Locally
1
mvn function:run
2
​
3
# In a different tab, trigger the function:
4
curl
localhost:8080
Copied!
Deploy
Enable API
1
gcloud services
enable
cloudfunctions.googleapis.com
Copied!
Deploy
1
gcloud functions deploy helloworld --trigger-http
\
2
--runtime
=
java11
\
3
--entry-point
=
functions.HelloWorld
\
4
--allow-unauthenticated
Copied!
Connect
Once a HTTP function is deployed, you can connect to it using
curl
. You can also find the URL:
1
gcloud functions describe helloworld --format
=
'value(httpsTrigger.url)'
Copied!
Trigger the function with
curl
:
1
URL
=
$(
gcloud functions describe helloworld --format
=
'value(httpsTrigger.url)'
)
2
​
3
curl
${URL}
Copied!
Alternatively, you can also use
gcloud
:
1
gcloud functions call helloworld
Copied!
Additional Configurations
By default, Cloud Functions will deploy to the smallest 256MB instance. You can specify a larger instance and configure environment variables with the
gcloud
CLI:
1
gcloud functions deploy helloworld --trigger-http
\
2
--runtime
=
java11
\
3
--memory
=
512M
4
--entry-point
=
functions.HelloWorld
\
5
--allow-unauthenticated
Copied!
Learn More
​
Cloud Functions Java Runtime documentation
​
​
Framework support
for
Spring Cloud Functions
,
Micronaut
,
Quarkus
​
Previous
Compute Engine
Next - Application Development
Development Tools
Last modified
1yr ago
Copy link
Contents
Getting Started
Clone
Build
Run Locally
Deploy
Connect
Additional Configurations
Learn More