使用 Cloud Run 函数后,您无需再管理服务器、配置软件、更新框架和修补操作系统。软件和基础架构完全由 Google 托管,您只需添加代码即可。
此外,系统会自动预配资源来响应请求或事件。这意味着,Cloud Run 服务会从一天几次调用自动扩容到数百万次调用,而无需您执行任何操作。如果您需要更好地控制扩缩行为,可以视情况使用手动扩缩。
Cloud Run 函数提供了一个逻辑连接层,让您可以编写代码来连接和扩展云端服务。您可以侦听以下事件并做出响应:文件上传到 Cloud Storage、更改日志或 Pub/Sub 主题中收到消息。Cloud Run functions 可增强现有云服务,让您能够通过任意编程逻辑来满足越来越多应用场景的需要。Cloud Run functions 可以访问 Google 服务账号凭据,因此能够无缝地通过大多数 Google Cloud 服务(包括 Cloud Vision)以及其他许多服务的身份验证。此外,许多 Cloud 客户端库都支持 Cloud Run functions,从而进一步简化这些集成。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# When should I deploy a function to Cloud Run?\n\n| **Note:** Cloud Functions has been renamed to Cloud Run functions. For more information, see the [Cloud Run functions blog post](https://cloud.google.com/blog/products/serverless/google-cloud-functions-is-now-cloud-run-functions).\n\nCloud Run removes the work of managing servers, configuring\nsoftware, updating frameworks, and patching operating systems. The software and\ninfrastructure are fully managed by Google so that you just add code.\nFurthermore, provisioning of resources happens automatically in response to\nrequests or events.\nThis means that a Cloud Run service automatically scales out from a few\ninvocations a day to many millions of invocations without any work from you.\nYou can optionally use [manual scaling](/run/docs/configuring/services/manual-scaling)\nif you need more control over your scaling behavior.\n\nWhen you deploy a function, source code or a container image to\nCloud Run, you receive all of the benefits described in the\n[Container runtime contract](/run/docs/container-contract).\n\nUse cases for deploying functions\n---------------------------------\n\nYou can directly deploy a function bound to events in order to implement\nasynchronous workloads (such as lightweight [ETL](/learn/what-is-etl)) or cloud\nautomations (such as triggering application builds).\nIn addition, the automatic provisioning of an HTTPS endpoint makes functions a\nperfect candidate for webhooks.\n\nSee the following table for additional common use cases for deploying a function\nto Cloud Run:\n\nConnect and extend cloud services\n---------------------------------\n\nCloud Run functions provides a connective layer of logic that lets you write\ncode to connect and extend cloud services. Listen and respond to a file upload\nto Cloud Storage, a log change, or an incoming message on a Pub/Sub\ntopic. Cloud Run functions augments existing cloud services and lets you\naddress an increasing number of use cases with arbitrary programming logic.\nCloud Run functions have access to the Google Service Account credential and\nare thus seamlessly authenticated with the majority of Google Cloud services,\nincluding Cloud Vision, as well as many others. In addition,\nCloud Run functions are supported by numerous\n[Cloud Client Libraries](/apis/docs/cloud-client-libraries), which\nfurther simplify these integrations.\n\nWhat's next\n-----------\n\n- Try the [getting started guide for deploying a function](/run/docs/quickstarts/functions/deploy-functions-console).\n- If you have existing functions and need to use the `gcloud functions deploy` command, the Cloud Functions v2 API, or the `google_cloudfunctions2_function` Terraform configuration for backward compatibility, you can [deploy functions with the `gcloud functions` command](/functions/docs/deploy)."]]