Quickstart using the gcloud tool

This quickstart shows you how to create, deploy, and execute your first workflow using the gcloud command-line tool. The workflow sends a request to a sample API and then uses the response to create and send a request to a public API. The workflow then returns the public API's response.

For a list of all Workflows gcloud tool commands, see the Workflows gcloud tool reference page.

Before you begin

  1. Melden Sie sich bei Ihrem Google Cloud-Konto an. Wenn Sie mit Google Cloud noch nicht vertraut sind, erstellen Sie ein Konto, um die Leistungsfähigkeit unserer Produkte in der Praxis sehen und bewerten zu können. Neukunden erhalten außerdem ein Guthaben von 300 $, um Arbeitslasten auszuführen, zu testen und bereitzustellen.
  2. Wählen Sie in der Google Cloud Console auf der Seite der Projektauswahl ein Google Cloud-Projekt aus oder erstellen Sie eines.

    Zur Projektauswahl

  3. Die Abrechnung für das Cloud-Projekt muss aktiviert sein. So prüfen Sie, ob die Abrechnung für Ihr Projekt aktiviert ist.

  4. Installieren und initialisieren Sie das Cloud SDK.
  5. Enable the Workflows API.

    gcloud services enable workflows.googleapis.com
  6. Create the service account and give it a name; for example, sa-name.
    gcloud iam service-accounts create sa-name
  7. Grant the roles/logging.logWriter role to the service account.

    gcloud projects add-iam-policy-binding PROJECT_ID \
        --member "serviceAccount:sa-name@PROJECT_ID.iam.gserviceaccount.com" \
        --role "roles/logging.logWriter"

    Replace PROJECT_ID with your project's ID.

Create, deploy, and execute a workflow

  1. Open a terminal or Cloud Shell.
  2. In your home directory, create a new file called myFirstWorkflow.yaml or myFirstWorkflow.json.
  3. Copy and paste one of the following into the new file, then save it:


    - getCurrentTime:
        call: http.get
          url: https://us-central1-workflowsample.cloudfunctions.net/datetime
        result: currentTime
    - readWikipedia:
        call: http.get
          url: https://en.wikipedia.org/w/api.php
            action: opensearch
            search: ${currentTime.body.dayOfTheWeek}
        result: wikiResult
    - returnResult:
        return: ${wikiResult.body[1]}


        "getCurrentTime": {
          "call": "http.get",
          "args": {
            "url": "https://us-central1-workflowsample.cloudfunctions.net/datetime"
          "result": "currentTime"
        "readWikipedia": {
          "call": "http.get",
          "args": {
            "url": "https://en.wikipedia.org/w/api.php",
            "query": {
              "action": "opensearch",
              "search": "${currentTime.body.dayOfTheWeek}"
          "result": "wikiResult"
        "returnResult": {
          "return": "${wikiResult.body[1]}"
    This workflow makes a call to a sample API. The returned day of the week is passed to the Wikipedia API. Relevant articles on Wikipedia about the current day of the week are returned.
  4. Deploy the workflow and associate it with the specified service account:
    gcloud workflows deploy myFirstWorkflow --source=myFirstWorkflow.yaml \

    Replace the following:

    • .yaml: Replace with .json if you copied the JSON version of the example workflow.

    • PROJECT_ID: Your project ID.

  5. Execute the workflow:
    gcloud workflows run myFirstWorkflow

    This returns the results of the execution attempt. The output is similar to the following:

    argument: 'null'
    endTime: '2020-06-23T16:21:35.266171131Z'
    name: projects/123456789012/locations/us-central1/workflows/myFirstWorkflow/executions/f72bc6d4-5ea0-4dfb-bb14-2dae82303120
    result: '["Tuesday","Tuesday Weld","Tuesday Night Music Club","Tuesday (ILoveMakonnen
      song)","Tuesdays with Morrie","Tuesday Group","Tuesday Knight","Tuesday (Burak Yeter
      song)","Tuesday Morning Quarterback","Tuesday Maybe"]'
    startTime: '2020-06-23T16:21:34.826993288Z'
    state: SUCCEEDED
    workflowVersionId: '1'
  6. You've deployed and executed your first workflow!

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

  1. Delete the workflow you created:
    gcloud workflows delete myFirstWorkflow
  2. When asked if you want to continue, enter y.

The workflow is deleted.

What's next