firebasegoogle-cloud-platformgoogle-cloud-functionsgoogle-cloud-run

Why would a firebase HTTP function deploy as a Cloud Run url?


I have a new project that I am just starting to build some Express endpoints for. It deployed with a URL in the format of https://app-[random string].run.app/ instead of the expected format of https://us-central1-.cloudfunctions.net/

The project has only Functions, Firestore Database, and Firebase Storage. The initial deployment only had a simple test endpoint (https onRequest function) and an onObjectFinalized function. What would cause a function to deploy with a URL that isn't on the cloudfunctions.net domain?


Solution

  • Cloud Functions gen 2 deployments are internally implemented as Cloud Run deployments, and have been for quite some time now. I suggest reviewing the documentation carefully about this:

    Cloud Functions is Firebase's next-generation Functions-as-a-Service offering. Built on Cloud Run and Eventarc, Cloud Functions (2nd gen) brings enhanced infrastructure and broader event coverage to Cloud Functions, including:

    • Built on Cloud Run: Functions are built with Cloud Build and deployed as Cloud Run services using the default Cloud Run execution environment. This gives you the ability to customize your function as you would a Cloud Run service. Refer to Cloud Run documentation to explore options for configuring your service, such as memory limits, environment variables, and so forth.

    Modern versions of the Firebase CLI using the latest APIs are going to push you to write gen 2 functions by default that deploy to Cloud Run.

    If you look at your function in the Google Cloud console, you will likely also be able to see other URLs that access your HTTP type function (both cloudfunctions.net and run.app). See the documentation about that as well:

    When you create a function with the gcloud functions command or the Cloud Functions v2 API, by default, the function has a cloudfunctions.net HTTP endpoint URL. If you take this function and deploy it on Cloud Run, your function also receives a run.app HTTP endpoint URL. However, functions created in Cloud Run won't have an cloudfunctions.net HTTP endpoint URL. A function's cloudfunctions.net URL and run.app URL behave in exactly the same way. They are interchangeable, and are used to trigger your function.