-
Notifications
You must be signed in to change notification settings - Fork 115
Deploying functions
Table of Contents
They Emulator CLI's deploy
commands mirrors that of the Cloud SDK. To deploy an HTTP function to the production Google Cloud Functions service you might do this:
cd /path/to/your/module
gcloud alpha functions deploy helloWorld --trigger-http --stage-bucket=my-stage-bucket
With the Emulator it's even easier:
cd /path/to/your/module
functions deploy helloWorld --trigger-http
While the Emulator can stage your code to a Google Cloud Storage bucket during local deployment, it's unnecessary.
To get the full list of deployment options run:
functions deploy --help
Background functions are categorized by their event trigger type. Run the following to see types of event triggers are available:
functions event-types list
Deploying a background function takes a few extra arguments. Here are some examples:
functions deploy helloWorld --trigger-provider=cloud.storage --trigger-event=object.change --trigger-resource=my-trigger-bucket
A shortcut would be just:
functions deploy helloWorld --trigger-bucket=my-trigger-bucket
functions deploy helloWorld --trigger-provider=cloud.pubsub --trigger-event=topic.publish --trigger-resource=my-trigger-topic
A shortcut would be just:
functions deploy helloWorld --trigger-topic=my-trigger-topic
If your current working directory is not the directory where your code resides, then you can use the --local-path
option to specify the path to the code that should be deployed, for example:
functions deploy helloWorld --trigger-http --local-path=/path/to/helloworld/
If you to name the deployed function something other than the name of the function that's exported in your code, then use the --entry-point
option to specify which exported function the deployment should use. The following examples deploys a function named helloWorld
, and looks in the code for an exported function named otherFunction
:
functions deploy helloWorld --trigger-http --entry-point=otherFunction
Disclaimer: This is not an official Google product.
@google-cloud/functions-emulator is currently in pre-1.0.0 development. Before the 1.0.0 release, backwards compatible changes and bug fixes will bump the patch version number and breaking changes will bump the minor version number.