Install
openclaw skills install @huaweicloudskill/huawei-cloud-functiongraph-function-createCreate and invoke FunctionGraph functions on Huawei Cloud. Supports VPC configuration, environment variables, synchronous and asynchronous function invocation. Use this skill when users ask to create, deploy, upload, or invoke cloud functions, serverless functions, or FunctionGraph functions. Triggered by keywords like "create function", "deploy function", "upload function", "invoke function", "create cloud function", "创建函数", "部署函数", "上传函数", "调用函数", "创建云函数", "FunctionGraph function", "serverless function", "function invocation".
openclaw skills install @huaweicloudskill/huawei-cloud-functiongraph-function-createThis skill manages FunctionGraph functions on Huawei Cloud, supporting creation with advanced configuration (VPC, environment variables) and function invocation (sync/async).
Architecture: Uses Huawei Cloud FunctionGraph Python SDK to interact with FunctionGraph service.
Applicable Scenarios:
Typical Use Cases:
python --versionpip install huaweicloudsdkfunctiongraph
export HUAWEI_AK="your-access-key"
export HUAWEI_SK="your-secret-key"
export HUAWEI_REGION="cn-north-4"
export HUAWEI_PROJECT_ID="your-project-id"
Security Rules:
functiongraph:function:create - Create functionfunctiongraph:function:get - Query function detailsfunctiongraph:function:list - List functionsfunctiongraph:function:invoke - Invoke functionSee IAM Policies for detailed permission configuration.
User Request → Parse Parameters → Validate Input
→ Create Function (with optional VPC/Env Vars) → Return Function URN
→ (Optional) Invoke Function → Return Invocation Result
cd scripts
# Basic creation
python create_function.py create \
--name my_function \
--runtime Python3.9 \
--handler index.handler \
--code main.py
# With VPC configuration
python create_function.py create \
--name my_function \
--runtime Python3.9 \
--handler index.handler \
--code main.py \
--vpc-id vpc-xxx \
--subnet-id subnet-xxx \
--security-group-id sg-xxx
# With environment variables
python create_function.py create \
--name my_function \
--runtime Python3.9 \
--handler index.handler \
--code main.py \
--env-vars '{"DB_HOST":"localhost","DB_PORT":"3306"}'
# Full configuration
python create_function.py create \
--name my_function \
--runtime Python3.9 \
--handler index.handler \
--code main.py \
--memory 256 \
--timeout 30 \
--description "My production function" \
--vpc-id vpc-xxx \
--subnet-id subnet-xxx \
--security-group-id sg-xxx \
--env-vars '{"DEBUG":"true","LOG_LEVEL":"info"}'
Note: The function URN uses the real FunctionGraph URN prefix
urn:fss:. ReplacePROJECT_IDin the examples below with your actual project ID (the same value as theHUAWEI_PROJECT_IDenvironment variable). The function package isdefaultand the version islatest(or a specific version/alias). You can copy the URN returned by thecreatecommand and append:latestfor invocation.
# Synchronous invocation (default)
python create_function.py invoke \
--function-urn urn:fss:cn-north-4:PROJECT_ID:function:default:my_function:latest \
--body '{"key1":"value1","source":"test"}'
# Asynchronous invocation
python create_function.py invoke \
--function-urn urn:fss:cn-north-4:PROJECT_ID:function:default:my_function:latest \
--body '{"async":true}' \
--invocation-type async
# Invoke with log tail (returns last 4KB of log)
python create_function.py invoke \
--function-urn urn:fss:cn-north-4:PROJECT_ID:function:default:my_function:latest \
--body '{"test":"data"}' \
--log-type tail
| Parameter | Required/Optional | Description | Default |
|---|---|---|---|
--name | Required | Function name, must follow naming rules | - |
--runtime | Required | Runtime environment (Python3.9, etc.) | - |
--handler | Required | Function entry point (e.g., index.handler) | - |
--code | Required | Code file path or inline code content | - |
--memory | Optional | Memory size in MB | 128 |
--timeout | Optional | Timeout in seconds | 3 |
--description | Optional | Function description | - |
--vpc-id | Optional | VPC ID for VPC configuration (must be set together with --subnet-id and --security-group-id) | - |
--subnet-id | Optional | Subnet ID for VPC configuration (must be set together with --vpc-id and --security-group-id) | - |
--security-group-id | Optional | Security group ID for VPC configuration (must be set together with --vpc-id and --subnet-id) | - |
--env-vars | Optional | Environment variables as JSON string | - |
| Parameter | Required/Optional | Description | Default |
|---|---|---|---|
--function-urn | Required | Function URN to invoke | - |
--body | Optional | Event payload as JSON string | {} |
--invocation-type | Optional | sync or async | sync |
--log-type | Optional | tail to return last 4KB log | - |
| Runtime | Handler Format | Example |
|---|---|---|
| Python3.9 | index.handler | def handler(event, context): |
| Node.js14.18 | index.handler | exports.handler = (event, context) => {} |
| Java8 | com.example.Handler::handleRequest | Java class method |
| Go1.x | handler | Go function name |
See Verification Method for detailed procedures.
# Verify function exists using SDK
from huaweicloudsdkfunctiongraph.v2.functiongraph_client import FunctionGraphClient
from huaweicloudsdkfunctiongraph.v2.model import ListFunctionsRequest
# List functions to verify creation
client = FunctionGraphClient.new_builder().build()
request = ListFunctionsRequest()
response = client.list_functions(request)
print(f"Total functions: {len(response.functions)}")
The script returns a structured JSON object:
{
"status": "success",
"function_urn": "urn:fss:cn-north-4:project_id:function:default:my_function",
"function_name": "my_function",
"runtime": "Python3.9",
"memory_size": 128,
"timeout": 3,
"handler": "index.handler",
"code_size": 1234,
"message": "Function created successfully"
}
{
"status": "success",
"function_urn": "urn:fss:cn-north-4:project_id:function:default:my_function",
"invocation_type": "sync",
"result": {
"output": "..."
},
"request_id": "a1b2c3d4-...",
"message": "Function invoked successfully"
}
| Error Code | Description | Resolution |
|---|---|---|
| InvalidParameter | Invalid input parameters | Check parameter format and values |
| InsufficientPermission | Insufficient permissions | Check IAM permissions |
| QuotaExceeded | Resource quota exceeded | Request quota increase or delete unused functions |
| FunctionAlreadyExists | Function with same name exists | Use different function name or delete existing function |
| FunctionNotFound | Function URN not found (invoke) | Verify the function URN is correct |