You can use Java to write functions in a custom container of Function Compute. This topic describes how to deploy and invoke a Java function. You can also modify the Spring Boot sample code as needed for custom development.
- Run the following command in the specified directory to initialize a project:
s init start-fc-custom-container-http-springboot -d start-cc-http-springbootNote
-dspecifies the name of the folder in which the sample project resides. You can customize the folder name as required.
- Run the following command to go to the project directory:
- Optional: Modify the sample code as needed for custom development.
- Modify the s.yaml file. Change the value of the
imagefield in the s.yaml file to your image name.
- Run the following command to deploy the project:
s deploy -ySample command output:
[2022-02-09 07:04:36] [INFO] [S-CLI] - Start the pre-action ...... helloworld: region: cn-hangzhou service: name: hello-world-service function: name: springboot-http-function runtime: custom-container handler: not-used memorySize: 256 timeout: 60 url: system_url: https://188077086902****.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/hello-world-service/springboot-http-function/ custom_domain: - domain: http://springboot-http-function.hello-world-service.188077086902****.cn-hangzhou.fc.devsapp.net triggers: - type: http name: httpTrigger
After the project is deployed, you can view the temporary domain name that is generated by Function Compute in the output. The temporary domain name can be used to access the newly deployed application. For example, run the following command to access the application: