Deploying Cloud Functions

Deployment

Deployments work by uploading an archive containing your function's source code to a Google Cloud Storage bucket. Once the source code has been uploaded, Cloud Build automatically builds your code into a container image and pushes that image to Container Registry. Cloud Functions uses that image to create the container that executes your function.

You can deploy Cloud Functions from your local machine, from your GitHub or Bitbucket source repository (via Cloud Source Repositories), or from the Cloud Functions API directly.

When deploying, Cloud Functions looks for particular files, depending on your runtime. See Writing Cloud Functions for details. Before your function's deployment is finalized, Cloud Functions will send your function a test request to confirm that it deployed successfully.

Basic concepts

As you learn about the different ways to deploy functions, it is helpful to understand some basic terminology. When you deploy a function, it is displayed in the Cloud Console, as shown below. In particular, note the Name and Executed Function fields:

  • The Name field is the registered name you assign to your function.
  • The Executed Function field is the name of the actual function in your source code that is executed when the deployed function gets called.

These two fields can have the same name, or the names can be different. Notice below that the first two functions have registered names that are different from the executed function names. The last function uses the same name for both fields: helloHttp.

Screenshot that shows function deployment process

Building and Testing Locally

Cloud Functions execute in runtime environments based on open source languages and frameworks so you can build and test your functions locally using standard runtimes and development tools.

You can also use the Functions Framework to run and debug your functions locally for supported runtimes to make testing and debugging easier.

Next steps