โ๏ธ Running a function in the cloud
- Being logged in
- Being in the directory of the function
- Enough quota
Deployโ
First, the function needs to be deployed with the following command
gccli fx deploy
$ gccli fx deploy
๐ท Verifying configuration...
๐ฆ๏ธ Archs: AMD64,ARM64,ARM
๐ฉ Building container image...
โณ๏ธ Process may take a while, please wait...
๐งฉ Compiling multi-arch image [OK]
๐ Pushing image to registry...
๐ฅ Function successfully uploaded!
$ โ
Run via public endpointโ
The function needs a public endpoint to be called remotely with the following command
gccli fx public
$ gccli fx public
๐ท Validating inputs...
๐จ You must keep the public endpoint safe!
๐ Any existing endpoint will be revoked
โ Do you accept conditions? (y/n) โ y
๐ค Public endpoint created successfully!
๐ https://api.greencloud.dev/gc/d322e8a50390418e83f15daa2bea32fb
$ โ
Navigating to the link will get the dispatcher to queue the function to be run and will return a task ID.
The result will be available for the next 5 minutes at the link below..
https://api.greencloud.dev/gc/6408becf1815ce1e1d877349/result
You may now navigate to https://api.greencloud.dev/gc/[taskId]/result to get the result of the function. If the function run hasn't been completed yet, you will get a 404 response. You may need to poll the link multiple times until you get the response.
Run via CLIโ
You may also invoke the function from the CLI with the following command gccli fx invoke. You will be asked to provide an optional payload. This will give you a task ID that you can later use to get the response of this function.
$ gccli fx invoke
๐ท Validating inputs...
๐ Obtaining local information...
โ Timeout โ 10
๐ Payload โ Hello from GreenCloud!
๐ Invoking function...
๐ ID: 6408a30b1815ce1e1d87731a
๐ป Waiting for task to output...
๐งพ 200 โ Hello from GreenCloud!
$ โ
Get function resultโ
We may look up the result of a previously run function by the ID that was given during the invocation. Let's use the ID from the previous example to get the result of the function once again with the command gccli fx result . Enter the task ID when prompted.
$ gccli fx result
๐ท Validating inputs...
๐ ID โ 6408a30b1815ce1e1d87731a
๐ป Waiting for task to output...
๐งพ 200 โ Hello from GreenCloud!
$ โ