Apsara File Storage NAS (NAS) is a distributed file system that offers secure, reliable, unlimited-capacity, high-performance, and easy-to-use file storage services for compute nodes, such as Elastic Compute Service (ECS), Elastic High Performance Computing (E-HPC), Docker, and Batch Compute.
Alibaba Cloud Function Compute supports seamless integration with NAS. This allows your functions to access files on a NAS file system as they do on the local file system. You only need to configure NAS for a specified service, including the region, mount point, and group. After you configure NAS, all functions of this service can access files on the specified NAS file system as they do on the local file system.
- Temporary files can be stored on a NAS file system, and the file size is not limited.
- Multiple functions can use one NAS file system to share files.
The NAS configuration is set on the service level. After a NAS mount target is configured for a service, all functions of the service can access files in the specified NAS file system.
- Log on to the Function Compute console.
- In the top navigation bar, select your region.
- In the left-side navigation pane, click Service/Function.
- In the service list, click the name of the target service.
- In the NAS File System section, set parameters and click Submit.
Parameter Description Remarks UserId Enter a custom user ID. For more information, see NAS users and user groups. GroupId Enter a custom group ID. NAS Mount Point Select a created NAS mount target. For more information, see Mount target configuration. Remote Path Enter a remote directory. Local Mount Path Enter a local directory.
NAS users and user groups
When you configure a NAS mount target for a function, you must first set the UserId and GroupId parameters, which are equivalent to the user and user group in NAS. You must set the file owner and the corresponding group permissions as needed to ensure the consistency of read and write permissions on files.
The values of UserId and GroupId range from -1 to 65534, excluding 0. Function Compute does not allow access from root users, which ensures the execution security. The value -1 is the default value. The UserId and GroupId parameters are optional. If you do not set the UserId parameter, the system uses the default value -1. If you do not set the GroupId parameter, the system uses the UserId value as the GroupId value.
We recommend that you set UserId and GroupId to specific values (numbers ranging from 1 to 65534) so that all functions of the service can share these files.
Mount target configuration
Add nasMountConfig, indicating the mount target configuration, in the second part of the NAS configuration. A maximum of five NAS mount targets can be configured for a service.
Each nasMountConfig consists of a ServerAddr (remote directory) and a MountDir (local directory). A local directory in the local file system is mapped to a remote directory in a NAS file system.
ServerAddr specifies a directory that the service needs to visit in a NAS file system, which consists of a mount target and the absolute directory. You can add mount targets in the NAS console. You can assemble a mount target and the absolute directory into a remote directory. For example, if the mount target of a NAS file system is xxxx-nas.aliyuncs.com and the absolute directory to be accessed is /workspace/document, the full remote directory is xxxx-nas.aliyuncs.com:/workspace/document.
Log on to the NAS console. In the left-side navigation pane, click File System List. On the File System List page, find the target file system and click Management in the Operations column. In the left-side navigation pane, click Mounting Use. On the Mount Target page, view the mount target information.
MountDir specifies a mount target in the local file system. Do not use common directories in the Linux or UNIX system, such as bin, opt, var, and dev, to mount NAS file systems. Function Compute allows you to use non-system directories such as mnt and home to mount NAS file systems.