huaweicloud/huaweicloud-skills

huawei-cloud-functiongraph-function-create

Create and invoke FunctionGraph functions on Huawei Cloud.

Zobacz źródło

Jak używać

  1. Skopiuj polecenie instalacji i sprawdź źródła przed instalacją we własnym środowisku agenta.
  2. W oryginale sprawdź wymagane narzędzia, dane dostępowe i obsługiwane środowiska.
  3. Opisz dane wejściowe i oczekiwany rezultat; porównaj wynik ze źródłami.
npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-functiongraph-function-create

Przed rozpoczęciem

  • Instalacja nie obejmuje subskrypcji modelu, limitu API ani uprawnień do plików.
  • Gwiazdki i instalacje pokazują aktywność, a nie niezależny test jakości lub bezpieczeństwa.
Oryginalny dokument Skill

Treść z repozytorium z zachowaniem nagłówków, przykładów, kodu, tabel, linków i obrazów.

FunctionGraph Function Creation & Invocation Skill

Overview

This 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:

  • Quickly create cloud functions without manual console login
  • Batch creation of multiple functions with VPC or environment variable configuration
  • Foundation component for workflow deployment
  • CI/CD integration for function deployment
  • Invoke and test deployed functions

Typical Use Cases:

  1. "Create a Python function named my_handler"
  2. "Deploy this code to FunctionGraph with VPC configuration"
  3. "Create a function with environment variables"
  4. "Invoke the function I just created"

Prerequisites

1. Python Environment

  • Python 3.9+
  • Verify: python --version

2. SDK Installation

bash
pip install huaweicloudsdkfunctiongraph

3. Authentication Configuration

  • Valid Huawei Cloud credentials (AK/SK mode)
  • Configure via environment variables:
bash
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:

  • NEVER expose AK/SK values in code or logs
  • NEVER let users input AK/SK directly in conversation
  • ALWAYS use environment variables for credentials
  • Recommend using IAM user instead of main account

4. IAM Permission Requirements

  • functiongraph:function:create - Create function
  • functiongraph:function:get - Query function details
  • functiongraph:function:list - List functions
  • functiongraph:function:invoke - Invoke function

See IAM Policies for detailed permission configuration.

Workflow

User Request → Parse Parameters → Validate Input
  → Create Function (with optional VPC/Env Vars) → Return Function URN
  → (Optional) Invoke Function → Return Invocation Result

Usage

Create a Function

bash
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"}'

Invoke a Function

Note: The function URN uses the real FunctionGraph URN prefix urn:fss:. Replace PROJECT_ID in the examples below with your actual project ID (the same value as the HUAWEI_PROJECT_ID environment variable). The function package is default and the version is latest (or a specific version/alias). You can copy the URN returned by the create command and append :latest for invocation.
bash
# 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 Confirmation

Create Parameters

ParameterRequired/OptionalDescriptionDefault
--nameRequiredFunction name, must follow naming rules-
--runtimeRequiredRuntime environment (Python3.9, etc.)-
--handlerRequiredFunction entry point (e.g., index.handler)-
--codeRequiredCode file path or inline code content-
--memoryOptionalMemory size in MB128
--timeoutOptionalTimeout in seconds3
--descriptionOptionalFunction description-
--vpc-idOptionalVPC ID for VPC configuration (must be set together with --subnet-id and --security-group-id)-
--subnet-idOptionalSubnet ID for VPC configuration (must be set together with --vpc-id and --security-group-id)-
--security-group-idOptionalSecurity group ID for VPC configuration (must be set together with --vpc-id and --subnet-id)-
--env-varsOptionalEnvironment variables as JSON string-

Invoke Parameters

ParameterRequired/OptionalDescriptionDefault
--function-urnRequiredFunction URN to invoke-
--bodyOptionalEvent payload as JSON string{}
--invocation-typeOptionalsync or asyncsync
--log-typeOptionaltail to return last 4KB log-

Runtime Options

RuntimeHandler FormatExample
Python3.9index.handlerdef handler(event, context):
Node.js14.18index.handlerexports.handler = (event, context) => {}
Java8com.example.Handler::handleRequestJava class method
Go1.xhandlerGo function name

Verification Method

See Verification Method for detailed procedures.

Quick Verification

python
# 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)}")

Output Format

Create Output

The script returns a structured JSON object:

json
{
  "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"
}

Invoke Output

json
{
  "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"
}

Best Practices

  1. Test before production: Always test in a development environment first
  2. Monitor resources: Set up monitoring for function invocations and errors
  3. Use environment variables: Store sensitive data in environment variables
  4. Implement error handling: Add proper error handling in function code
  5. Set appropriate timeouts: Configure timeout based on function logic
  6. VPC for private resources: Use VPC configuration when functions need access to private network resources

Error Handling

Error CodeDescriptionResolution
InvalidParameterInvalid input parametersCheck parameter format and values
InsufficientPermissionInsufficient permissionsCheck IAM permissions
QuotaExceededResource quota exceededRequest quota increase or delete unused functions
FunctionAlreadyExistsFunction with same name existsUse different function name or delete existing function
FunctionNotFoundFunction URN not found (invoke)Verify the function URN is correct

References

z tego samego repozytorium

Więcej Skills

Wszystkie Skills
huaweicloud
Społeczność

huawei-cloud-billing-scout

Huawei Cloud BSS billing (not AWS/Azure/other clouds; refuses pricing quotes, real-name review, and any non-billing scope): balance, spend, attribution, reconciliation, coupons, stored-value cards, enterprise/partner billing. One-page briefing via hcloud. Use only when the user explicitly mentions 华为云 / Huawei Cloud / BSS and 余额/账单/对账/资源包/代金券/储值卡/企业或伙伴账务; refuses pay, renew, refund, delete.

Instalacje / 1h
2
GitHub Stars
59
Aktualizacja
3 lis
huaweicloud
Społeczność

huawei-cloud-cci-instance-management

Huawei Cloud CCI (Cloud Container Instance) full lifecycle management using hcloud CLI. Covers Namespace, Network, Deployment, StatefulSet, Pod creation/update/delete/status, EIPPool for public IP, logs and metrics. Two-step confirmation for all destructive operations (delete namespace cascades all resources under it). Use this skill when the user wants to operate CCI serverless containers via command line. Triggers: CCI, 云容器实例, serverless container, 容器实例, namespace, deployment, statefulset, pod

Instalacje / 1h
2
GitHub Stars
59
Aktualizacja
3 lis
huaweicloud
Społeczność

huawei-cloud-computing-query

Queries Huawei Cloud computing resources (ECS/BMS/IMS/AS), Covers ECS instances, flavors, keypairs, quotas, server groups, block devices, NICs, VNC console, BMS bare metal servers/flavors/quotas, IMS images/OS versions/members/quotas, and AS scaling groups/configs/policies/activity logs/lifecycle hooks/warm pools/quotas. No write operations. Use this skill when the user needs to query ECS instance details, list flavors, check BMS availability, browse images, or view auto-scaling group/policy sta

Instalacje / 1h
2
GitHub Stars
59
Aktualizacja
3 lis
huaweicloud
Społeczność

huawei-cloud-find-skills

Invoke this skill to search, list, query, discover, browse, find and install any Huawei Cloud (华为云) agent skill. Triggers include: "华为云", "华为云有什么skill", "华为云相关skill", "华为云agent skill 市场", "华为云skill类目", "explore Huawei Cloud skills", "show Huawei Cloud skill categories", "does a Huawei Cloud skill exist for...", "which Huawei Cloud skills exist", "搜索华为云技能", "查询华为云skill列表", "有没有管理ECS/OBS/RDS的skill", "帮我找 XX 华为云skill", "介绍 XX Skill 内容", "华为云 XX Skill 具体做什么", "安装华为云Skill".

Instalacje / 1h
2
GitHub Stars
59
Aktualizacja
3 lis