Usar dependencias privadas con Cloud Run Functions
Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
Puedes usar un paquete de un repositorio npm o Python como dependencia de una función de Cloud Run.
Permisos obligatorios
Las funciones de Cloud Run usan la cuenta de servicio de Cloud Build del mismo proyecto Google Cloud para compilar y desplegar tu función.
Si las funciones de Cloud Run y Artifact Registry están en el mismo proyecto, la cuenta de servicio tiene los permisos necesarios para descargar de los repositorios. Google Cloud
Si las funciones de Cloud Run y Artifact Registry están en proyectos diferentes, debes conceder acceso al repositorio a la cuenta de servicio de Cloud Build.
Para proporcionar acceso de solo lectura para descargar dependencias, concede el rol Lector de Artifact Registry.
Si también usas Cloud Build para subir artefactos a repositorios, concede el rol Escritor de Artifact Registry.
Configurar el acceso a las dependencias
Consulta las instrucciones de configuración de npm y Python en la documentación de las funciones de Cloud Run.
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (UTC)."],[[["\u003cp\u003eCloud Run functions can use packages from npm or Python repositories as dependencies.\u003c/p\u003e\n"],["\u003cp\u003eThe Cloud Build service account is used to build and deploy Cloud Run functions, requiring specific permissions.\u003c/p\u003e\n"],["\u003cp\u003eIf Cloud Run functions and Artifact Registry are in the same project, the service account automatically has the necessary download permissions.\u003c/p\u003e\n"],["\u003cp\u003eIf in separate projects, you must grant the Cloud Build service account either the Artifact Registry Reader role for downloading dependencies or the Artifact Registry Writer role for uploading and downloading.\u003c/p\u003e\n"],["\u003cp\u003eDetailed configuration instructions for npm and Python dependencies can be found in the Cloud Run functions documentation.\u003c/p\u003e\n"]]],[],null,["# Using private dependencies with Cloud Run functions\n\nYou can use a package in an npm or Python repository as a dependency for\na Cloud Run function.\n\nRequired permissions\n--------------------\n\nCloud Run functions uses the [Cloud Build service account](/build/docs/cloud-build-service-account) in the\nsame Google Cloud project to build and deploy your function.\n\n- If Cloud Run functions and Artifact Registry are in the same Google Cloud project, the service account has the necessary permissions to download from repositories.\n- If Cloud Run functions and Artifact Registry are in different projects, you must grant repository access to the Cloud Build service account.\n - To provide read-only access for downloading dependencies, [grant](/artifact-registry/docs/access-control#grant) the Artifact Registry Reader role.\n - If you also use Cloud Build to upload artifacts to repositories, [grant](/artifact-registry/docs/access-control#grant) the Artifact Registry Writer role.\n\nConfiguring access to dependencies\n----------------------------------\n\nSee the Cloud Run functions documentation for [npm](/functions/docs/writing/specifying-dependencies-nodejs#using_private_modules) and [Python](/functions/docs/writing/specifying-dependencies-python#using_private_dependencies)\nconfiguration instructions."]]