Deploying from the Google Cloud Functions API

This page gives you an overview of how to deploy a Cloud Function from the Google Cloud Functions API. Similar to the gcloud command-line tool, which uses the Cloud Functions API, you can use the API directly to manage Google Cloud Functions. Sample use cases include deploying large amounts of functions or deploying custom functions on behalf of an end-user.

To create a Cloud Function using the Cloud Functions API, do the following in your application:

  1. Create a sourceUploadUrl.
  2. Upload a zip archive at the signed URL.
  3. Create a Cloud Function.

Create a sourceUploadUrl

First call the API method projects.locations.functions.generateUploadUrl to create an uploadUrl.

This URL is a generated Google Cloud Storage signed URL that should be used for the function source code upload. The uploaded file should be a zip archive that contains your function.

Upload a Zip Archive at the Signed URL

Zip the contents of the Cloud Function source code. Upload the zip file to Cloud Storage via a signed URL.

See Resumable Uploads to learn how to upload a file to a Cloud Storage signed URL.

Create a Cloud Function

Finally, to create a Cloud Function use the projects.locations.functions.create method in a client library, making sure to provide necessary fields such as the name and sourceUploadUrl.


The project gcx uses the Cloud Functions API in Node to programmatically create and call Cloud Functions, either as a CLI or API. This tool not only shows an example of using the Cloud Functions API, but you can use it as a convenient way to automate the deployment of Google Cloud Functions.