Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Este guia fornece uma vista geral introdutória de como outros Google Cloud serviços
estão envolvidos no processo de implementação das funções do Cloud Run.
Quando implementa o código-fonte da sua função nas funções do Cloud Run,
esse código-fonte é armazenado num contentor do Cloud Storage. Em seguida, o Cloud Build compila automaticamente o seu código numa imagem de contentor e envia essa imagem para um registo de imagens do Artifact Registry.
As funções do Cloud Run acedem a esta imagem quando precisam de executar o contentor para executar a sua função.
No diagrama seguinte, a caixa de funções do Cloud Run representa
uma função implementada no Cloud Run, através da
API Cloud Run Admin ou da API Cloud Functions. Normalmente, as funções mais recentes são implementadas através da Cloud Run Admin API e as funções mais antigas são implementadas através da Cloud Functions API.
Figura 1. Um utilizador prepara o código-fonte das funções e
implementa-o no Cloud Run.
Consoante a API usada quando implementa uma função, ocorre o seguinte:
Se implementou a sua função através da API Cloud Run Admin, ocorre o seguinte:
O seu código fonte é carregado para um contentor do Cloud Storage que não tem um período de retenção.
Se estiver a usar a encriptação predefinida, o nome do contentor é gerado automaticamente e tem o nome run-sources-PROJECT_ID-REGION.
O código fonte é enviado para o Cloud Build, onde os buildpacks do Google Cloud e o Functions Framework criam uma imagem de contentor. Tenha em atenção que a conta de serviço do Cloud Build cria a imagem do contentor. Por predefinição, o Cloud Run usa o
e2-standard-2 tipo de máquina
fornecido pelo Cloud Build.
A imagem do contentor é, em seguida, carregada para o Artifact Registry através de um contentor criado automaticamente denominado REGION-docker.pkg.dev/PROJECT_ID/cloud-run-source-deploy.
A imagem é implementada no Cloud Run como um serviço.
Pode acionar ou invocar a função com o Eventarc, o Pub/Sub ou outros acionadores HTTP.
Se implementou a sua função através da Cloud Functions API (v2), ocorre o seguinte:
O seu código fonte é carregado para um contentor do Cloud Storage que não tem um período de retenção.
O nome do contentor é gerado automaticamente e segue este formato:
Se estiver a usar a encriptação predefinida, este contentor tem o nome gcf-v2-sources-PROJECT_NUMBER-REGION.
Se estiver a proteger os seus dados com a CMEK, o contentor tem o nome
gcf-sources-PROJECT_NUMBER-REGION-CMEK_KEY_HASH.
O código fonte é enviado para o Cloud Build, onde os buildpacks do Google Cloud e o Functions Framework criam uma imagem de contentor. Tenha em atenção que a conta de serviço do Cloud Build cria a imagem do contentor. Por predefinição, o Cloud Run usa o
e2-standard-2 tipo de máquina
fornecido pelo Cloud Build.
A imagem do contentor é, em seguida, carregada para o Artifact Registry através de um contentor criado automaticamente denominado REGION-docker.pkg.dev/PROJECT_ID/gcf-artifacts.
A imagem é implementada no Cloud Run como um serviço.
Pode acionar ou invocar a função com o Eventarc, o Pub/Sub ou outros acionadores HTTP.
Se criou anteriormente funções com a API Cloud Functions, consulte o
guia de comparação de funções do Cloud Run
para saber mais sobre as diferenças entre as duas versões das funções do Cloud Run.
[[["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-08-21 UTC."],[],[],null,["# Cloud Run functions overview\n\nThis guide provides an introductory overview of how other Google Cloud services\nare involved in the Cloud Run functions deployment process.\n\nBefore you begin\n----------------\n\nFamiliarize yourself with Cloud Run functions and source deployment\nconcepts from the\n[Cloud Run deployment options and resource model](/run/docs/resource-model)\nguide.\n\nArchitecture overview\n---------------------\n\nWhen you deploy your function's source code to Cloud Run functions,\nthat source code is stored in a Cloud Storage bucket. Cloud Build then\nautomatically builds your code into a container image and pushes that image to\nan Artifact Registry [image registry](/run/docs/deploy-functions#image-repository).\nCloud Run functions accesses this image when it needs to run the\ncontainer to execute your function.\n\nIn the following diagram, the Cloud Run functions box represents\na function that is deployed in Cloud Run, using either the\nCloud Run Admin API or the Cloud Functions API. Typically, newer functions\nare deployed using the Cloud Run Admin API, and older functions are deployed\nusing the Cloud Functions API.\n**Figure 1.** A user prepares functions source code and deploys it to Cloud Run.\n\nDepending on which API is used when deploying a function, the following occurs:\n\n- If you deployed your function using use the *Cloud Run Admin API*, the\n following occurs:\n\n 1. Your source code is uploaded to a Cloud Storage bucket that has no\n retention period.\n\n 1. If you're using default encryption, the name of the bucket is autogenerated and named `run-sources-`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`-`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e.\n 2. If you're protecting your data with [Customer-managed encryption keys (CMEK)](/kms/docs/cmek), the bucket name is not autogenerated, and you must provide a bucket name.\n 2. The source code is submitted to Cloud Build, where\n Google Cloud's buildpacks and the Functions Framework create a container\n image. Note that the Cloud Build service account builds the container\n image. Cloud Run defaults to using the\n [`e2-standard-2` machine type](/build/pricing)\n provided by Cloud Build.\n\n 3. Your container image is then uploaded to Artifact Registry through an auto-created\n bucket called \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e`-docker.pkg.dev/`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`/cloud-run-source-deploy`.\n\n 4. The image is deployed to Cloud Run as a service.\n\n 5. You can trigger or invoke the function with Eventarc,\n Pub/Sub, or other HTTP triggers.\n\n- If you deployed your function using use the *Cloud Functions API (v2)*, the\n following occurs:\n\n 1. Your source code is uploaded to a Cloud Storage bucket that has no\n retention period.\n\n The name of the bucket is autogenerated and follows this format:\n 1. If you're using default encryption, this bucket is named `gcf-v2-sources-`\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e`-`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e.\n 2. If you're protecting your data with CMEK, the bucket is named `gcf-sources-`\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e`-`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e`-`\u003cvar translate=\"no\"\u003eCMEK_KEY_HASH\u003c/var\u003e.\n 2. The source code is submitted to Cloud Build, where\n Google Cloud's buildpacks and the Functions Framework create a container\n image. Note that the Cloud Build service account builds the container\n image. Cloud Run defaults to using the\n [`e2-standard-2` machine type](/build/pricing)\n provided by Cloud Build.\n\n 3. Your container image is then uploaded to Artifact Registry through an auto-created\n bucket called \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e`-docker.pkg.dev/`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`/gcf-artifacts`.\n\n 4. The image is deployed to Cloud Run as a service.\n\n 5. You can trigger or invoke the function with Eventarc,\n Pub/Sub, or other HTTP triggers.\n\nWhat's next\n-----------\n\n- Learn about the [different types of functions](/run/docs/write-functions) and your options for [triggering functions](/run/docs/function-triggers).\n- If you previously created functions with the Cloud Functions API, see the [Cloud Run functions comparison guide](/run/docs/functions/comparison) to learn about the differences between the two versions of Cloud Run functions."]]