60

We are using GCP's Firebase with Firestore for a new mobile app we are developing. As part of this effort we need to deploy a number of cloud functions which will act as Firestore triggers for doing some back end processing.

Our intention is to keep the deploys encapsulated inside of Firebase by using the firebase cli tools. However when we attempt to initiate the Firebase project for functions using the "firebase init functions" call the only two language options are "Javascript" and "Typescript", and the only deployable stack seems to be Node.js.

On previous GCP projects we had deployed Python based cloud functions (using the gcloud cli) and ideally we'd like to continue using Python for our Firebase cloud functions. So my questions are:

  1. is it possible to deploy Python-based Firebase cloud functions? If not:

  2. can we simply go back to deploying Python-based GCP cloud functions using the gcloud cli and still have them work as Firestore triggers?

Thanks

1 Answer 1

90

EDIT May 5, 2023:

Firebase now supports functions written in python in an early public preview. See: https://firebase.google.com/docs/functions/get-started?gen=2nd#python-preview


The Firebase CLI does not support deploying functions written in python.

You can certainly write Cloud Firestore triggers in python and deploy them with gcloud.

One thing you might not be aware of: the underlying Cloud Functions product is the same no matter how you deploy your functions. Firebase just adds tools and APIs on top of the existing Google Cloud Functions infrastructure. There is really no such thing as a "Firebase Cloud Function". There is just Cloud Functions, and you have options about how you can write and deploy them, either using gcloud, or the Firebase CLI.

5
  • 5
    Thanks Doug - I'm glad to hear that we can continue deploying using Python. And thanks for confirming that the Firebase cli is an additive on top of GCP. We suspected as much but it's great to have it confirmed.
    – Gatmando
    Jul 22, 2019 at 16:02
  • Is there any way to use the flutter helper firebase wrappers with cloud functions deployed in python3? I tried returning json data, but now I get "firebase_functions/internal] Response is missing data field". Apr 8, 2021 at 13:20
  • so I just learned that if I add a "data" key to my response dictionary, it works. So the error message would have been clearer to me if it included quotes around the word 'data'. :-) Apr 8, 2021 at 21:11
  • 3
    Cloud Functions second generation now supports Python!
    – IcyIcicle
    May 10 at 3:24
  • I'm trying to use external python packages by putting them in requirements.txt. Doesn't seem to work. Any solutions? Aug 20 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.