You need to enable JavaScript to run this app.
Volcano Engine Function as a Service

Volcano Engine Function as a Service

Copy page
Download PDF
Data processing
Using Function as a Service to read and write NAS file system
Copy page
Download PDF
Using Function as a Service to read and write NAS file system
Mounting a NAS file system on a function enables persistent data storage and sharing among multiple functions. This topic introduces how to use Volcano Engine Function as a Service to read and write the NAS file system.​
Background information ​
This article uses the following example code package to demonstrate to you how to read from and write into a FileNAS filesystem. The core logic of the code is: When receiving HTTP trigger request, the function records the request ID in a .txt file, writes it in the mounted NAS file system, and returns all received request IDs along with the current request ID.​
​
​
vefaas-golang-nas-sample.zip
​
​
tip​
This code logic is for reference only. Please modify it as needed according to your business scenario when actually using it.​
Prerequisites​
  • For Virtual Private Cloud (VPC)​
  • Permission for using Volcano Engine Virtual Private Cloud has been obtained.​
  • NAS file storage​
  • Permission for using Volcano Engine NAS has been obtained.​
  • A NAS file system has been created in the region where the function is to be deployed. For details, see Creating file systems.​
  • A mount point has been created in the VPC. For detailed operation, refer to Creating Mount Point.​
  • Function as a Service​
  • The veFaaS is activated.​
Procedure​
Step One: Create the function and mount NAS​
  1. Log in to the veFaaS console.​
  1. In the top navigation bar, select the target region.​
  1. On the Function list page, click Create function, then select Create [Event function].​
  • Basic configuration​
  • Enter a function name and notes.​
  • Function code​
  • Runtime: Select Golang.​
  • Code template: Select vefaas-golang-default.​
  • Advanced configuration​
  • Configure VPC access and storage and keep other options unchanged.​
  • VPC access​
  • Configure the Virtual Private Cloud, subnet, and security groups to be bound to the function. The VPC configured for the function must match the VPC of the NAS mount point.​
  • Storage configuration​
  • Configure the NAS file system, mount point, remote directory, and local directory.​
  • NAS file system: Select a NAS file system of the same region.​
  • Mount point: select the NAS mount point that is located in the same VPC as the function.​
  • Remote directory: configure the remote directory to be accessed on the NAS. For example /doc-nas-1.​
  • Local directory: Configure the local directory for the function operation environment. This example is: /mnt/nas1.​
  1. Click Create to complete function creation.​
Step Two: Upload the code package and configure environment variables​
  1. Upload the code package​
  • On the code tab of the current function, click Upload to upload the example code package provided in the Background information.​
  1. Configure environment variables​
  1. Switch to the Basic information tab of the current function.​
  1. Click the Edit icon next to the configuration information to configure environment variables for the function: NAS_LOCAL_PATH:{the local directory corresponding to the NAS mount point}. This example is NAS_LOCAL_PATH:/mnt/nas1.​
tip​
In this sample code, Function as a Service obtains the local directory of the NAS file system of the current function configuration through NAS_LOCAL_PATH.​
Step Three: Release the function​
Release the current code and configuration of the function online.​
  1. On the function details page, click Release in the upper-right corner.​
  • Select Latest for the function version. Keep other parameters as default.​
  1. Click OK. Wait until the function release is finished.​
Validating results​
  1. Test the function to verify whether the response result meets expectations.​
  1. On the function details page, click Test in the upper-right corner.​
  1. On the pop-up function test page, configure the Trigger type and test request.​
  • Trigger type: Select API Gateway Trigger.​
  • Test request: Keep the default.​
  1. Click Test. Wait for the test result. As shown in the figure: The function returned all received request IDs and the current request ID as expected.​
  1. Log in to the function instance through Webshell to check whether a txt file named with the request ID is written in the local directory.​
  1. Switch to the Resource management tab.​
  1. In the instance list, select any running instance, click Webshell, and log in to the current instance.​
  1. Enter the local directory corresponding to the NAS mount point (This example is /mnt/nas1). You can see multiple txt files named with request IDs are written in the directory as expected.​
tip​
This sample code generates a .txt file named after the request ID each time a request is received. Since this example performs 7 function tests, there are a total of 7 files in the directory.​
Last updated: 2026.08.19 14:06:07