- Documentation
Volcano Engine Function as a Service
Best Practices
Data processing
Using veFaaS to read and write the TOS mount directory
Data processing
Using veFaaS to read and write the TOS mount directory
Using veFaaS to read and write the TOS mount directory
Mounting a TOS Bucket on a function enables persistent data storage and sharing across multiple functions. This article introduces how to use the veFaaS to read and write the mounted TOS Bucket.
Mounting a TOS Bucket on a function allows persistent data storage and sharing across multiple functions. In addition, functions can access TOS like a local file system, simplifying resource access and data processing.
- Torch Object Storage (TOS)
- Volcano Engine Torch Object Storage (TOS) is activated.
- A TOS Bucket is created in the region where functions will be deployed. For detailed instructions, see Creating buckets.
warning
To better manage permissions, it is recommended to use IAM user keys with minimal authorization. Avoid using Volcano Engine root user keys or IAM user keys with excessive permissions directly.
- The veFaaS is activated.
Step One: Create a function and mount TOS
- In the top navigation bar, select the target region.
- On the function list page, click Create function and select Create [Event function].
- Enter a function name and notes.
- Code template: Select vefaas-python38-default.
- Enable TOS mount feature for storage configurations, and keep other parameters as default.
- Click Create to create the function.
Step Two: Edit code online
This article uses the following code example to demonstrate to you how to read and write the mounted TOS Bucket.
tip
The code logic is for reference only. Modify the code according to your actual business scenario as needed.
On the Code tab of the current function, click index.py file, overwrite the original content with the following code, and click Save.
Step Three: Release the function
Release the current code and configuration of the function online.
- On the function details page, click Release in the upper right corner.
- Select Latest for the function version. Keep other parameters as default.
- Click OK. Wait until the function release is finished.
- Test the function to verify whether the response result meets expectations.
- On the function details page, click Test in the upper-right corner.
- 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.
- Click Test. Wait for the test results.
- View the instance logs of the function to confirm whether the expected file reading and writing is completed.
- Switch to the Resource management tab.
- In the Instances list, select the running instance, click Logs, and enter the instance logs page.
- When a function has multiple instances, it is recommended to check the logs of each instance to identify the one instance actually handling the request.
- Log in to the TOS console and check whether the output.txt file is written under the corresponding mount directory.
Last updated: 2026.08.19 14:06:07