ກ່ຽວກັບ
A function is one handler: you write it, and we add a small runtime that serves it over HTTP, build it and run it like a Container that stops when idle. The same code shows in the Console’s editor, so you can edit it there or locally: th functions pull fetches what the Console saved and th functions deploy sends your folder back.
| Runtimes | Main file | Handler |
|---|---|---|
python314, python313 (recommended), python312, python311 | main.py (+ requirements.txt) | def main(request) returning a str, dict (JSON) or (body, status, headers) |
nodejs24 (recommended), nodejs22 | index.ts or index.js (+ package.json) | export async function handler(req: Request) returning a Response, string or object |
go126 (recommended), go125 | *.go + go.mod | func Handle(w http.ResponseWriter, r *http.Request) |
A function has at most 100 text files, 512 KiB each and 2 MiB in all. Files in .thignore (else .dockerignore, else .gitignore), .git, node_modules, .venv, __pycache__ and dist are left out, and a Dockerfile is ignored. Builds are billed like Container builds. To run it on a schedule or for every queue message, add a trigger with th triggers.
ວິທີເຮັດ
Deploy a function from a folder
mkdir hello && cd hello
printf 'def main(request):\n return {"message": "Hello, " + request.args.get("name", "World")}\n' > main.py
th functions deploy hello --env GREETING=hi
th functions call hello --path "/?name=Thai"The first deploy creates the function; its runtime comes from the files (or --runtime). th waits for the build and prints the URL. --async returns once the build is queued.
Go back to an earlier version
th functions versions list hello
th functions versions activate hello 12
th functions pull hello --version 12 --dir hello-v12Every deploy is a version, and the latest 30 are kept. Activating one serves it again with today’s settings and variables; if its image was cleaned up, its code is built again as a new version. --runtime on a deploy moves the function to another version of its language, e.g. --runtime python314.
Run a function only from its triggers
th functions deploy nightly-report --ingress triggers
th triggers create nightly --service nightly-report --schedule "0 3 * * *"With --ingress triggers the function has no endpoint at all: no public URL, no custom domain and no address inside the project’s VPC. Only its Cron and Queue triggers reach it, and th triggers run runs one now. --ingress all opens it again.
Edit in the Console, then work locally
th functions pull hello --dir hello
# edit the files
th functions deploy hello --source hellopull keeps local files that differ unless you pass --force.
ຄຳສັ່ງ
| ຄຳສັ່ງ | ຄຳອະທິບາຍ |
|---|---|
th functions deploy | Uploads the files of DIR (default .) as the function's code, builds them and serves the result. |
th functions list | Lists the functions of the active Project. |
th functions describe | Shows a function's runtime, deploy state, settings and files. |
th functions pull | Writes the function's saved code (what the Console editor shows), or the code of one version, into DIR (default ./NAME). |
th functions call | Sends one request to the function and prints the answer. |
th functions logs | Prints the latest log lines of a function (what the handler printed). |
th functions versions list | Lists a function's versions, newest first. |
th functions versions activate | Serves an earlier version again; today's settings and variables stay. |
th functions runtimes | Lists the runtimes a function can use and the handler each expects. |
th functions delete | Deletes a function with its code, triggers and revisions. |
th functions deploy
Uploads the files of DIR (default .) as the function's code, builds them and serves the result.
ຮູບແບບຄຳສັ່ງ
th functions deploy NAME [--source DIR] [flags]A new function is created first; its runtime comes from --runtime or from the files (go.mod: Go, package.json / index.ts: Node.js, main.py / requirements.txt: Python).
Files listed in .thignore (or .dockerignore / .gitignore), .git, node_modules, .venv, __pycache__ and dist are left out. A Dockerfile is ignored: functions always build with the platform's runtime.
--runtime takes a runtime (python313, nodejs24, go126) or a language (python, nodejs, go: its recommended version). An existing function may move to another version of its language.
Every deploy is kept as a version (th functions versions list); --message describes it. --ingress sets who reaches the function: all (the internet, the default), internal (other services in its project) or triggers (no endpoint at all; only its Cron and Queue triggers run it). --env, --set-env-vars and --secret-env replace every variable of the function; without them the current variables stay. Settings given for an existing function (--cpu, --memory, --min-instances, ...) are applied before its code is built.
ຕົວຢ່າງ
th functions deploy helloth functions deploy hello --runtime python314 --message "Python 3.14"th functions deploy orders --source ./orders --memory 512Mi --max-instances 10th functions deploy nightly-report --ingress triggersອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
ພາຣາມິເຕີ
| ຊື່ | ປະເພດ | ຄ່າເລີ່ມຕົ້ນ | ຄຳອະທິບາຍ |
|---|---|---|---|
--source | ຂໍ້ຄວາມ | . | Directory with the function's files |
--runtime | ຂໍ້ຄວາມ | Runtime (e.g. python313, nodejs24, go126) or language (python, nodejs, go) | |
--entry-point | ຂໍ້ຄວາມ | the runtime's, e.g. main, handler, Handle | Handler name |
--cpu | ຂໍ້ຄວາມ | vCPU, e.g. 0.25, 0.5, 1 (a size of the Container menu) | |
--memory | ຂໍ້ຄວາມ | Memory, e.g. 256Mi, 512Mi, 1Gi | |
--compute-class | ຂໍ້ຄວາມ | Compute class of a new function | |
--env | ລາຍການ | Environment variable KEY=VALUE (repeatable) | |
--set-env-vars | ລາຍການ | Environment variables KEY=VALUE,KEY2=VALUE2 | |
--secret-env | ລາຍການ | Secret environment variable KEY=VALUE (repeatable) | |
--min-instances | ຕົວເລກ | Minimum instances (0 stops it when idle) | |
--max-instances | ຕົວເລກ | Maximum instances | |
--timeout | ຂໍ້ຄວາມ | Request timeout, e.g. 60s or 5m | |
--concurrency | ຕົວເລກ | Requests at once per instance (1-1000) | |
--cpu-always-allocated | ແຟລັກ | Keep CPU between requests | |
--allow-unauthenticated | ແຟລັກ | for a new function; --no-allow-unauthenticated needs an invoker token | Allow public calls |
--ingress | ຂໍ້ຄວາມ | Who reaches the function: all, internal or triggers (no endpoint, triggers only) | |
--message | ຂໍ້ຄວາມ | Describe this version | |
--async | ແຟລັກ | Return once the build is queued |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions list
Lists the functions of the active Project.
ຮູບແບບຄຳສັ່ງ
th functions listພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions describe
Shows a function's runtime, deploy state, settings and files.
ຮູບແບບຄຳສັ່ງ
th functions describe NAMEອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions pull
Writes the function's saved code (what the Console editor shows), or the code of one version, into DIR (default ./NAME).
ຮູບແບບຄຳສັ່ງ
th functions pull NAME [--dir DIR] [--version N] [--force]An existing file with other content is kept unless --force.
ອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
ພາຣາມິເຕີ
| ຊື່ | ປະເພດ | ຄ່າເລີ່ມຕົ້ນ | ຄຳອະທິບາຍ |
|---|---|---|---|
--dir | ຂໍ້ຄວາມ | ./NAME | Directory to write into |
--version | ຂໍ້ຄວາມ | the saved code | A version from th functions versions list |
--force | ແຟລັກ | Overwrite files that differ |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions call
Sends one request to the function and prints the answer.
ຮູບແບບຄຳສັ່ງ
th functions call NAME [--data BODY|@FILE] [--method POST] [--path /x] [--token TOKEN]With --data the method defaults to POST, otherwise GET. --token is the invoker token of a function that does not allow unauthenticated calls.
ອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
ພາຣາມິເຕີ
| ຊື່ | ປະເພດ | ຄ່າເລີ່ມຕົ້ນ | ຄຳອະທິບາຍ |
|---|---|---|---|
--data | ຂໍ້ຄວາມ | Request body, or @FILE to read it from a file | |
--method | ຂໍ້ຄວາມ | HTTP method | |
--path | ຂໍ້ຄວາມ | / | Path to call |
--token | ຂໍ້ຄວາມ | Invoker token |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions logs
Prints the latest log lines of a function (what the handler printed).
ຮູບແບບຄຳສັ່ງ
th functions logs NAME [--lines N]ອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
ພາຣາມິເຕີ
| ຊື່ | ປະເພດ | ຄ່າເລີ່ມຕົ້ນ | ຄຳອະທິບາຍ |
|---|---|---|---|
--lines | ຕົວເລກ | 100 | Number of lines (default 100) |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions versions list
Lists a function's versions, newest first.
ຮູບແບບຄຳສັ່ງ
th functions versions list NAMEEvery deploy is a version; the serving one is marked. The latest 30 are kept.
ອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions versions activate
Serves an earlier version again; today's settings and variables stay.
ຮູບແບບຄຳສັ່ງ
th functions versions activate NAME VERSIONWhen the registry no longer holds its image, its code is built again as a new version and served once the build succeeds.
ຕົວຢ່າງ
th functions versions activate hello 12th functions versions activate hello v12ອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
VERSIONຕ້ອງໃສ່ |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions runtimes
Lists the runtimes a function can use and the handler each expects.
ຮູບແບບຄຳສັ່ງ
th functions runtimesພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet
th functions delete
Deletes a function with its code, triggers and revisions.
ຮູບແບບຄຳສັ່ງ
th functions delete NAME [--quiet]--quiet skips the prompt.
ອາກິວເມັນຕາມຕຳແໜ່ງ
| ຊື່ | ຄຳອະທິບາຍ |
|---|---|
NAMEຕ້ອງໃສ່ | The function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug. |
ພາຣາມິເຕີທົ່ວໄປ
ຄຳສັ່ງນີ້ຮັບ ພາຣາມິເຕີທົ່ວໄປ ໄດ້ນຳ: --project, --region, --endpoint, --format, --quiet