Jika Anda membuat fungsi baru, lihat Panduan Memulai Konsol di Cloud Run. Konten di halaman ini hanya berlaku untuk fungsi lama yang sudah ada yang dibuat dengan Cloud Functions v1 API.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Pemicu HTTP (generasi ke-1)
Di fungsi Cloud Run, pemicu HTTP memungkinkan fungsi berjalan sebagai respons terhadap permintaan HTTP(S). Saat Anda menentukan pemicu HTTP untuk suatu fungsi, fungsi tersebut
akan diberi URL yang dapat digunakan untuk menerima permintaan. Pemicu HTTP mendukung
metode permintaan GET, POST, PUT, DELETE, dan OPTIONS.
Anda menggunakan fungsi HTTP
untuk mengimplementasikan fungsi Cloud Run yang dapat menangani permintaan HTTP(S) umum.
Deployment
Anda dapat menentukan pemicu HTTP saat men-deploy fungsi. Lihat
Men-deploy fungsi Cloud Run untuk mengetahui petunjuk umum tentang cara men-deploy fungsi, dan bagian ini untuk mengetahui informasi tambahan khusus terkait cara mengonfigurasi pemicu HTTP selama deployment.
Flag --trigger-http menentukan bahwa fungsi tersebut menggunakan pemicu HTTP.
Flag
--allow-unauthenticated
menentukan bahwa fungsi dapat dipanggil tanpa autentikasi.
Menghapus flag ini berarti bahwa panggilan ke fungsi tersebut memerlukan
autentikasi. Lihat
Mengautentikasi untuk pemanggilan
untuk informasi selengkapnya.
Flag
--security-level
mengontrol apakah endpoint fungsi memerlukan HTTPS.
Nilai secure-always berarti HTTPS diperlukan dan permintaan HTTP non-SSL
tidak didukung. Nilai secure-optional berarti HTTP dan HTTPS
didukung. Defaultnya adalah secure-always.
Di kolom Authentication, pilih opsi bergantung pada
apakah Anda ingin mengizinkan pemanggilan fungsi yang tidak terautentikasi atau tidak. Secara default, autentikasi diwajibkan. Lihat
Mengautentikasi untuk pemanggilan
untuk mengetahui informasi selengkapnya.
Centang atau hapus centang pada kotak Wajibkan HTTPS untuk mengontrol apakah
endpoint fungsi memerlukan HTTPS. Jika tidak dipilih, HTTP dan
HTTPS akan didukung.
URL Fungsi
Setelah fungsi di-deploy dengan pemicu HTTP, Anda dapat mengambil
URL yang ditetapkan.
Fungsi Cloud Run telah menetapkan URL dengan format
berikut. URL ini memiliki format deterministik, yang berarti Anda dapat memprediksi
URL sebelum men-deploy fungsi:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 UTC."],[[["\u003cp\u003eHTTP triggers allow Cloud Run functions to execute in response to HTTP(S) requests, with support for \u003ccode\u003eGET\u003c/code\u003e, \u003ccode\u003ePOST\u003c/code\u003e, \u003ccode\u003ePUT\u003c/code\u003e, \u003ccode\u003eDELETE\u003c/code\u003e, and \u003ccode\u003eOPTIONS\u003c/code\u003e methods, and each function is assigned a unique URL for receiving requests.\u003c/p\u003e\n"],["\u003cp\u003eBy default, HTTP triggered functions require authentication, but you can configure them during deployment to allow unauthenticated access if needed.\u003c/p\u003e\n"],["\u003cp\u003eYou can deploy a function with an HTTP trigger using the \u003ccode\u003egcloud\u003c/code\u003e CLI, where you have flags to set whether authentication is needed and if the endpoint requires HTTPS, or you can do so through the Google Cloud console by selecting the HTTP option in the trigger section.\u003c/p\u003e\n"],["\u003cp\u003eAfter deployment, the function's assigned URL can be retrieved via the \u003ccode\u003egcloud\u003c/code\u003e CLI using a command, or in the console by navigating to the function's details and viewing the trigger information.\u003c/p\u003e\n"],["\u003cp\u003eCloud Run function URLs follow a predictable format, allowing users to estimate the function URL before deploying the function.\u003c/p\u003e\n"]]],[],null,["# HTTP triggers (1st gen)\n=======================\n\nIn Cloud Run functions, an HTTP trigger enables a function to run in response to\nHTTP(S) requests. When you specify an HTTP trigger for a function, the function\nis assigned a URL at which it can receive requests. HTTP triggers support the\n`GET`, `POST`, `PUT`, `DELETE`, and `OPTIONS` request methods.\n\nBy default, requests to a function with an HTTP trigger require\n[authentication](/functions/1stgendocs/securing/authenticating). You can choose to\nallow unauthenticated calls during [deployment](#deployment). See\n[Allowing unauthenticated HTTP function invocation](/functions/1stgendocs/securing/managing-access-iam#allowing_unauthenticated_http_function_invocation)\nfor more information.\n\nYou use [HTTP functions](/functions/1stgendocs/writing/write-http-functions)\nto implement Cloud Run functions that can handle general HTTP(S) requests.\n\nDeployment\n----------\n\nYou can specify an HTTP trigger when you deploy a function. See\n[Deploy a Cloud Run function](/functions/1stgendocs/deploy) for\ngeneral instructions on how to deploy a function, and this section for\nadditional information specific to configuring HTTP triggers during deployment. \n\n### gcloud\n\nIf you are\n[deploying using the gcloud CLI](/functions/1stgendocs/deploy#gcloud),\nthe flags shown here are used to configure HTTP triggers: \n\n```sh\ngcloud functions deploy YOUR_FUNCTION_NAME \\\n--no-gen2 \\\n--trigger-http \\\n[--allow-unauthenticated] \\\n[--security-level=SECURITY_LEVEL] \\\n...\n```\n\n- The [`--trigger-http`](/sdk/gcloud/reference/functions/deploy#--trigger-http) flag specifies that the function uses an HTTP trigger.\n- The [`--allow-unauthenticated`](/sdk/gcloud/reference/functions/deploy#--allow-unauthenticated) flag specifies that the function can be called without authentication. Omitting this flag means that calls to the function require authentication. See [Authenticating for invocation](/functions/1stgendocs/securing/authenticating) for more information.\n- The [`--security-level`](/sdk/gcloud/reference/functions/deploy#--security-level) flag controls whether the function endpoint requires HTTPS. The value `secure-always` means HTTPS is required and non-SSL HTTP requests are not supported. The value `secure-optional` means both HTTP and HTTPS are supported. The default is `secure-always`.\n\n### Console\n\nIf you are\n[deploying using the Google Cloud console](/functions/1stgendocs/deploy#console),\nyou can configure an HTTP trigger in the **Trigger** section:\n\n1. In the **Trigger type** field, select **HTTP**.\n2. In the **Authentication** field, select an option depending on whether you want to allow unauthenticated invocations of your function. By default, authentication is required. See [Authenticating for invocation](/functions/1stgendocs/securing/authenticating) for more information.\n3. Select or clear the **Require HTTPS** checkbox to control whether the function endpoint requires HTTPS. If deselected, both HTTP and HTTPS are supported.\n\nFunction URL\n------------\n\nAfter your function is deployed with an HTTP trigger, you can retrieve its\nassigned URL.\n\nCloud Run functions have assigned URLs that have the following\nformat. These URLs have a deterministic format, meaning that you can predict\nwhat the URL will be before you deploy the function: \n\n```sh\nhttps://REGION-PROJECT_ID.cloudfunctions.net/FUNCTION_NAME\n```\n\nYou can retrieve your function's URL(s) as follows: \n\n### gcloud\n\n\u003cbr /\u003e\n\n```sh\n gcloud functions describe YOUR_FUNCTION_NAME \n\n --format=\"value(httpsTrigger.url)\"\n \n```\n\n\u003cbr /\u003e\n\n### Console\n\n1. Go to the Cloud Run functions overview page in the Google Cloud console:\n\n [Go to Cloud Run functions](https://console.cloud.google.com/functions/list)\n2. Click the name of the function whose URL you want to retrieve.\n\n3. Click the Edit tab.\n\n4. View your function's URL in the **Trigger** section.\n\nNext steps\n----------\n\n- Learn how to [write HTTP functions](/functions/1stgendocs/writing/write-http-functions).\n- Learn how to [deploy a Cloud Run function](/functions/1stgendocs/deploy).\n- See the [HTTP function tutorial](/functions/1stgendocs/tutorials/http-1st-gen) for an example of writing, deploying, and calling an HTTP function."]]