Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Abilitazione e disabilitazione dei servizi
Questa pagina descrive come attivare e disattivare i servizi per un Google Cloud progetto.
Puoi utilizzare l'Service Usage per attivare o disattivare qualsiasi servizio disponibile per i tuoi progetti, inclusi i Google Cloud servizi pubblici e i servizi privati creati utilizzando Cloud Endpoints. Per ulteriori informazioni sulle differenze tra API e servizi pubblici e privati, consulta Servizi pubblici e privati.
Per la maggior parte dei casi d'uso operativi, il modo più semplice per attivare e disattivare i servizi è utilizzare la Google Cloud console. Se devi creare script, puoi utilizzare anche Google Cloud CLI. Se devi programmare per l'API Service Usage, ti consigliamo di utilizzare una delle nostre librerie client. Per eseguire esperimenti con l'API,
puoi seguire le istruzioni alternative riportate in questa guida e utilizzare il comando curl
per testare l'API senza configurare un ambiente di sviluppo completo delle applicazioni.
Prima di iniziare
Per abilitare e disabilitare API e servizi, devi:
Un Google Cloud progetto. Per scoprire come creare un Google Cloud progetto, consulta
Creare e gestire progetti.
Se vuoi utilizzare gli esempi curl in questa guida, assicurati di seguire le istruzioni per completare la configurazione iniziale in Per iniziare. Questi passaggi includono la definizione di gcurl, che è un alias autenticato per il comando curl standard, e la definizione della variabile di ambiente PROJECT_NUMBER.
Attivazione dei servizi
L'attivazione dei servizi utilizza la quota della metrica serviceusage.googleapis.com/mutate_requests. La quota predefinita disponibile è di 2 query al secondo (QPS).
Seleziona il Google Cloud progetto in cui vuoi attivare un'API eseguendo una delle seguenti operazioni:
Fai clic su un Google Cloud progetto in Seleziona un progetto recente.
Utilizza il Google Cloud browser dei progetti seguendo questa procedura:
Fai clic su Seleziona progetto per aprire il Google Cloud browser dei progetti.
Individua il progetto e fai clic sul Google Cloud nome del progetto.
Fai clic su Apri per aprire il progetto.
Fai clic sull'API che vuoi attivare. Se hai bisogno di aiuto per trovare l'API, utilizza la casella Cerca API e servizi nella parte superiore della pagina. Viene visualizzata una pagina
che descrive l'API.
Fai clic sul pulsante Attiva.
gcloud
Esegui il seguente comando per abilitare il servizio API Pub/Sub nel
tuo progetto corrente:
gcloud services enable pubsub.googleapis.com
Il comando produce un output simile al seguente:
Waiting for async operation operations/acf.2e2fcfce-8327-4984-9040-a67777082687 to complete...
Operation finished successfully.
Per recuperare i dettagli dell'operazione, puoi utilizzare il seguente comando:
Puoi attivare un singolo servizio utilizzando il metodo
services.enable. Puoi attivare da 2 a 20 servizi in un'unica operazione utilizzando il metodo services.batchEnable.
Attivare un singolo servizio
Il seguente comando abilita il servizio API Pub/Sub nel tuo progetto:
Il metodo
services.enable
restituisce una risorsa
Operazione a lunga esecuzione
che rappresenta il lavoro in corso sul server. Ogni operazione ha un nome della risorsa univoco. Ad esempio, ecco un'operazione con il nome operations/acf.2e2fcfce-8327-4984-9040-a67777082687:
Se vuoi attivare più servizi API nel tuo progetto, puoi emettere un comando di abilitazione per ciascun servizio API singolarmente oppure un comando di abilitazione batch e specificare più API. Ad esempio, per attivare entrambi
i servizi API Pub/Sub e Dataflow nel tuo progetto:
Come services.enable, services.batchEnable
restituisce una risorsa dell'operazione, che puoi eseguire il polling utilizzando il relativo name.
Disabling services
La disattivazione dei servizi utilizza la quota della metrica serviceusage.googleapis.com/mutate_requests. La quota predefinita disponibile è di 2 query al secondo (QPS).
Puoi disattivare un'API per un progetto in qualsiasi momento, anche se eventuali commissioni in sospeso verranno comunque addebitate sul tuo account e ti verrà addebitato l'utilizzo dell'API fatturabile nei tuoi progetti. Per ulteriori informazioni, consulta
API e fatturazione.
Molti servizi, come Cloud Storage e BigQuery, richiedono un addebito per l'archiviazione dei dati. La disattivazione dell'accesso all'API di un servizio non comporta l'eliminazione dei dati sottostanti, che continueranno a essere fatturati. Se intendi interrompere l'utilizzo di un servizio e interrompere tutti i caricamenti futuri, assicurati di eliminare tutti i dati associati al servizio prima di disattivare l'accesso all'API del servizio.
Se disattivi l'API GKE, tutti i cluster in esecuzione nel progetto vengono sospesi. Dopo 30 giorni, i cluster sospesi vengono eliminati. Per reintegrare i cluster sospesi, abilita l'API GKE. Potrebbero essere necessarie fino a 24 ore per il reintegro dei cluster.
Seleziona il Google Cloud progetto in cui vuoi disattivare
un'API eseguendo una delle seguenti operazioni:
Fai clic su un Google Cloud progetto in Seleziona un progetto recente.
Utilizza il Google Cloud browser dei progetti seguendo questa procedura:
Fai clic su Seleziona progetto per aprire il Google Cloud browser dei progetti.
Individua il progetto e fai clic sul Google Cloud nome del progetto.
Fai clic su Apri per aprire il progetto.
Fai clic sull'API che vuoi disattivare. Se hai bisogno di aiuto per trovare l'API, utilizza la casella Cerca API e servizi nella parte superiore della pagina. Viene visualizzata una pagina
che descrive l'API.
Fai clic su stopDisabilita API.
gcloud
Esegui il seguente comando per disattivare il servizio API Pub/Sub per il progetto corrente:
gcloud services disable pubsub.googleapis.com
Il comando produce un output simile al seguente:
Waiting for async operation operations/acf.e9d0943b-55d9-4ac0-8af4-745e1b8983f8 to complete...
Operation finished successfully.
Per recuperare i dettagli dell'operazione, puoi utilizzare il seguente comando:
[[["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."],[],[],null,["# Enabling and Disabling Services\n===============================\n\nThis page describes how to enable and disable services for a Google Cloud project.\nYou can use Service Usage to enable or disable any available service\nfor your projects, including public\n[Google Cloud services](/terms/services) and private services created\nusing [Cloud Endpoints](/endpoints/docs). For more information on the\ndifferences between public and private APIs and services, see\n[Public and Private Services](/service-usage/docs/public-vs-private).\n\nFor most operational use cases, the simplest way to enable and disable services\nis to use the Google Cloud console. If you need to create scripts, you can also use the\nGoogle Cloud CLI. If you need to program against the\nService Usage API, we recommend that you use one of our provided\n[client libraries](/service-usage/docs/libraries). To experiment with the API,\nyou can follow the alternative instructions in this guide and use the `curl`\ncommand to test the API without setting up a full application development\nenvironment.\n\nBefore you begin\n----------------\n\nTo enable and disable APIs and services you need:\n\n- A Google Cloud project. To learn how to create a Google Cloud project, see [Creating and Managing Projects](/resource-manager/docs/creating-managing-projects).\n- The correct [Identity and Access Management](/iam) permissions. To learn about the IAM requirements for Service Usage, see [Access Control](/service-usage/docs/access-control).\n- To install the [Google Cloud CLI](/sdk/docs/install).\n- If you want to use the `curl` examples in this guide, make sure you follow the instructions to complete the initial setup in [Getting Started](/service-usage/docs/set-up-development-environment). These steps include defining `gcurl`, which is an authenticated alias for the standard `curl` command, and defining the environment variable `PROJECT_NUMBER`.\n\nEnabling services\n-----------------\n\nEnabling services uses quota from the\n`serviceusage.googleapis.com/mutate_requests` quota metric. The default\navailable quota is 2 queries per second (QPS). \n\n### console\n\nTo enable an API for a project:\n\n1. Go to the Google Cloud console [API Library](https://console.cloud.google.com/project/_/apis/library) page. \n [Go to the API Library page](https://console.cloud.google.com/project/_/apis/library)\n2. Select the Google Cloud project where you want to enable\n an API by performing one of the following:\n\n - Click on a Google Cloud project under **Select a recent project**.\n\n - Use the Google Cloud project browser by performing the following\n steps:\n\n 1. Click **Select project** to open the Google Cloud project browser.\n 2. Find your project and then click on the Google Cloud project name.\n 3. Click **Open** to open the project.\n3. Click the API you want to enable. If you need help finding the API, use\n the **Search for APIs \\& Services** box near the top of the page. A page\n describing the API appears.\n\n4. Click the **Enable** button.\n\n### gcloud\n\nRun the following command to enable the Pub/Sub API service in your\ncurrent project: \n\n```\ngcloud services enable pubsub.googleapis.com\n```\n\nThe command produces output similar to the following: \n\n```\nWaiting for async operation operations/acf.2e2fcfce-8327-4984-9040-a67777082687 to complete...\nOperation finished successfully.\n```\n\nYou can use the following command to get the operation details: \n\n```\ngcloud services operations describe operations/acf.2e2fcfce-8327-4984-9040-a67777082687\n```\n\n### curl\n\nYou can enable a single service using the\n[`services.enable`](/service-usage/docs/reference/rest/v1/services/enable)\nmethod. You can enable between 2 and 20 services in a single operation using\nthe [`services.batchEnable`](/service-usage/docs/reference/rest/v1/services/batchEnable)\nmethod.\n\n### Enable a single service\n\nThe following command enables the Pub/Sub API service on your\nproject: \n\n gcurl -d '{}' \"https://serviceusage.googleapis.com/v1/projects/${PROJECT_NUMBER}/services/pubsub.googleapis.com:enable\"\n\nThe\n[`services.enable`](/service-usage/docs/reference/rest/v1/services/enable)\nmethod returns a\n[Long Running Operation](/service-usage/docs/reference/rest/v1/operations)\nresource, which represents ongoing work on the server. Each operation has\na unique resource name. For example, here is an operation\nwith the name `operations/acf.2e2fcfce-8327-4984-9040-a67777082687`: \n\n {\n \"name\": \"operations/acf.2e2fcfce-8327-4984-9040-a67777082687\"\n }\n\nTo poll the operation status by using the Service Usage\n[`operations.get`](/service-usage/docs/reference/rest/v1/operations/get)\nmethod, pass the name of the operation to the API: \n\n OPERATION_NAME=\"operations/acf.2e2fcfce-8327-4984-9040-a67777082687\"\n gcurl \"https://serviceusage.googleapis.com/v1/${OPERATION_NAME}\"\n\n### Enable multiple services at once\n\nIf you want to enable multiple API services on your project, you can issue\nan enable command for each API service individually, or you can issue one\nbatch enable command and specify multiple APIs. For example, to enable both\nthe Pub/Sub and Dataflow API services on your project: \n\n gcurl -d '{\n \"serviceIds\": [\"pubsub.googleapis.com\", \"dataflow.googleapis.com\"]\n }' \"https://serviceusage.googleapis.com/v1/projects/${PROJECT_NUMBER}/services:batchEnable\"\n\nLike `services.enable`, [`services.batchEnable`](/service-usage/docs/reference/rest/v1/services/batchEnable)\nreturns an operation resource, which you can poll by using its `name`.\n| **Note:** The process for enabling APIs can vary. Some APIs prompt you to accept their Terms of Service before you can enable them. Some APIs are in preview mode and require special signup and whitelisting before you can use them. Other APIs might ask for additional information, such as your organization's contact information and the name of the application you are developing. When more information is requested, it will not be shared outside of Google; it's used to help Google understand how the API is being used and as a secondary contact should we need to contact you regarding your use of the service.\n\nDisabling services\n------------------\n\nDisabling services uses quota from the\n`serviceusage.googleapis.com/mutate_requests` quota metric. The default\navailable quota is 2 queries per second (QPS).\n\nYou can disable an API for a project at any time, although any pending fees will\nstill be charged to your account and you'll be charged for any billable API use\nin your projects. For more information, see\n[APIs and Billing](https://support.google.com/cloud/answer/6158867).\n\nMany services like Cloud Storage and BigQuery charge to store data. Disabling a\nservice's API access does not delete the underlying data which will continue\nto be billed. If your intent is to discontinue using a service and stop all\nfuture charges, be sure to delete all data associated with the service before\ndisabling the service's API access.\n\nIf you disable the GKE API, any running clusters in the project become suspended. After 30 days, the suspended clusters are deleted. To reinstate your suspended clusters, enable the GKE API. It may take up to 24 hours for the clusters to be reinstated.\n**Note:** In v1 of the API, if you attempt to disable a service that other enabled services depend on, the call will fail. The API call to disable the service will result in an error message. To disable the specified service and all of the services that depend on it, set the `disable_dependent_services` parameter on the [`services.disable`](/service-usage/docs/reference/rest/v1/services/disable) request to `true`. \n\n### console\n\nTo disable an API for a project:\n\n1. Go to the Google Cloud console [API Dashboard](https://console.cloud.google.com/project/_/apis/dashboard) page. \n [Go to the API Dashboard page](https://console.cloud.google.com/project/_/apis/dashboard)\n2. Select the Google Cloud project where you want to disable\n an API by performing one of the following:\n\n - Click on a Google Cloud project under **Select a recent project**.\n\n - Use the Google Cloud project browser by performing the following\n steps:\n\n 1. Click **Select project** to open the Google Cloud project browser.\n 2. Find your project and then click on the Google Cloud project name.\n 3. Click **Open** to open the project.\n3. Click the API you want to disable. If you need help finding the API, use\n the **Search for APIs \\& Services** box near the top of the page. A page\n describing the API appears.\n\n4. Click *stop* **Disable API**.\n\n### gcloud\n\nRun the following command to disable the Pub/Sub API service for\nyour current project: \n\n```\ngcloud services disable pubsub.googleapis.com\n```\n\nThe command produces output similar to the following: \n\n```\nWaiting for async operation operations/acf.e9d0943b-55d9-4ac0-8af4-745e1b8983f8 to complete...\nOperation finished successfully.\n```\n\nYou can use the following command to get the operation details: \n\n```\ngcloud services operations describe operations/acf.e9d0943b-55d9-4ac0-8af4-745e1b8983f8\n```\n\n### curl\n\nThe following command disables the Pub/Sub API service on\nyour project: \n\n gcurl -d '{}' \"https://serviceusage.googleapis.com/v1/projects/${PROJECT_NUMBER}/services/pubsub.googleapis.com:disable\"\n\nLike `services.enable`, [`services.disable`](/service-usage/docs/reference/rest/v1/services/disable)\nreturns an operation resource, which you can poll by using its `name`."]]