Il 15 settembre 2026, tutti gli ambienti Cloud Composer 1 e Cloud Composer 2 versione 2.0.x raggiungeranno la fine del ciclo di vita pianificata e non potrai più utilizzarli. Ti consigliamo di pianificare la migrazione a Cloud Composer 3.
Apache Airflow ha un'interfaccia a riga di comando (CLI) che puoi utilizzare per eseguire
attività come l'attivazione e la gestione di DAG, l'ottenimento di informazioni sulle esecuzioni di DAG
e sulle attività, l'aggiunta e l'eliminazione di connessioni e utenti.
Comandi dell'interfaccia a riga di comando Airflow supportati
Airflow in Cloud Composer 1 fornisce due sintassi diverse per i comandi CLI:
Per un elenco completo dei comandi dell'interfaccia a riga di comando di Airflow supportati, consulta la documentazione di riferimento del comando
gcloud composer environments run.
Prima di iniziare
Devi disporre delle autorizzazioni per utilizzare
Google Cloud CLI con Cloud Composer ed eseguire i comandi
dell'interfaccia a riga di comando Airflow.
I comandi dell'interfaccia a riga di comando di Airflow consumano la environments.executeAirflowCommandquota.
Esegui i comandi dell'interfaccia a riga di comando di Airflow
Per eseguire i comandi dell'interfaccia a riga di comando di Airflow nei tuoi ambienti, utilizza gcloud CLI:
La maggior parte dei comandi gcloud composer richiede una posizione. Puoi specificare la posizione con il flag --location o impostando la posizione predefinita.
Ad esempio, per attivare un DAG denominato sample_quickstart con l'ID 5077 nel tuo ambiente Cloud Composer:
[[["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-08-29 UTC."],[[["\u003cp\u003eCloud Composer 1 utilizes the Apache Airflow command-line interface (CLI) for managing tasks like triggering DAGs, accessing DAG run details, and handling connections and users.\u003c/p\u003e\n"],["\u003cp\u003eCloud Composer 1 supports two different syntaxes for CLI commands: Airflow 1.10 CLI syntax for environments with Airflow 1.10, and Airflow 2 CLI syntax for environments running Airflow 2.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud composer environments run\u003c/code\u003e command is used to execute Airflow CLI commands in Cloud Composer environments, requiring specification of the environment name, location, subcommand, and subcommand arguments.\u003c/p\u003e\n"],["\u003cp\u003eWhen using the \u003ccode\u003egcloud composer environments run\u003c/code\u003e command, arguments for Airflow CLI subcommands should be separated by \u003ccode\u003e--\u003c/code\u003e, and different syntax rules apply for Airflow 1 and Airflow 2 environments.\u003c/p\u003e\n"],["\u003cp\u003eFor private IP environments, Airflow CLI commands must be run from a machine with access to the GKE cluster's control plane, and if public endpoint access is disabled, \u003ccode\u003ekubectl\u003c/code\u003e can be used directly with cluster credentials.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n[Cloud Composer 3](/composer/docs/composer-3/access-airflow-cli \"View this page for Cloud Composer 3\") \\| [Cloud Composer 2](/composer/docs/composer-2/access-airflow-cli \"View this page for Cloud Composer 2\") \\| **Cloud Composer 1**\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nApache Airflow has a command-line interface (CLI) that you can use to perform\ntasks such as triggering and managing DAGs, getting information about DAG runs\nand tasks, adding and deleting connections and users.\n\nSupported Airflow CLI commands\n\n\u003cbr /\u003e\n\nAirflow in Cloud Composer 1 provides two different syntaxes for CLI commands:\n\n- [Airflow 1.10 CLI syntax](https://airflow.apache.org/docs/apache-airflow/1.10.12/cli-ref.html),\n available in Cloud Composer environments with Airflow 1.10.\n\n- [Airflow 2 CLI syntax](https://airflow.apache.org/docs/apache-airflow/stable/cli-and-env-variables-ref.html),\n available Cloud Composer environments with Airflow 2.\n\nFor a full list of supported Airflow CLI commands, see the reference for the\n[`gcloud composer environments run`](/sdk/gcloud/reference/composer/environments/run#SUBCOMMAND) command.\n\nBefore you begin\n\n- You must have [permissions](/composer/docs/composer-1/access-control#cli) to use\n Google Cloud CLI with Cloud Composer and run Airflow CLI\n commands.\n\n | **Caution:** Users with the `composer.environments.executeairflowcommand` permission can execute Python code available to Airflow components on behalf of the environment's service account. For more information, see [Access control](/composer/docs/composer-1/access-control#service-account-security).\n- Airflow CLI commands consume the `environments.executeAirflowCommand`\n [quota](/composer/quotas).\n\n | **Important:** If you want to trigger a large number of DAGs, we recommend to do it [with Airflow REST API](/composer/docs/composer-1/access-airflow-api#call-api). Triggering DAGs through Google Cloud CLI might cause your environment to reach the quota limit, and as a result, Airflow CLI commands will no longer be executed.\n\nRun Airflow CLI commands\n\nTo run Airflow CLI commands in your environments, use gcloud CLI: \n\n gcloud composer environments run \u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e \\\n --location \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e \\\n \u003cvar translate=\"no\"\u003eSUBCOMMAND\u003c/var\u003e \\\n -- \u003cvar translate=\"no\"\u003eSUBCOMMAND_ARGUMENTS\u003c/var\u003e\n\nReplace the following :\n\n- `ENVIRONMENT_NAME`: the name of your environment.\n- `LOCATION`: the region where the environment is located.\n- `SUBCOMMAND`: one of the [supported Airflow CLI commands](/sdk/gcloud/reference/composer/environments/run#SUBCOMMAND).\n- `SUBCOMMAND_ARGUMENTS` with arguments for the Airflow CLI command.\n\nSub-command arguments separator\n\nSeparate the arguments for the specified Airflow CLI command with `--`:\n\n\u003cbr /\u003e\n\nAirflow 2\n\n\n- Specify compound CLI commands as a sub-command.\n- Specify any arguments for compound commands as sub-command arguments, after a `--` separator.\n\nExample: \n\n gcloud composer environments run example-environment \\\n dags list -- --output=json\n\n\u003cbr /\u003e\n\nAirflow 1\n\n\n- Specify CLI commands as a sub-command.\n- Specify any arguments after a `--` separator.\n\nExample: \n\n gcloud composer environments run example-environment \\\n list_dags -- --report\n\n\u003cbr /\u003e\n\nDefault location\n\nMost `gcloud composer` commands require a location. You can specify the\nlocation with the `--location` flag, or by\n[setting the default location](/composer/docs/gcloud-installation#set-default).\n\nFor example, to trigger a DAG named `sample_quickstart` with the ID `5077` in\nyour Cloud Composer environment:\n\n\u003cbr /\u003e\n\nAirflow 2\n\n\n gcloud composer environments run example-environment \\\n --location us-central1 dags trigger -- sample_quickstart \\\n --run-id=5077\n\n\u003cbr /\u003e\n\nAirflow 1\n\n\n gcloud composer environments run example-environment \\\n --location us-central1 trigger_dag -- sample_quickstart \\\n --run_id=5077\n\n\u003cbr /\u003e\n\nWhat's next\n\n- [Access Airflow UI](/composer/docs/composer-1/access-airflow-web-interface)\n- [Access control (Airflow CLI)](/composer/docs/composer-1/access-control#cli)"]]