Cloud Run 函式與 Firebase
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Google Cloud Run 函式和 Firebase 適用的 Cloud Functions 共同構成 Google 無伺服器運算解決方案的重要部分,可建立事件導向應用程式。
Google Cloud Platform 開發人員可以透過 Cloud Run 函式做為連結層,監聽及回應事件,在 Google Cloud Platform (GCP) 服務之間編織邏輯。
對 Firebase 開發人員而言,Cloud Functions for Firebase 提供擴充 Firebase 行為的方法,並透過新增伺服器端程式碼整合 Firebase 功能。
這兩個解決方案可讓您在全代管環境中快速可靠地執行函式,在這個環境中您不必擔心管理任何伺服器或佈建任何基礎架構的問題。
Cloud Functions for Firebase
如果您是建構行動應用程式或行動網頁應用程式的開發人員,建議使用 Cloud Functions for Firebase。Firebase 提供一系列完整的全代管行動服務,包括 Analytics、Authentication 和 Realtime Database,可供行動開發人員使用。Cloud Functions 可讓您透過新增伺服器端程式碼來延伸及連接 Firebase 功能的行為,使產品/服務更加完善。
針對處理付款事宜與傳送簡訊等工作,Firebase 開發人員可輕鬆與外部服務整合。此外,開發人員可以加入自訂邏輯,但這些邏輯可能對行動裝置來說過於耗用資源,或需要透過伺服器保護。瞭解應用實例,進一步瞭解典型整合方式。如果開發人員需要功能更完整的後端,Cloud Run 函式可做為 Google Cloud Platform 強大功能的閘道。
Cloud Functions for Firebase 最適合 Firebase 開發人員使用:
- Firebase SDK 可透過程式碼設定函式
- 已與 Firebase 主控台和 Firebase CLI 整合
- 與 Google Cloud Functions 相同的觸發條件,外加 Firebase 即時資料庫、Firebase 驗證和 Firebase Analytics 觸發條件
開發人員可以撰寫函式形式的程式碼,連結及擴充 GCP 服務。Cloud Run 函式可做為連接層,讓您監聽及回應事件,在 GCP 服務之間編織邏輯。開發人員只需幾行程式碼,就能豐富 GCP 服務的使用體驗,建立更高層級的組合,不必佈建或管理伺服器。詳情請參閱 Google Cloud Run functions 說明文件。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-17 (世界標準時間)。
[null,null,["上次更新時間:2025-08-17 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\nGoogle Cloud Run functions and Cloud Functions for Firebase together\ncomprise an important part of Google's serverless compute solution for creating\nevent-driven applications.\n\nFor **Google Cloud Platform developers** , [Cloud Run\nfunctions](https://cloud.google.com/functions/) serve as a connective layer\nallowing you to weave logic between Google Cloud Platform (GCP) services by\nlistening for and responding to events.\n\nFor **Firebase developers** ,\n[Cloud Functions for Firebase](https://firebase.google.com/docs/functions/)\nprovides a way to extend the behavior of Firebase and integrate Firebase\nfeatures through the addition of server-side code.\n\nBoth solutions provide fast and reliable execution of functions in a fully\nmanaged environment where there's no need for you to worry about managing any\nservers or provisioning any infrastructure.\n\nCloud Functions for Firebase\n\nYou should use Cloud Functions for Firebase if you're a developer building a\nmobile app or mobile web app. Firebase gives mobile developers access to a\ncomplete range of fully managed mobile-centric services including analytics,\nauthentication and Realtime Database. Cloud Functions rounds out the offering\nby providing a way to extend and connect the behavior of Firebase features\nthrough the addition of server-side code.\n\nFirebase developers can easily integrate with external services for tasks like\nprocessing payments and sending SMS messages. Also, developers can include\ncustom logic that is either too heavyweight for a mobile device, or\nwhich needs to be secured on a server.\n[Explore use cases](https://firebase.google.com/docs/functions/use-cases)\nto learn more about typical integrations.\nFor developers that need a more full-featured backend, Cloud Run\nfunctions provides a gateway to the powerful capabilities in\n[Google Cloud Platform](https://cloud.google.com/docs/).\n\nCloud Functions for Firebase is optimized for Firebase developers:\n\n- Firebase SDK to configure your functions through code\n- Integrated with Firebase Console and Firebase CLI\n- The same triggers as Google Cloud Functions, plus Firebase Realtime Database, Firebase Authentication, and Firebase Analytics triggers\n\nCloud Run functions for Google Cloud Platform\n\nDevelopers can connect and extend GCP services by writing code in the form of a\nfunction. Cloud Run functions serve as a connective layer allowing you to\nweave logic between GCP services by listening for and responding to events. With\njust a few lines of code, developers can enrich their use of GCP services to\ncreate higher level combinations without needing to provision or manage servers.\nSee the [Google Cloud Run functions\ndocumentation](https://cloud.google.com/functions/docs/) for more information."]]