Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Esegui il deployment di un servizio Cloud Run con Cloud Code for VS Code
Questa pagina mostra come iniziare rapidamente a utilizzare Cloud Code.
Configurerai un servizio Hello World eseguito su Cloud Run utilizzando un'applicazione di esempio, eseguirai il deployment del servizio su Cloud Run e visualizzerai lo stato delle risorse del servizio in tempo reale.
Prima di iniziare
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.
Nella barra di stato di Cloud Code, fai clic sul nome del progetto attivo.
Nel menu Selezione rapida visualizzato, seleziona Nuova applicazione.
Scegli Applicazione Cloud Run come tipo di applicazione preferito.
Dall'elenco delle applicazioni di esempio (Node.js, Python con i framework Flask e Django, Java, Go), scegli un servizio Hello World.
Ad esempio, la scelta di Node.js: Hello World crea un servizio Node.js
Hello World iniziale.
Conferma la posizione del servizio sul disco (o modificala, se necessario) e fai clic su
Crea nuova applicazione.
In VS Code si aprirà un'anteprima del file README per il servizio selezionato.
Esegui il deployment in Cloud Run
Per eseguire il deployment del servizio su Cloud Run, segui questi passaggi:
Apri la tavolozza dei comandi (premi Ctrl/Cmd+Shift+P o fai clic su Visualizza >
Tavolozza comandi) e poi esegui il comando Deploy to Cloud Run.
Nel riquadro Esegui il deployment su Cloud Run, imposta il progetto Google Cloud .
Accetta le restanti impostazioni predefinite e fai clic su Esegui il deployment.
Cloud Code crea l'immagine, la invia al registro ed esegue il deployment del tuo servizio su Cloud Run.
Per visualizzare il servizio in esecuzione, apri l'URL visualizzato nella parte superiore della finestra di dialogo Deploy to Cloud Run (Esegui il deployment in Cloud Run).
Visualizzazione dei log
Puoi anche visualizzare i log del servizio di cui hai eseguito il deployment con il visualizzatore log
fornito con Cloud Code.
Per visualizzare i log:
Fai clic su Cloud Code nella barra delle attività di VS Code a sinistra.
Espandi la sezione Cloud Run per visualizzare il tuo
servizio Cloud Run.
Fai clic con il tasto destro del mouse sul servizio Cloud Run, quindi fai clic su
Visualizza log.
Visualizzazione dello stato della risorsa
Puoi visualizzare lo stato dei tuoi servizi Cloud Run utilizzando il browser dei servizi Cloud Run:
Fai clic su Cloud Code nella barra delle attività di VS Code a sinistra.
Espandi la sezione Cloud Run per visualizzare il tuo
servizio Cloud Run.
Fai clic sul servizio Cloud Run di cui vuoi saperne di più.
Le proprietà del servizio vengono visualizzate nella finestra sottostante.
Pulizia
Per eliminare il progetto:
Vai alla pagina Progetti nella console Google Cloud :
Servizio Cloud Run:per eliminare un servizio Cloud Run, vai a Cloud Run nella consoleGoogle Cloud utilizzando il menu di navigazione. Seleziona il servizio
che vuoi eliminare e poi fai clic su Elimina.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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)."]]