Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Deploying functions

Jason Dobry edited this page Dec 23, 2016 · 4 revisions

Table of Contents

Deploying HTTP functions

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

Deploying background functions

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:

Cloud Storage Bucket Trigger

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

Cloud Pub/Sub Topic Trigger

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

Common deployment options

--local-path

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/

--entry-point

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