Private Abhängigkeiten mit Cloud Run-Funktionen verwenden
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Sie können ein Paket in einem npm- oder Python-Repository als Abhängigkeit für eine Cloud Run-Funktion verwenden.
Erforderliche Berechtigungen
Cloud Run-Funktionen verwenden das Cloud Build-Dienstkonto im selben Google Cloud Projekt, um Ihre Funktion zu erstellen und bereitzustellen.
Wenn sich Cloud Run-Funktionen und Artifact Registry im selben Google CloudProjekt befinden, hat das Dienstkonto die erforderlichen Berechtigungen zum Herunterladen aus Repositories.
Wenn sich Cloud Run-Funktionen und Artifact Registry in verschiedenen Projekten befinden, müssen Sie dem Cloud Build-Dienstkonto Repositoryzugriff gewähren.
Wenn Sie Lesezugriff zum Herunterladen von Abhängigkeiten gewähren möchten, gewähren Sie die Rolle „Artifact Registry-Leser“.
Wenn Sie auch Cloud Build verwenden, um Artefakte in Repositories hochzuladen, gewähren Sie die Rolle „Artifact Registry Writer“.
Zugriff auf Abhängigkeiten konfigurieren
In der Cloud Run Functions-Dokumentation finden Sie Konfigurationsanleitungen für npm und Python.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (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."]]