Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Implantar um app do Cloud Run usando o Cloud Shell
Saiba como configurar e implantar um aplicativo de amostra Hello World no Cloud Run e visualizar o status dos recursos do serviço ativo.
Antes de começar
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Na barra de status do Cloud Code, selecione Novo aplicativo.
Selecione "Aplicativo do Cloud Run" como seu tipo de aplicativo preferido.
Na lista de aplicativos de amostra (Node.js, Python com frameworks Flask e Django, Java, Go), escolha um aplicativo Hello World.
Por exemplo, escolher Python (Flask): Hello World cria um aplicativo Hello World em Python (Flask).
Selecione uma pasta como o local do aplicativo e clique em Criar novo aplicativo.
O editor do Cloud Shell carrega o aplicativo em um novo espaço de trabalho.
Depois que o espaço de trabalho for carregado, o app poderá ser acessado na visualização de explorador.
Implantar no Cloud Run
Para implantar o aplicativo no Cloud Run, siga estas etapas:
Abra a paleta de comandos (pressione Ctrl/Cmd+Shift+P ou clique em Visualizar >
Paleta de comandos) e execute o comando Deploy to Cloud Run. Isso abre a interface do Cloud Run: implantar.
Se necessário, autorize o Cloud Code a fazer chamadas de API do Google Cloud .
Defina o projeto do Google Cloud .
Se solicitado, ative a API Cloud Run clicando em Ativar APIs.
Na caixa de diálogo Implantar para o Cloud Run, selecione um serviço atual ou crie um novo.
Se você estiver criando um novo serviço, selecione "Cloud Run (totalmente gerenciado)" em "Plataforma de implantação".
Escolha uma região para implantar.
Em Autenticação, selecione Permitir invocações não autenticadas para tornar este serviço público.
Depois de definir suas configurações preferidas, clique em Implantar.
Em seguida, o Cloud Code cria sua imagem, envia para o registro e implanta o aplicativo no Cloud Run. Seu serviço está ativo!
Veja o serviço em execução seguindo o URL exibido na
caixa de diálogo "Cloud Run: Implantar".
Editar o serviço
Para editar o aplicativo, siga estas instruções:
Com a visualização do Explorer, encontre o arquivo app.py que implementa o comportamento do serviço.
Modifique a mensagem "está em execução!" para a mensagem que escolher.
Depois de fazer essa alteração, escolha o comando Implantar no Cloud Run
usando a paleta de comandos.
Verifique se o serviço que você acabou de criar está selecionado em "Configurações do serviço".
Clique em Deploy.
Depois que o aplicativo terminar de ser criado e implantado, será possível atualizar o
serviço para ver a mensagem atualizada.
Ver registros
Também é possível ver os registros do aplicativo implantado com o Visualizador de registros fornecido com o Cloud Code.
Para ver os registros, siga estas etapas:
Clique em
Cloud
Code e expanda a seção Cloud Run.
Clique com o botão direito do mouse no serviço do Cloud Run e clique em Ver registros.
Atualize o aplicativo no navegador e veja os novos registros gerados
clicando no botão de atualização de registros.
Limpar
Para evitar cobranças na sua conta do Google Cloud pelos
recursos usados nesta página, siga estas etapas.
Para excluir seu projeto:
Acesse a página "Projetos" no console Google Cloud :
Selecione o projeto que você criou para este guia de início rápido e clique em Excluir.
Isso encerrará o projeto e programará a remoção dele.
Se você estiver usando um projeto preexistente e quiser excluir os recursos criados para este guia de início rápido:
Imagem do contêiner:o Cloud Run não cobra quando um
serviço não está em uso, mas ainda é possível ser
cobrado pelo armazenamento da imagem do contêiner no Artifact Registry.
Para excluir a imagem, abra a página do Artifact Registry, selecione o
repositório que contém a imagem, selecione a imagem, clique em Excluir
e clique em Excluir.
Serviço do Cloud Run:para excluir um serviço do Cloud Run, na página do Cloud Run no consoleGoogle Cloud , selecione o serviço que você quer excluir, clique em Excluir e, em seguida, clique em Excluir.
[[["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."],[],[],null,["# Quickstart: Deploy a Cloud Run service by using Cloud Shell\n\nDeploy a Cloud Run app by using Cloud Shell\n===========================================\n\nLearn how to set up and deploy a sample Hello World application to\nCloud Run and view the status of your live service's resources.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\nCreate an application\n---------------------\n\n1. [Launch the Cloud Shell Editor](https://ide.cloud.google.com).\n2. From the Cloud Code status bar, select **New Application**.\n3. Choose **Cloud Run application** as your preferred application type.\n4. From the list of sample applications (Node.js, Python with Flask and Django\n frameworks, Java, Go), choose a Hello World app.\n\n For example, choosing `Python (Flask): Hello World` creates a starter\n Python (Flask) Hello World app.\n5. Select a folder as your application location and then click\n **Create New Application**.\n\n Cloud Shell Editor loads the application in a new workspace.\n After the workspace loads, your app is accessible in the explorer view.\n\nDeploy to Cloud Run\n-------------------\n\nTo deploy your application to Cloud Run, follow these steps:\n\n1. Open the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run the **Deploy to Cloud Run** command. This brings up the Cloud Run Deploy UI.\n2. If prompted, authorize Cloud Code to make Google Cloud API calls.\n3. Set your Google Cloud project.\n4. If prompted, enable the Cloud Run API by clicking **Enable APIs**.\n5. In the Deploy to Cloud Run dialog, select a pre-existing service or create a new one.\n6. If you're creating a new service, choose **Cloud Run (fully managed)** under Deployment Platform.\n7. Choose a region to deploy to.\n8. For Authentication, select **Allow unauthenticated invocations** to make this a public service.\n9. After you define your preferred settings, you can click **Deploy**.\n\n Cloud Code builds your image, pushes it to the registry, and\n deploys your app to Cloud Run. Your service is now live!\n10. View your running service by following the URL displayed in\n your Cloud Run: Deploy dialog.\n\nEdit your service\n-----------------\n\nTo edit your application, follow these steps:\n\n1. With the Explorer view, find the `app.py` file that implements the service behavior.\n2. Change the message \"It's running!\" to a message of your choosing.\n3. After you make this change, choose the **Deploy to Cloud Run** command using the Command Palette.\n4. Check that the service you just created is selected in Service Settings.\n5. Click **Deploy**.\n6. After your application finishes building and deploying, you can refresh your service to see your updated message.\n\nView logs\n---------\n\nYou can also view logs from your deployed application with the Log Viewer\nthat comes with Cloud Code.\n\nTo view logs, follow these steps:\n\n1. Click **Cloud\n Code** and then expand the **Cloud Run** section.\n2. Right-click your Cloud Run service and then click **View logs**.\n\n3. Refresh your app in the browser, and see the new logs generated by\n clicking the Logs refresh button.\n\nClean up\n--------\n\n\nTo avoid incurring charges to your Google Cloud account for\nthe resources used on this page, follow these steps.\n\nTo delete your project:\n\n1. Go to the Projects page in the Google Cloud console:\n\n [Go to the Projects page](https://console.cloud.google.com/project)\n2. Select the project you created for this quickstart and then click\n **Delete**.\n\n This shuts down the project and schedules it for deletion.\n\nIf you're using a pre-existing project and would like to delete resources\nyou created for this quickstart:\n\n- **Container image:** While Cloud Run doesn't charge when a\n service isn't in use, you might still be\n [charged for storing the container image in Artifact Registry](/artifact-registry/pricing).\n To delete your image, open the Artifact Registry page, select the\n repository that contains your image, select your image, click **Delete** ,\n and then click **Delete**.\n\n [Open the Artifact Registry page](https://console.cloud.google.com/artifacts)\n- **Cloud Run service:** To delete a Cloud Run\n service, from the Cloud Run page in the\n Google Cloud console, select the service you'd like to delete, click\n **Delete** , and then click **Delete**.\n\n [Open the Cloud Run page](https://console.cloud.google.com/run)\n\nWhat's next\n-----------\n\n- Discover the variety of features that the [Cloud Shell Editor interface](/shell/docs/editor-overview) has to offer.\n- Learn how to [configure Cloud Shell](/shell/docs/configuring-cloud-shell) to customize your experience."]]