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.
Men-deploy fungsi Cloud Run generasi ke-1 menggunakan Google Cloud konsol
Cloud Run functions adalah lingkungan eksekusi tanpa server untuk membuat dan menghubungkan layanan cloud. Dengan Cloud Run Functions, Anda menulis fungsi-fungsi bertujuan tunggal yang dilampirkan ke peristiwa yang muncul dari infrastruktur serta layanan cloud Anda. Fungsi Anda dipicu saat peristiwa yang sedang dipantau diaktifkan, atau oleh permintaan HTTP.
Halaman ini menunjukkan cara membuat dan men-deploy fungsi HTTP generasi ke-1 menggunakanGoogle Cloud konsol. Perhatikan bahwa Anda hanya dapat membuat fungsi generasi ke-1 baru di project yang ada, bukan project baru. Untuk project baru, lihat
Panduan memulai Konsol untuk fungsi Cloud Run.
Untuk mengikuti panduan langkah demi langkah tugas ini langsung di
Google Cloud konsol, klik Pandu saya:
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Pastikan project tempat Anda mengaktifkan fungsi Cloud Run dipilih. Anda hanya dapat mengakses link ini untuk project yang ada. Jika tidak,
Anda akan dialihkan ke konsol
Cloud Run Google Cloud . Untuk mempelajari cara membuat dan men-deploy fungsi menggunakan konsol Cloud Run, lihat Panduan Memulai Konsol untuk fungsi Cloud Run. Google Cloud
Klik Create function.
Beri nama fungsi Anda, misalnya, function-1.
Nama yang Anda berikan untuk fungsi dapat berisi huruf kecil, angka, dan tanda hubung.
Pada kolom Trigger, pilih HTTP.
Di kolom Authentication, pilih Require Authentication.
Opsi lainnya, Izinkan pemanggilan yang tidak diautentikasi, memungkinkan Anda menjangkau fungsi tanpa autentikasi.
Hal ini berguna untuk pengujian, tetapi sebaiknya jangan gunakan setelan ini dalam
produksi kecuali Anda membuat situs atau API publik. Selain itu, fitur ini mungkin tidak berfungsi untuk Anda, bergantung pada setelan kebijakan perusahaan Anda. Baca bagian Mengautentikasi pemanggilan untuk mengetahui informasi selengkapnya tentang cara memanggil fungsi yang memerlukan autentikasi.
Klik Save untuk menyimpan perubahan, lalu klik Next.
Di kolom Source code, pilih Inline editor. Dalam latihan ini,
Anda akan menggunakan fungsi "Halo Dunia" default yang disediakan di editor.
Gunakan drop-down Runtime untuk memilih runtime bahasa yang Anda pilih.
Menerapkan fungsi
Di bagian bawah halaman, klik Deploy.
Klik ikon west untuk kembali ke halaman Ringkasan Cloud Run functions.
Ketika fungsi sedang diterapkan, ikon di sebelahnya akan terlihat seperti indikator lingkaran berputar kecil. Setelah selesai di-deploy, spinner berubah menjadi tanda centang hijau:
Menguji fungsi
Tampilkan menu more_vert untuk fungsi Anda, lalu pilih Test function.
Di halaman pengujian, klik Uji fungsi.
Layar Output menampilkan teks "Halo Dunia!"
Sekarang ubah pesannya. Di kolom Triggering Event, masukkan teks {"message":"Hello, YOUR_NAME!"}, ganti YOUR_NAME dengan nama, lalu klik Test the function.
Misalnya, Anda memasukkan nama "Rowan". Di kolom Output, Anda akan melihat pesan Hello, Rowan!.
Di kolom Log, kode status 200 menunjukkan keberhasilan.
Melihat log
Periksa log untuk melihat pesan Anda dalam histori log:
Di halaman Ringkasan Cloud Run functions, tampilkan menu more_vert untuk fungsi Anda, lalu klik Lihat log.
[[["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\u003eThis guide demonstrates how to create and deploy a 1st generation (1st gen) HTTP Cloud Run function using the Google Cloud console, specifically focusing on functions that are triggered by HTTP requests.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves creating a function within the Cloud Run functions Overview page, selecting the 1st gen environment, and configuring an HTTP trigger with the option for either requiring authentication or allowing unauthenticated access.\u003c/p\u003e\n"],["\u003cp\u003eThe function's code can be managed within an inline editor, and once configured, users can deploy the function directly from the console, and upon completion of deployment, the green check mark will signify a successful deployment.\u003c/p\u003e\n"],["\u003cp\u003eTesting the deployed function is straightforward, allowing users to view output and logs, with an example provided to test changing the message to be displayed, including information regarding the success status code of 200.\u003c/p\u003e\n"],["\u003cp\u003eAfter deploying and testing the function, the guide provides links to resources to learn how to write, deploy, call, and monitor Cloud Run functions, as well as writing a function from scratch.\u003c/p\u003e\n"]]],[],null,["# Deploy a 1st gen Cloud Run function by using the Google Cloud console\n=====================================================================\n\nCloud Run functions is a serverless execution environment for building and\nconnecting cloud services. With Cloud Run functions you write single-purpose\nfunctions that are attached to events emitted from your cloud infrastructure and\nservices. Your function is triggered when an event being watched is fired, or by\nan HTTP request.\n\nThis page shows how to create and deploy a 1st gen HTTP function using the\nGoogle Cloud console. Note that you can only create new 1st gen functions on\nexisting projects, not new projects. For new projects, see\n[Console Quickstart for Cloud Run functions](/run/docs/quickstarts/functions/deploy-functions-console).\n\n*** ** * ** ***\n\nTo follow step-by-step guidance for this task directly in the\nGoogle Cloud console, click **Guide me**:\n\n[Guide me](https://console.cloud.google.com/freetrial?redirectPath=/functions?walkthrough_id=functions_quickstart)\n\n*** ** * ** ***\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **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.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Functions and Cloud Build APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudfunctions,cloudbuild.googleapis.com&redirect=https://cloud.google.com/functions/1stgendocs/console-quickstart-1st-gen)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **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.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Functions and Cloud Build APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudfunctions,cloudbuild.googleapis.com&redirect=https://cloud.google.com/functions/1stgendocs/console-quickstart-1st-gen)\n\nCreate a function\n-----------------\n\n| **Note:** You can only create new 1st gen functions on existing projects, not new projects.\n\n1. Open the Functions Overview page in the Google Cloud console:\n\n [Go to the Cloud Run functions Overview page](https://console.cloud.google.com/functions/list)\n\n Make sure that the project for which you enabled Cloud Run functions is\n selected. You can only access this link for existing projects. Otherwise,\n you will be redirected to the\n [Cloud Run Google Cloud console](https://console.cloud.google.com/run). To learn how to\n create and deploy functions using the Cloud Run Google Cloud console, see\n [Console Quickstart for Cloud Run functions](/run/docs/quickstarts/functions/deploy-functions-console).\n2. Click **Create function**.\n\n3. Name your function, for example, `function-1`.\n\n The name you give your function can include lowercase letters, numbers, and\n hyphens.\n4. In the **Trigger** field, select **HTTP**.\n\n5. In the **Authentication** field, select **Require Authentication**.\n\n The other option, [**Allow unauthenticated invocations**](/functions/1stgendocs/securing/managing-access-iam#allowing_unauthenticated_http_function_invocation),\n lets you reach the function\n [without authentication](/functions/1stgendocs/securing/managing-access-iam#allowing_unauthenticated_http_function_invocation).\n This is useful for testing, but we don't recommend using this setting in\n production unless you are creating a public API or website. Further, it might\n not work for you, depending on your corporate policy settings. See\n [Authenticating for invocation](/functions/1stgendocs/securing/authenticating) for\n details on how to invoke a function that requires authentication.\n6. Click **Save** to save your changes, and then click **Next**.\n\n7. In the **Source code** field, select **Inline editor**. In this exercise,\n you will use the default \"Hello World\" function provided in the editor.\n\n8. Use the **Runtime** drop-down to select your chosen language runtime.\n\nDeploy the function\n-------------------\n\n1. At the bottom of the page, click **Deploy**.\n\n2. Click the west icon to return to the\n Cloud Run functions Overview page.\n\n While the function is being deployed, the icon next\n to it is a small spinner. After it finishes deploying, the spinner turns to\n a green check mark:\n\nTest the function\n-----------------\n\n1. Display the more_vertmenu for your\n function and select **Test function**.\n\n2. On the testing page, click **Test the function**.\n\n The **Output** screen displays the text \"Hello World!\"\n3. Now change the message. In the **Triggering Event** field, enter the text\n `{\"message\":\"Hello, `\u003cvar translate=\"no\"\u003eYOUR_NAME\u003c/var\u003e`!\"}`, replacing\n \u003cvar translate=\"no\"\u003eYOUR_NAME\u003c/var\u003e with a name, and click **Test the\n function**.\n\n For example, suppose you entered the name \"Rowan\". In the **Output** field,\n you would see the message `Hello, Rowan!`.\n\n In the **Logs** field, a status code of 200 indicates success.\n\nView logs\n---------\n\nCheck the logs to see your actions in the log history:\n\n- On the Cloud Run functions Overview page, display the more_vertmenu for your function and click **View logs**.\n\nYour log history appears.\n\nWhat's next\n-----------\n\n- [Learn how to write a function from scratch](/functions/1stgendocs/create-deploy-http-nodejs-1st-gen).\n- [Learn more about writing Cloud Run functions](/functions/1stgendocs/writing).\n- [Learn more about deploying Cloud Run functions](/functions/1stgendocs/deploy).\n- [Learn more about calling Cloud Run functions](/functions/1stgendocs/calling).\n- [Learn more about monitoring Cloud Run functions](/functions/1stgendocs/monitoring)."]]