Como usar dependências privadas com funções do Cloud Run
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
É possível usar um pacote em um repositório npm ou Python como uma dependência de uma função do Cloud Run.
Permissões necessárias
O Cloud Run functions usa a conta de serviço do Cloud Build no
mesmo projeto Google Cloud para criar e implantar sua função.
Se o Cloud Run functions e o Artifact Registry estiverem no mesmo projeto Google Cloud, a conta de serviço terá as permissões necessárias para fazer o download de repositórios.
Se o Cloud Run functions e o Artifact Registry estiverem em projetos diferentes,
conceda acesso ao repositório à conta de serviço do Cloud Build.
Para fornecer acesso somente leitura para o download de dependências, conceda o
papel Leitor do Artifact Registry.
Se você também usa o Cloud Build para fazer upload de artefatos para repositórios,
conceda a função de escritor do Artifact Registry.
Como configurar o acesso a dependências
Consulte a documentação do Cloud Run functions para instruções de configuração do npm e do Python.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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."]]