Se stai creando una nuova funzione, consulta la guida rapida della console su Cloud Run. I contenuti di questa pagina si applicano solo alle funzioni legacy esistenti create con l'API Cloud Functions v1.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Runtime Ruby
Panoramica
La funzione Cloud Run viene eseguita in un ambiente costituito da una versione del sistema operativo, oltre a pacchetti aggiuntivi, supporto per le lingue e la libreria Functions Framework che supporta e richiama la funzione.
Questo ambiente è identificato dalla versione della lingua ed è noto come ambiente di runtime.
Cloud Run supporta diverse versioni di Ruby, elencate nella pagina Supporto del runtime. Puoi selezionare il runtime Ruby preferito per la tua funzione durante il deployment.
gcloud
Se utilizzi Google Cloud CLI, specifica il runtime
utilizzando il parametro --runtime. NAME specifica il
nome della funzione. Ad esempio:
Affinché le funzioni Cloud Run trovino la definizione della funzione, il codice sorgente deve seguire una struttura specifica. Per ulteriori informazioni, consulta Scrittura di funzioni Cloud Run.
Preparazione della funzione
Puoi preparare una funzione direttamente dalla Google Cloud console o scriverla sulla tua macchina locale e caricarla. Per preparare la tua macchina locale per lo sviluppo in Ruby, consulta Configurazione di un ambiente di sviluppo Ruby.
La libreria che richiama la funzione è il
Ruby Functions Framework.
Specifica delle dipendenze
Puoi specificare le dipendenze per la funzione aggiungendole a un file di progetto.
Per ulteriori informazioni, consulta Specificare le dipendenze in Ruby.
[[["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-03 UTC."],[[["\u003cp\u003eCloud Run functions utilize a runtime environment that includes the operating system, language support, and the Functions Framework library, with the specific environment determined by the selected Ruby version.\u003c/p\u003e\n"],["\u003cp\u003eYou can choose from several supported Ruby runtimes when deploying your Cloud Run function, with the available versions listed on the Runtime support page.\u003c/p\u003e\n"],["\u003cp\u003eWhen using the Google Cloud CLI, the \u003ccode\u003e--runtime\u003c/code\u003e parameter allows you to specify the desired Ruby runtime for your function during deployment.\u003c/p\u003e\n"],["\u003cp\u003eCloud Run functions require a specific source code structure for the system to locate your function's definition; therefore, it's imperative to follow the guidance given in the Writing Cloud Run functions documentation.\u003c/p\u003e\n"],["\u003cp\u003eRuby supports only CloudEvent functions as event-driven function types, and you can manage dependencies for your function by adding them to a designated project file, as detailed in the Specifying dependencies in Ruby guide.\u003c/p\u003e\n"]]],[],null,["# The Ruby Runtime\n================\n\nOverview\n--------\n\nYour Cloud Run function runs in an environment consisting of an operating\nsystem version plus add-on packages, language support, and\nthe Functions Framework library that supports and invokes your function.\nThis environment is identified by the language version, and is known as the\nruntime.\n\nFor information about runtimes in general, and to learn which Ubuntu version\neach Ruby runtime uses, see the [Cloud Run functions execution\nenvironment](/functions/1stgendocs/concepts/execution-environment#ruby).\n\nSelect your runtime\n-------------------\n\nCloud Run functions supports several versions of Ruby, listed on the\n[Runtime support](/functions/1stgendocs/runtime-support#ruby) page. You can\nselect the preferred Ruby runtime for your function during deployment. \n\n### gcloud\n\nIf you're using the Google Cloud CLI, specify the runtime\nby using the `--runtime` parameter. \u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e specifies the\nfunction name. For example: \n\n```bash\ngcloud functions deploy NAME --no-gen2 --runtime ruby33 --trigger-http\n```\n\nFor more deployment parameters, see [Deploy a Cloud Run function](/functions/1stgendocs/deploy#basics).\n\n### Console\n\nIf you're using the Google Cloud console, see the [Google Cloud console\nquickstart](/functions/1stgendocs/console-quickstart-1st-gen) for detailed instructions.\n\nSource code structure\n---------------------\n\nFor Cloud Run functions to find your function's definition, your\nsource code must follow a specific structure. See\n[Writing Cloud Run functions](/functions/1stgendocs/writing#structuring_source_code)\nfor more information.\n\nFunction preparation\n--------------------\n\nYou can prepare a function directly from the Google Cloud console or write it on\nyour local machine and upload it. To prepare your local machine for Ruby\ndevelopment, see [Setting up a Ruby development environment](/ruby/docs/setup).\nThe library that invokes your function is the\n[Ruby Functions Framework](/functions/1stgendocs/functions-framework).\n| **Note:** The only type of [event-driven functions](/functions/1stgendocs/writing#types_of_cloud_functions) Ruby supports are [CloudEvent functions](/functions/1stgendocs/writing#cloudevent_functions).\n\nSpecifying dependencies\n-----------------------\n\nYou can specify dependencies for your function by adding them to a project file.\nFor more information, see [Specifying dependencies in\nRuby](/functions/1stgendocs/writing/specifying-dependencies-ruby).\n\nWhat's next\n-----------\n\n- [Create your first Ruby function](/functions/1stgendocs/create-deploy-http-ruby-1st-gen) from scratch."]]