Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Déployer un service Cloud Run avec Cloud Code pour VS Code
Cette page vous explique comment démarrer rapidement avec Cloud Code.
Vous allez configurer un service Hello World qui s'exécute sur Cloud Run à l'aide d'un exemple d'application, déployer votre service sur Cloud Run et afficher l'état des ressources de votre service actif.
Avant de commencer
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.
Dans la barre d'état Cloud Code, cliquez sur le nom du projet actif.
Dans le menu "Démarrage rapide" qui s'affiche, sélectionnez Nouvelle application.
Sélectionnez Application Cloud Run comme type d'application préféré.
Dans la liste des exemples d'applications (Node.js, Python avec frameworks Flask et Django, Java, Go), choisissez un service Hello World.
Par exemple, si vous choisissez Node.js: Hello World, vous créez un service Hello World Node.js de démarrage.
Confirmez l'emplacement de votre service sur le disque (ou modifiez-le si nécessaire), puis cliquez sur Create New Application (Créer une application).
Un aperçu du fichier README du service sélectionné s'ouvre dans VS Code.
Déployer dans Cloud Run
Pour déployer votre service sur Cloud Run, procédez comme suit :
Ouvrez la palette de commandes (appuyez sur Ctrl/Cmd+Shift+P ou cliquez sur Affichage > Palette de commandes), puis exécutez la commande Deploy to Cloud Run (Déployer sur Cloud Run).
Dans le volet Déployer sur Cloud Run, définissez votre projet Google Cloud .
Acceptez les autres paramètres par défaut, puis cliquez sur Déployer.
Cloud Code crée votre image, la transfère dans le registre et déploie votre service dans Cloud Run.
Pour afficher le service en cours d'exécution, ouvrez l'URL affichée en haut de la boîte de dialogue Déployer sur Cloud Run.
Afficher les journaux
Vous pouvez également afficher les journaux de votre service déployée avec la visionneuse de journaux fournie avec Cloud Code.
Pour afficher les journaux, procédez comme suit :
Cliquez sur Cloud Code dans la barre d'activité VS Code à gauche.
Développez la section Cloud Run pour afficher votre service Cloud Run.
Faites un clic droit sur votre service Cloud Run, puis cliquez sur Afficher les journaux.
Afficher l'état des ressources
Vous pouvez afficher l'état de vos services Cloud Run à l'aide du navigateur de service Cloud Run :
Cliquez sur Cloud Code dans la barre d'activité VS Code à gauche.
Développez la section Cloud Run pour afficher votre service Cloud Run.
Cliquez sur le service Cloud Run à propos duquel vous souhaitez plus d'informations.
Les propriétés du service s'affichent dans la fenêtre ci-dessous.
Nettoyer
Pour supprimer votre projet :
Accédez à la page "Projets" de la console Google Cloud :
Service Cloud Run : pour supprimer un service Cloud Run, accédez à Cloud Run dans la consoleGoogle Cloud à l'aide du menu de navigation. Sélectionnez le service que vous souhaitez supprimer, puis cliquez sur Supprimer.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis guide provides instructions on how to quickly deploy a Hello World service to Cloud Run using Cloud Code for VS Code.\u003c/p\u003e\n"],["\u003cp\u003eYou'll learn how to create a new Cloud Run application from a selection of sample services and then deploy it using the "Deploy to Cloud Run" command.\u003c/p\u003e\n"],["\u003cp\u003eThe guide explains how to use Cloud Code's Log Viewer to view logs from your deployed service, as well as how to view the status of your Cloud Run service using the Cloud Run service browser.\u003c/p\u003e\n"],["\u003cp\u003eInstructions are given on how to clean up resources, whether deleting the entire project or only the container image and Cloud Run service, after the quickstart.\u003c/p\u003e\n"],["\u003cp\u003eFinally, it gives pointers to further resources such as language-specific debugging, relevant settings, and running a Kubernetes application with Cloud Code.\u003c/p\u003e\n"]]],[],null,["# Quickstart: Deploy a Cloud Run service with Cloud Code for VS Code\n\nDeploy a Cloud Run service with Cloud Code for VS Code\n======================================================\n\nThis page shows you how to get started quickly with Cloud Code.\n\nYou'll set up a Hello World service that runs on Cloud Run using a\nsample application, deploy your service to Cloud Run, and view\nthe 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-\n\n\n Enable the Cloud Run API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=run.googleapis.com)\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\n-\n\n\n Enable the Cloud Run API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=run.googleapis.com)\n\n1. Install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). Git is required for copying samples to your machine.\n2. Install the [Cloud Code plugin](/code/docs/vscode/install#installing) if you haven't already.\n\nCreating a service\n------------------\n\n1. In the Cloud Code status bar, click the active project name.\n\n2. In the Quick Pick menu that appears, select **New Application**.\n\n3. Choose **Cloud Run application** as your preferred application type.\n\n4. From the list of sample applications (Node.js, Python with Flask and Django\n frameworks, Java, Go), choose a Hello World service.\n\n For example, choosing `Node.js: Hello World` creates a starter Node.js\n Hello World service.\n5. Confirm your service location on disk (or modify it, if necessary) and click\n **Create New Application**.\n\n A preview of the README file for your selected service will open in VS Code.\n\nDeploy to Cloud Run\n-------------------\n\nTo deploy your service to Cloud Run, follow these steps:\n\n1. Open the Command Palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e\n **Command Palette** ) and then run the **Deploy to Cloud Run** command.\n\n2. In the **Deploy to Cloud Run** pane, set your Google Cloud project.\n\n3. Accept the remaining default settings and then click **Deploy**.\n\n Cloud Code builds your image, pushes it to the registry, and\n deploys your service to Cloud Run.\n4. To view your running service, open the URL displayed at the top of the\n **Deploy to Cloud Run** dialog.\n\nViewing logs\n------------\n\nYou can also view logs from your deployed service with the Log Viewer\nthat comes with Cloud Code.\n\nTo view logs, follow these steps:\n\n1. Click **Cloud Code** in the VS Code Activity bar on the left.\n2. Expand the **Cloud Run** section to view your Cloud Run service.\n3. Right-click your Cloud Run service and then click **View logs**.\n\nViewing resource status\n-----------------------\n\nYou can view the status of your Cloud Run services using the\nCloud Run service browser:\n\n1. Click **Cloud Code** in the VS Code Activity bar on the left.\n2. Expand the **Cloud Run** section to view your Cloud Run service.\n3. Click the Cloud Run service you'd like to know more about. The service's properties are displayed in the window below.\n\nCleaning up\n-----------\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\n3. Type the project ID to confirm and then click **Shut down**.\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 the\n service isn't in use, you might be\n [charged for storing the container image in Artifact Registry](/artifact-registry/pricing).\n For steps to delete your image, see\n [Deleting images](/artifact-registry/docs/docker/manage-images#deleting_images).\n\n- **Cloud Run service:** To delete a Cloud Run\n service, navigate to Cloud Run in the\n Google Cloud console using the navigation menu. Select the service\n you want to delete and then click **Delete**.\n\nWhat's next\n-----------\n\n- Discover the language-specific [debugging support](/code/docs/vscode/debug) that Cloud Code provides.\n- Customize your Cloud Code experience by configuring [relevant settings](/code/docs/vscode/configuring-settings).\n- Try creating and [running a Kubernetes application with Cloud Code](/code/docs/vscode/quickstart-local-dev)."]]