Building a Program
This section provides the sample code for image rotation.
Creating a Deployment Package
This example uses a Go function to rotate images. For details about function development, see the FunctionGraph Developer Guide. Figure 1 shows the sample code directory. The service code is not described.
Creating a Function
When creating a function, specify an agency with OBS access permissions so that FunctionGraph can invoke the OBS service.
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
Click Create Function.
Set the function information.
After setting the basic information, click Create.
- For Function Type, select Event Function.
- For Function Name: Enter a function name, for example, test-rotate.
- For Agency, select serverless_trust.
- For Runtime, select Go 1.x.
On the details page of function test-rotate, configure the following information:
- On the Code tab, choose Upload > Local ZIP, upload the binary file go-test.zip of the sample code.
- Choose Configuration > Basic Settings, set the following parameters, and click Save.
- For Memory, select 256.
- For Execution Timeout, enter 40.
- For Handler, retain the default value index.handler.
- For App, retain the default value default.
- For Description, enter Image rotation.
- Choose Configuration > Environment Variables, set environment variables, and click Save.
bucket: the bucket parameter defined in handler.go for pulling images. Set the value to your-bucket-output, the bucket created for storing images.
object: the image name parameter defined in handler.go. Set the value to your-picture-name.
obsAddress: the bucket address parameter defined in handler.go for pulling images. Set the value to obs.region.myhuaweicloud.com.
Environment Variable |
Description |
---|---|
bucket |
OBS bucket parameters defined in the handler.go file for pulling images. |
object |
The image name parameter defined in handler.go. |
obsAddress |
The bucket address parameter defined in handler.go for pulling images. The value of obsAddress is in the format of obs.{region}.myhuaweicloud.com. For details about the value of region, see Regions and Endpoints. |
---- End
Creating a Flow
- Return to the FunctionGraph console. Then choose Flows in the navigation pane.
Click Create next to Express Flow.
Figure 2 Creating an express flow
- Drag a function node and click it to configure parameters.
- App: Retain the default value default.
- Function: Select the test-rotate function created in the previous step.
- Version: Retain the default value latest.
- Retain the default values for other parameters.
Figure 3 Configuring function node
Click OK after the parameters are configured.
- After the function flow node is created, click Save in the upper right corner, configure the following basic information, and click OK.
- Name: test-rotate-workflow.
- Enterprise Project: Retain the default value default.
- Logs: Retain the default value ALL.
Retain the default values for other parameters.
Figure 4 Saving a flow
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot