You can use the custom runtime of Function Compute to write functions in Function Compute by using PowerShell 7.1. This topic describes how to deploy and invoke a PowerShell function. You can modify the PowerShell sample code as needed for custom development.


  1. Run the following command to initialize a project:
    s init fc-custom-powershell-event -d fc-custom-powershell-event
    Note -d specifies the name of the folder in which the sample project resides. You can customize the folder name as required.
  2. Run the following command to go to the project directory:
    cd fc-custom-powershell-event
  3. Optional: Modify the sample code as needed for custom development.
  4. Run the following command to deploy the project:
    s deploy -y
    Sample command output:
     Checking Service, Function (1.14s)
     Creating Service, Function (0.54s)
    Tips for next step
    * Display information of the deployed resource: s info
    * Display metrics: s metrics
    * Display logs: s logs
    * Invoke remote function: s invoke
    * Remove Service: s remove service
    * Remove Function: s remove function
    * Remove Trigger: s remove trigger
    * Remove CustomDomain: s remove domain
      region:   cn-hangzhou
        name: hello-world-service
        name:       powershellEventFunc
        runtime:    custom
        handler:    index.handler
        memorySize: 512
        timeout:    3
  5. Run the following command to remotely invoke the function:
    s invoke -e "hello"
    Sample command output:
    ========= FC invoke Logs begin =========
    FC Invoke Start RequestId: b3f20880-0dc1-4173-a190-04489b9c****
    FC Invoke End RequestId: b3f20880-0dc1-4173-a190-04489b9c****
    Duration: 51.31 ms, Billed Duration: 52 ms, Memory Size: 512 MB, Max Memory Used: 102.37 MB
    ========= FC invoke Logs end =========
    FC Invoke Result:
    End of method: invoke