Uploading Function Code
This section describes how to upload a function code file on the FunctionGraph console for deployment.
Scenarios
Runtime |
Uploading a ZIP File |
Uploading a JAR File |
Description |
---|---|---|---|
Node.js |
Supported |
Not supported |
- |
Python |
Supported |
Not supported |
When you write code in Python, do not name your dependency package with the same suffix as a standard Python library, such as json, lib, and os. Otherwise, an error indicating a module loading failure will be reported. |
Java |
Supported |
Supported |
You can upload a ZIP or JAR file of Java code. Uploading a JAR file
Uploading a ZIP file If dependencies are introduced, you can create a ZIP file that contains all dependencies and the JAR file of the function code and upload the ZIP file. For details, see Developing Functions in Java (Using an IDEA Java Project) and Developing Functions in Java (Using an IDEA Maven Project). |
Go |
Supported |
Not supported |
Ensure that the name of the dynamic library file is consistent with the plug-in name of the handler. For example, if the name of the dynamic library file is testplugin.so, set the handler name to testplugin.Handler. |
C# |
Supported |
Not supported |
- |
PHP |
Supported |
Not supported |
- |
Custom |
Supported |
Not supported |
- |
Cangjie |
Supported |
Not supported |
- |
Notes and Constraints
- The code file to be uploaded cannot exceed 40 MB. If the file size exceeds 40 MB, upload it by following the instructions provided in Uploading Function Code from OBS.
- If the code to be uploaded contains sensitive information (such as account passwords), encrypt the sensitive information to prevent leakage.
- If the code deployed in the inline code editor is greater than 20 MB, the code is not displayed, as shown in Figure 1. However, the function code can still be tested.
Uploading Function Code
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click a function name to go to the function details page.
- Click the Code tab and choose Upload > Local ZIP or Upload > Local JAR.
- In the dialog box that is displayed, click Add and select the function code file.
- Use KMS static encryption to encrypt function code as required. (This feature is optional and available only in the LA-Sao Paulo1 region.)
- functiongraph/default (default): The function automatically creates a default key in DEW.
If you use the default key for encryption and decryption for the first time, ensure that the function agency has the following permissions: kms:dek:decrypt, kms:dek:create, kms:cmk:create, kms:cmk:get, and kms:cmk:list.
- Customer master key (CMK): You can select a created key to encrypt the function code. For details about how to create a customer master key, see Creating a Custom Key.
To use customer master key, ensure that the function agency has the following permissions: kms:dek:decrypt, kms:dek:create, kms:cmk:get and kms:cmk:list.
If you select Customer master key (CMK), do not delete the CMK used for function encryption in DEW. Otherwise, the function execution will fail because encrypted data cannot be decrypted.
Go to the IAM console and add the agency permission policy (using the default key as an example) to the function agency by referring to Configuring a Custom Policy in JSON View. Then, configure the agency permission for the function by referring to Configuring an Agency.{ "Version": "1.1", "Statement": [ { "Action": [ "kms:dek:decrypt", "kms:dek:create", "kms:cmk:create", "kms:cmk:get", "kms:cmk:list" ], "Effect": "Allow" } ] }
- functiongraph/default (default): The function automatically creates a default key in DEW.
- After the file is uploaded, click OK. The code is automatically deployed to the code editing area.
If you need to modify the code in the code editing area, click Deploy each time after the modification is complete. For details about how to modify the function handler, see Modifying the Function Handler.
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