Updated on 2025-08-07 GMT+08:00

Creating a Function

  1. Download the image compression program package. For details, see Compressing Images Using a Function.
  2. Create a function. (Specify an agency with OBS access permissions so that FunctionGraph can invoke the OBS service.)

    1. Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
    2. Click Create Function.
    3. Set the function information and click Create Function. For details, see Creating a Function.
    4. Click the created function.
      • On the Code tab, choose Upload > Local ZIP, upload the program package.
      • Choose Configuration > Environment Variables, set environment variables, and click Save.
        Table 1 Parameter description

        Parameter

        Description

        obs_endpoint

        The bucket address parameter defined in index.py. Set the value to obs.region.myhuaweicloud.com.

        output_bucket

        The output bucket parameter defined in index.py. Set the value to your-bucket-output, the bucket created in Creating OBS Buckets.

  3. Add a dependency.

    The sample code depends on the Pillow package, which needs to be imported as a dependency. The procedure is as follows:

    1. Go to the details page of the created function, click the Code tab, and click Add in the Dependencies area at the bottom.
    2. Add the public dependency pillow-7.1.2. The default version is 1. Click OK.