如果貴組織使用共用虛擬私有雲,您可以使用無伺服器虛擬私有雲端存取,直接將 Cloud Run 函式連線至共用虛擬私有雲網路。這樣一來,Cloud Run 函式就能存取共用虛擬私有雲網路中的資源,例如 Compute Engine VM 執行個體、Memorystore 執行個體,以及任何其他具有內部 IP 位址的資源。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-05 (世界標準時間)。"],[[["\u003cp\u003eCloud Run functions can connect directly to a Shared VPC network using Serverless VPC Access, allowing access to resources with internal IP addresses.\u003c/p\u003e\n"],["\u003cp\u003eServerless VPC Access connectors can be configured either in individual service projects or in the host project, each with distinct advantages.\u003c/p\u003e\n"],["\u003cp\u003eConfiguring connectors in service projects offers benefits such as isolation, chargebacks, security, and team independence in managing the connections.\u003c/p\u003e\n"],["\u003cp\u003eConfiguring connectors in the host project centralizes network management, preserves IP address space, reduces maintenance overhead, and may lower costs associated with connector idle time.\u003c/p\u003e\n"]]],[],null,["# Connect to a Shared VPC network\n===============================\n\nIf your organization uses [Shared VPC](/vpc/docs/shared-vpc), you can\nconnect Cloud Run functions directly to your Shared VPC network by using\n[Serverless VPC Access](/vpc/docs/serverless-vpc-access). This allows\nCloud Run functions to access resources in your Shared VPC network,\nsuch as Compute Engine VM instances, Memorystore instances, and any\nother resources with an internal IP address.\n\nIf your organization does not use Shared VPC, see\n[Connect to a VPC network](/functions/1stgendocs/networking/connecting-vpc).\n\nComparison of configuration methods\n-----------------------------------\n\nFor Shared VPC, Serverless VPC Access connectors can be\nconfigured in two different ways. You can either set up connectors in each\nservice project that has Cloud Run functions resources that need access\nto your network, or you can set up shared connectors in the host project. There\nare advantages to each method. \n\n### Service projects\n\nAdvantages of creating connectors in the service projects:\n\n- **Isolation:** Each connector has dedicated bandwidth and is unaffected by bandwidth use of connectors in other service projects. This is good if you have a service that experiences spikes in traffic, or if you need to ensure that each service project is unaffected by connector use of other service projects.\n- **Chargebacks:** Charges incurred by connectors are associated with the service project containing the connector. This enables easier chargebacks.\n- **Security:** Allows you to follow the \"principle of least privilege.\" Connectors must be granted access to the resources in your Shared VPC network that they need to reach. By creating a connector in the service project, you can limit what the services in the project can access by using firewall rules.\n- **Team independence:** Reduces dependency on the host project administrator. Teams can create and manage the connectors associated with their service project. A user with the Compute Engine [Security Admin](/compute/docs/access/iam#compute.securityAdmin) role or a custom [Identity and Access Management (IAM)](/iam) role with the [`compute.firewalls.create`](/compute/docs/reference/rest/v1/firewalls/insert#iam-permissions) permission enabled for the host project must still manage firewall rules for the connector.\n\nTo set up connectors in service projects, see\n[Configure connectors in service projects](/functions/1stgendocs/networking/shared-vpc-service-projects).\n\n### Host project\n\nAdvantages of creating connectors in the host project:\n\n- **Centralized network management:** Aligns with the Shared VPC model of centralizing network configuration resources in the host project.\n- **IP address space:** Preserves more of your IP address space. Connectors require an IP address for each instance, so having fewer connectors (and fewer instances in each connector) uses fewer IP addresses. This is good if you are concerned about running out of IP addresses.\n- **Maintenance:** Reduces maintenance, because each connector you create may be used by multiple service projects. This is good if you are concerned about maintenance overhead.\n- **Cost for idle time:** Can reduce the amount of connector idle time and associated cost. Connectors incur costs even when they are not serving traffic (see [pricing](/vpc/pricing#serverless-vpc-pricing)). Having fewer connectors may reduce the amount of resource you pay for when not serving traffic, depending on your connector type and number of instances. This is often cost effective if your use case involves a large number of services, and the services are used infrequently.\n\nTo set up connectors in the host project, see\n[Configure connectors in the host project](/functions/1stgendocs/networking/shared-vpc-host-project)."]]