با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Cloud Functions به توسعه دهندگان امکان دسترسی به رویدادهای Firebase و Google Cloud را به همراه قدرت محاسباتی مقیاس پذیر برای اجرای کد در پاسخ به آن رویدادها می دهد. در حالی که انتظار میرود برنامههای Firebase از توابع Cloud به روشهای منحصربهفردی برای برآوردن نیازهای منحصربهفرد خود استفاده کنند، موارد استفاده معمولی ممکن است در این زمینهها قرار بگیرند:
موارد استفاده و مثالها را برای هر دستهای که مورد علاقهتان است مرور کنید، و سپس به آموزش شروع ما یا راهنمای نحوه خاص رویدادهای احراز هویت ، رویدادهای تحلیلی و موارد دیگر بروید.
هنگامی که اتفاق جالبی می افتد به کاربران اطلاع دهید
توسعهدهندگان میتوانند Cloud Functions استفاده کنند تا کاربران را درگیر و بهروز نگه دارند تا اطلاعات مربوط به یک برنامه را بهروز کنند. به عنوان مثال، اپلیکیشنی را در نظر بگیرید که به کاربران امکان می دهد فعالیت های یکدیگر را در برنامه دنبال کنند. هر بار که کاربر خود را به عنوان دنبال کننده کاربر دیگری اضافه می کند، یک نوشتن در Realtime Database رخ می دهد. سپس این رویداد نوشتن میتواند عملکردی را برای ایجاد اعلانهای Firebase Cloud Messaging (FCM) راهاندازی کند تا به کاربران مناسب اطلاع دهد که دنبالکنندگان جدیدی به دست آوردهاند.
این تابع در مسیری که فالوورها در آن ذخیره می شوند، نوشتن را در مسیر Realtime Database فعال می کند.
برای کاربرانی که در یک خبرنامه مشترک هستند ایمیل های تایید ارسال کنید.
هنگامی که کاربر ثبت نام خود را کامل کرد، یک ایمیل خوش آمدگویی ارسال کنید.
هنگامی که کاربر یک حساب کاربری جدید ایجاد می کند، یک پیامک تأیید ارسال کنید.
انجام پاکسازی و نگهداری پایگاه داده
با مدیریت رویداد پایگاه داده Cloud Functions ، می توانید Realtime Database یا Cloud Firestore را در پاسخ به رفتار کاربر تغییر دهید و سیستم را در وضعیت دلخواه خود نگه دارید. برای مثال، میتوانید رویدادهای نوشتن را نظارت کنید و قالب (مثلاً تغییر به تمام حروف بزرگ) رشتههای خاص در پیامهای کاربران را تغییر دهید. در اینجا این است که چگونه می تواند کار کند:
کنترل کننده رویداد پایگاه داده تابع به رویدادهای نوشتن در یک مسیر خاص گوش می دهد و داده های رویداد حاوی متن یک پیام را بازیابی می کند.
تابع متن را پردازش می کند تا رشته ها را به حروف بزرگ تغییر دهد.
تابع متن به روز شده را به پایگاه داده باز می نویسد.
سایر موارد استفاده از پاکسازی و نگهداری پایگاه داده
محتوای کاربر حذف شده را از Realtime Database پاک کنید.
تعداد گره های فرزند را در پایگاه داده Firebase محدود کنید.
تعداد عناصر موجود در لیست Realtime Database را ردیابی کنید.
داده ها را از Realtime Database در Google Cloud BigQuery کپی کنید.
تبدیل متن به ایموجی
مدیریت ابرداده های محاسبه شده برای سوابق پایگاه داده.
کارهای فشرده را در فضای ابری به جای برنامه خود اجرا کنید
میتوانید به جای اجرای آن بر روی دستگاه کاربر، از Cloud Functions برای بارگذاری روی کار فشرده Google cloud (CPU یا شبکهسازی سنگین) استفاده کنید و پاسخگویی برنامه خود را بهبود بخشید. به عنوان مثال، میتوانید تابعی بنویسید تا به آپلود تصاویر در Cloud Storage گوش دهد، تصویر را در نمونهای که عملکرد را اجرا میکند دانلود کنید، آن را تغییر دهید و دوباره به Cloud Storage آپلود کنید. تغییرات شما می تواند شامل تغییر اندازه، برش یا تبدیل تصاویر با ابزارهایی مانند شارپ یا Pillow باشد.
زمانی که یک فایل تصویری در Cloud Storage آپلود میشود، یک تابع فعال میشود.
این تابع تصویر را دانلود می کند و یک نسخه کوچک از آن ایجاد می کند.
تابع آن مکان تصویر کوچک را در پایگاه داده می نویسد، بنابراین یک برنامه مشتری می تواند آن را پیدا کرده و استفاده کند.
این تابع تصویر کوچک را در مکانی جدید به Cloud Storage بارگذاری میکند.
نمونه های دیگر از کارهای دسته ای در فضای ابری Firebase
حذف دوره ای حساب های Firebase استفاده نشده Node.js | پایتون .
پشتیبان گیری خودکار از تصاویر آپلود شده Node.js | پایتون .
ارسال ایمیل انبوه برای کاربران
داده ها را به صورت دوره ای جمع آوری و خلاصه کنید.
یک صف از کار معلق را پردازش کنید.
با سرویس ها و API های شخص ثالث یکپارچه شوید
Cloud Functions میتواند به برنامه شما کمک کند با تماس و افشای APIهای وب، با سرویسهای دیگر بهتر کار کند. به عنوان مثال، برنامه ای که برای همکاری در توسعه استفاده می شود، می تواند تعهدات GitHub را در یک اتاق گفتگوی گروه کاری ارسال کند.
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی."],[],[],null,["\u003cbr /\u003e\n\nCloud Functions gives developers access to Firebase and Google Cloud\nevents, along with\nscalable computing power to run code in response to those events. While it's\nexpected that Firebase apps will use Cloud Functions in unique ways to meet\ntheir unique requirements, typical use cases might fall into these areas:\n\n- [Notify users when something interesting happens](#notify_users_when_something_interesting_happens).\n- [Perform database sanitization and maintenance](#perform_database_sanitization_and_maintenance).\n- [Execute intensive tasks in the cloud instead of in your app](#execute_intensive_tasks_in_the_cloud_instead_of_in_your_app).\n- [Integrate with third-party services and APIs](#integrate_with_third-party_services_and_apis).\n\nReview the use cases and examples for each category that interests\nyou, and then proceed to our [Get Started](/docs/functions/get-started) tutorial\nor to specific how-to guides\nfor [authentication events](/docs/functions/auth-events),\n[analytics events](/docs/functions/analytics-events), and more.\n\nNotify users when something interesting happens\n\nDevelopers can use Cloud Functions to keep users engaged and up to date\nwith relevant information about an app. Consider, for example, an app that\nallows users to follow one another's activities in the app. Each time a user\nadds themselves as a follower of another user, a write occurs in the\nRealtime Database. Then this write event could trigger a function\nto create Firebase Cloud Messaging (FCM) notifications to let the appropriate\nusers know that they have gained new followers.\n\n1. The function triggers on writes to the Realtime Database path where followers are stored.\n2. The function composes a message to send via .\n3. sends the notification message to the user's device.\n\nTo review working code, see the sample code in GitHub:\n\n- Node.js: [fcm-notifications](https://github.com/firebase/functions-samples/tree/main/Node/fcm-notifications)\n- Python: [fcm-notifications](https://github.com/firebase/functions-samples/tree/main/Python/fcm-notifications)\n\nOther interesting notification use cases\n\n- Send confirmation emails to users subscribing to a newsletter.\n- Send a welcome email when a user completes signup.\n- Send an SMS confirmation when a user creates a new account.\n\nPerform database sanitization and maintenance\n\nWith Cloud Functions database event handling, you can modify Realtime Database or\nCloud Firestore in response to user behavior, keeping the system in your desired\nstate. For example, you could monitor write events and change the format\n(for example, change to all uppercase) of certain strings in users' messages.\nHere's how that could work:\n\n1. The function's database event handler listens for write events on a specific path, and retrieves event data containing the text of a messages.\n2. The function processes the text to change strings to uppercase.\n3. The function writes the updated text back to the database.\n\nTo review working code, see the sample code in GitHub:\n\n- Node.js: [uppercase-rtdb](https://github.com/firebase/functions-samples/tree/main/Node/quickstarts/uppercase-rtdb)\n- Python: [uppercase-rtdb](https://github.com/firebase/functions-samples/tree/main/Python/quickstarts/uppercase-rtdb)\n\nOther database sanitization and maintenance use cases\n\n- Purge a deleted user's content from Realtime Database.\n- Limit the number of child nodes in a Firebase database.\n- Track the number of elements in a Realtime Database list.\n- Copy data from Realtime Database to Google Cloud BigQuery.\n- Convert text to emoji.\n- Manage computed metadata for database records.\n\nExecute intensive tasks in the cloud instead of in your app\n\nYou can take advantage of Cloud Functions to offload to the Google\ncloud resource-intensive work (heavy CPU or networking) instead of running it\non a user's device, improving the responsiveness of your app.\nFor instance, you could write a function\nto listen for image uploads to Cloud Storage, download the image to the instance\nrunning the function, modify it, and upload it back to Cloud Storage. Your\nmodifications could include resizing, cropping, or converting images with tools\nlike [sharp](https://www.npmjs.com/package/sharp) or\n[Pillow](https://pillow.readthedocs.io/en/stable/).\n\n1. A function triggers when an image file is uploaded to Cloud Storage.\n2. The function downloads the image and creates a thumbnail version of it.\n3. The function writes that thumbnail location to the database, so a client app can find and use it.\n4. The function uploads the thumbnail back to Cloud Storage in a new location.\n5. The app downloads the thumbnail link.\n\nFor a walkthrough of an image processing example, see the guide to\n[handling Cloud Storage events](https://firebase.google.com/docs/functions/gcp-storage-events?gen=2nd).\n\nOther examples of batch jobs in the Firebase cloud\n\n- Periodically delete unused Firebase accounts [Node.js](https://github.com/firebase/functions-samples/tree/main/Node/delete-unused-accounts-cron) \\| [Python](https://github.com/firebase/functions-samples/tree/main/Python/delete-unused-accounts-cron).\n- Automatically back up uploaded images [Node.js](https://github.com/firebase/functions-samples/tree/main/Node/taskqueues-backup-images) \\| [Python](https://github.com/firebase/functions-samples/tree/main/Python/taskqueues-backup-images).\n- Send bulk email to users.\n- Aggregate and summarize data periodically.\n- Process a queue of pending work.\n\nIntegrate with third-party services and APIs\n\nCloud Functions can help your app work better with other services by\ncalling and exposing web APIs. For instance, an app used for collaboration on\ndevelopment could post GitHub commits to a workgroup chat room.\n\n1. A user pushes commits to a GitHub repo.\n2. An HTTPS function triggers via the [GitHub webhook API](https://developer.github.com/webhooks/).\n3. The function sends a notification of the commit to a team Slack channel.\n\nOther ways to integrate with third-party services and APIs\n\n- Use Google [Cloud Vision API](https://cloud.google.com/vision/) to analyze and tag uploaded images.\n- Translate messages using Google Translate.\n- Use [custom auth](https://firebase.google.com/docs/auth/where-to-start#custom-auth) to sign in users.\n- Send a request to a webhook on Realtime Database writes.\n- Enable full-text search on Realtime Database elements.\n- Process payments from users.\n- Create auto-responses to phone calls and SMS messages.\n- Create a chatbot using Google Assistant."]]