Stay organized with collections Save and categorize content based on your preferences.
Add an HTTP target task to a Cloud Tasks queueThis quickstart shows you how to add an HTTP target task to a Cloud Tasks queue using the Cloud Tasks API.
Before you beginInstall the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
Create or select a Google Cloud project.
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.Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace PROJECT_ID
with a name for the Google Cloud project you are creating.
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace PROJECT_ID
with your Google Cloud project name.
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Tasks API:
gcloud services enable cloudtasks.googleapis.com
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/cloudtasks.admin, roles/logging.viewer
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
Replace the following:
PROJECT_ID
: your project ID.USER_IDENTIFIER
: the identifier for your user account—for example, myemail@example.com
.ROLE
: the IAM role that you grant to your user account.Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
Create or select a Google Cloud project.
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.Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace PROJECT_ID
with a name for the Google Cloud project you are creating.
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace PROJECT_ID
with your Google Cloud project name.
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Tasks API:
gcloud services enable cloudtasks.googleapis.com
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/cloudtasks.admin, roles/logging.viewer
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
Replace the following:
PROJECT_ID
: your project ID.USER_IDENTIFIER
: the identifier for your user account—for example, myemail@example.com
.ROLE
: the IAM role that you grant to your user account.Use the gcloud tasks queues create
command to create your queue.
gcloud
queue management methods carries some risk if used together with methods based on uploading queue.yaml/queue.xml
. For more information, see Use Queue Management or queue.yaml.
In your terminal, create a queue that logs all operations.
gcloud tasks queues create QUEUE_NAME \
--log-sampling-ratio=1.0 \
--location=REGION
Replace the following:
QUEUE_NAME
: a name for your Cloud Tasks queueREGION
: the supported region you deployed your service or app inWait for the queue to initialize and then verify that it was created successfully.
gcloud tasks queues describe QUEUE_NAME \
--location=REGION
The output should be similar to the following:
name: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_NAME
rateLimits:
maxBurstSize: 100
maxConcurrentDispatches: 1000
maxDispatchesPerSecond: 500.0
retryConfig:
maxAttempts: 100
maxBackoff: 3600s
maxDoublings: 16
minBackoff: 0.100s
state: RUNNING
Use the gcloud tasks create-http-task
command to create a task that targets an HTTP endpoint and add the task to your queue.
Create a task, add it to the queue you created, and deliver that task to an HTTP endpoint.
gcloud tasks create-http-task \
--queue=QUEUE_NAME \
--url=URL_PATH \
--method=GET \
--location=REGION \
--project=PROJECT_ID
Replace URL_PATH
with the full URL path that the request will be sent to. For example: https://www.google.com
The path must begin with either http://
or https://
.
Verify that the task was executed successfully by reading the logs.
gcloud logging read --limit=3
The logs should look similar to the following:
jsonPayload:
'@type': type.googleapis.com/google.cloud.tasks.logging.v1.TaskActivityLog
task: projects/PROJECT_ID/locations/REGION/queues/QUEUE_NAME/tasks/TASK_ID
taskCreationLog:
scheduleTime: '2024-07-04T19:00:27.801837Z'
status: OK
targetAddress: GET https://www.google.com/
targetType: HTTP
To avoid incurring charges to your Google Cloud account for the resources used on this page, delete the Google Cloud project with the resources.
Caution: Deleting a project has the following effects:appspot.com
URL, delete selected resources inside the project instead of deleting the whole project.If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects can help you avoid exceeding project quota limits.
Delete a Google Cloud project:
gcloud projects delete PROJECT_ID
Alternatively, you can delete the Cloud Tasks queue:
gcloud tasks queues delete QUEUE_NAME \
--location=REGION
What's next
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4