Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page vous explique comment déployer un service sur Cloud Run à l'aide de Cloud Code pour VS Code.
Déployer un service sur 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 .
Sélectionnez un service préexistant ou créez-en un.
Si vous créez un service, choisissez votre préférence de plate-forme entre Cloud Run (fully managed) (Cloud Run (entièrement géré)) et Knative serving (Knative Serving) sous Deployment Platform (Plate-forme de déploiement). Pour obtenir de l'aide afin de choisir la meilleure option en fonction de vos besoins de développement, consultez le guide Choisir votre plate-forme.
Si vous avez choisi Cloud Run (entièrement géré), choisissez une région dans laquelle effectuer le déploiement. Si vous avez sélectionné Knative Serving, configurez les informations du cluster Kubernetes.
(Facultatif) Pour spécifier des paramètres supplémentaires tels que le compte de service, les variables d'environnement et les connexions SQL, développez la section Paramètres de révision avancés.
Les variables d'environnement suivantes sont automatiquement ajoutées aux conteneurs en cours d'exécution :
Nom
Description
Exemple
PORT
Port sur lequel le serveur HTTP doit écouter.
8080
K_SERVICE
Nom du service Cloud Run en cours d'exécution.
hello-world
K_REVISION
Nom de la révision Cloud Run en cours d'exécution.
hello-world.1
K_CONFIGURATION
Nom de la configuration Cloud Run ayant créé la révision.
hello-world
Sous Environnement de compilation, indiquez si vous souhaitez compiler en local ou à l'aide de Cloud Build.
Spécifiez votre compilateur (Docker ou Buildpack) et ses paramètres.
Après avoir défini vos préférences, cliquez sur Déployer.
Cloud Code pour VS Code crée votre image, la transfère dans le registre et déploie votre service dans Cloud Run. Votre service est désormais actif !
Affichez votre service en cours d'exécution en suivant l'URL affichée dans la vue Web.
Vous pouvez également afficher les détails de votre service en cours d'exécution en cliquant sur le bouton Afficher les journaux détaillés et en parcourant vos journaux détaillés dans la fenêtre de sortie.
Une fois la session terminée, effectuez un clic droit pour utiliser les commandes suivantes :
Afficher les journaux : ouvrez les journaux d'application d'un déploiement spécifique avec l'explorateur de journaux Cloud Code.
Ouvrir une URL : ouvrez l'URL du service d'application d'un service spécifique dans un navigateur Web.
Si vous avez désactivé le mode de surveillance dans votre configuration de lancement et que vous souhaitez modifier votre application, puis la recompiler et la redéployer, cliquez sur la barre d'état Cloud Code, puis sur Activer le mode de surveillance.
Obtenir de l'aide
Pour envoyer vos commentaires, signalez tout problème sur GitHub ou posez une question sur Stack Overflow.
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/05 (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/05 (UTC)."],[[["\u003cp\u003eThis guide details how to deploy a service to Cloud Run using Cloud Code for VS Code directly from the command palette.\u003c/p\u003e\n"],["\u003cp\u003eYou can choose between deploying to Cloud Run (fully managed) or Knative serving, each with their own configuration steps, such as selecting a region or configuring Kubernetes cluster details.\u003c/p\u003e\n"],["\u003cp\u003eDuring deployment, Cloud Code builds your image, pushes it to the registry, and makes your service live on Cloud Run, with options to use local or Cloud Build.\u003c/p\u003e\n"],["\u003cp\u003ePost-deployment, you can access your service's URL in the webview, view logs, and manage your application, including turning on or off watch mode for changes.\u003c/p\u003e\n"],["\u003cp\u003eThe running container will have access to the environment variables such as, the service's port, name, revision and configuration, to help maintain the application.\u003c/p\u003e\n"]]],[],null,["# Deploy a service in Cloud Code for VS Code\n\nThis page shows you how to deploy a service to Cloud Run using\nCloud Code for VS Code.\n\nDeploying a service to Cloud Run\n--------------------------------\n\nTo deploy your service to Cloud Run:\n\n1. Open the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e\n **Command Palette** ) and then run the\n **Deploy to Cloud Run** command.\n\n2. In the **Deploy to Cloud Run** pane, set your Google Cloud project.\n\n3. Select a preexisting service or create a new one.\n\n4. If you're creating a new service, choose your platform preferences\n under **Deployment Platform** , either\n **Cloud Run (fully managed)** or\n **Knative serving** . For help choosing the best option for\n your development needs, see the\n [Choosing your platform guide](/run/docs/choosing-a-platform).\n\n5. If you selected **Cloud Run (fully managed)** , choose\n a region to deploy to. If you selected **Knative serving**,\n configure the Kubernetes cluster information.\n\n | **Note:** Cloud Code can only deploy to Knative serving if Knative serving is enabled as a feature on the GKE cluster. It is not compatible with the newer version of Knative serving which is installed as an Anthos fleet component with Cloud Service Mesh. The free trial period for Knative serving ended on September 30, 2021. See the [GA version documentation](/anthos/run/docs/install) for details about installing Cloud Run for Anthos as an Anthos fleet component with Anthos Service Mesh. The [past version has been archived](/anthos/run/archive/docs) but the documentation remains available for existing users.\n6. (Optional) To specify additional settings like service account, environment\n variables, and SQL connections, expand the **Advanced revision settings**\n section.\n\n The following environment variables are automatically added to the running\n containers:\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n7. Under Build environment, specify whether to build locally or using\n Cloud Build.\n\n8. Specify your builder (Docker or Buildpack) and its settings.\n\n9. After you define your preferred settings, click **Deploy**.\n\n Cloud Code for VS Code builds your image, pushes it to the registry, and\n deploys your service to Cloud Run. Your service is now live!\n10. View your running service by following the URL displayed in the **webview**.\n\n You can also view details of your running service by clicking the\n **Show Detailed Logs** button and looking through your verbose logs in the\n output window.\n\n11. After your session completes, right-click to use the following commands:\n\n - **View Logs:** Open the application logs of a specific deployment with the Cloud Code Logs Explorer\n - **Open URL:** Open the application service URL of a specific service in a web browser\n12. If you've turned off watch mode in your launch configuration and you want to\n make changes to your application and rebuild and redeploy the application,\n click the Cloud Code status bar and then click\n **Turn on watch mode**.\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]