You can use the Custom Runtime of Function Compute to write functions in PowerShell. This topic describes how to quickly deploy and call a PowerShell function.


You have installed Node.js 8.6.0 or later versions. For more information, see official download address.
Note If you have installed Funcraft, go to Step 2: Deploy and call a function.

Step 1: Prepare the environment

An easy and simple way to install Funcraft is to download the executable binary files.

  1. Install Funcraft on the local machine. For more information, see installation instructions.
  2. Run fun --version to check whether the installation is successful.
  3. Run fun config to configure Funcraft. Then configure Account ID, Access Key ID, Access Key Secret, and Default region name as prompted.
    $ fun config
    Aliyun Account ID 1234xxx
    Aliyun Access Key ID xxxx
    Aliyun Access Key Secret xxxx
    Default region name cn-xxxx
    The timeout in seconds for each SDK client invoking 300
    The maximum number of retries for each SDK client 5
    Allow to anonynously report usage statistics to improve the tool over time? (Y/n)

Step 2: Deploy and call a function

  1. Run the following command to clone the sample project to your local machine.
    git clone https://          
    Note If you do not have git installed, enter in the address bar of your browser. Click the download button to download directly.
  2. Run the following command to access the cloned sample project:
    cd fc-custom-demo
    cd powershell-demo       
  3. Use the following command to install dependencies:
    fun install -v   
    The following result is returned:
    start installing function dependencies without docker
    building powershell-demo/fc-powershell
    Funfile exist, Fun will use container to build forcely
    Step 1/7 : FROM
    Step 7/7 : RUN fun-install apt-get install powershell
    Successfully built 7c6476a3a449
    Successfully tagged fun-cache-965bbabb-ab6f-44e7-9910-7dd1df1d3c3e:latest
    copying function artifact to /Users/songluo/gitpro/fc-custom-demo/powershell-demo
    copy from container /mnt/auto/. to localNasDir
    Install Success  
  4. Run the following command to deploy the project to Function Compute:
    fun deploy -y      
    The following result is returned:
    ? Do you want to let fun to help you automate the configuration? Yes
    ? You have already configured 'NasConfig: Auto'. We want to use this configuration to store your function dependencies. Yes
    Fun automatically backups the original template.yml file to /Users/txd123/Desktop/jack/fc-custom-demo/powershell-demo/.template.yml.backup
    Fun add .fun/root to /Users/txd123/Desktop/jack/fc-custom-demo/powershell-demo/.nas.yml
    Fun add environment variables to 'powershellDemo/fc-powershell' in /Users/txd123/Desktop/jack/fc-custom-demo/powershell-demo/template.yml
    starting upload /Users/txd123/Desktop/jack/fc-custom-demo/powershell-demo/.fun/root to nas://powershellDemo/mnt/auto/root/
    start fun nas init...
    fun nas init Success
    zipping /Users/txd123/Desktop/jack/fc-custom-demo/powershell-demo/.fun/root
    ✔ upload done
    unzipping file
    ✔ unzip done
    ✔ upload completed!
    ? Region cn-qingdao only supports capacity NAS. Do you want to create it automatically? Yes
        Waiting for function fc-powershell to be deployed...
            Waiting for packaging function fc-powershell code...
            The function fc-powershell has been packaged. A total of 3 files were compressed and the final size was 1.31 KB
        function fc-powershell deploy success
        function fc-powershell deploy success
    service powershellDemo deploy success
  5. Run the following command to call the deployed function:
    fun invoke -e "Hello World"          
    The following result is returned:
    ========= FC invoke Logs begin =========
    FC Invoke Start RequestId: cd30369e-7dfa-439c-a68d-7fe16d5a7e05
    Hello World
    FC Invoke End RequestId: cd30369e-7dfa-439c-a68d-7fe16d5a7e05
    Duration: 54.13 ms, Billed Duration: 100 ms, Memory Size: 512 MB, Max Memory Used: 133.70 MB
    ========= FC invoke Logs end =========
    FC Invoke Result:
    Hello World