Managing CDN Functions
Precautions
The priorities for function configurations in CDN and FunctionGraph vary in different stages. The details are as follows:
- Client request received: The function is executed in FunctionGraph first and then configured by CDN, so it is the CDN configuration that takes effect at last.
- Before origin pull: The function is configured by CDN first and then executed in FunctionGraph, so it is the FunctionGraph configuration that takes effect at last.
Procedure
- Log in to the CDN console. In the navigation pane, choose Domains. In the domain name list, click the domain name for which you want to configure a function. The details page is displayed.
Figure 1 Domain name management
- Select Functions. If you do not have permission to create an agency, see Creating an Agency. If you have created an agency, click Edit and then click Add Stage.
Figure 2 Adding a stage
- Configure the function stage and rule.
- Select Client request received for Stage. For details, see Table 1.
- Set Content Type to All files, Function to programmable-cdn, Version to V1, and Priority to 1. For details, see. Table 2. A maximum of 40 rules can be added.
Figure 3 Configuring function stage and rule
Table 1 Function stage description Stage
Description
Client request received
Functions are executed between the time when a client initiates a request and the time when a CDN node receives the request, for example, URL rewriting.
Before origin pull
Functions are executed before a CDN node receives a request that is not cached and retrieves the requested resource, for example, rewriting the retrieval URL.
Table 2 Rule parameters Parameter
Description
Content Type
All files: The rule takes effect for all files.
File type: Files with the specified types comply with the current rule.
Directory: Files in the specified directory comply with the current rule.
Full path: Files in the full path comply with the current rule.
Content
If Content Type is set to All files, you do not need to set this parameter.
If Content Type is set to File type:
- Enter a period (.) as the first character.
- Use commas (,) to separate multiple file types, for example, .jpg,.zip,.exe.
- Enter up to 20 file types.
If Content Type is set to Directory:
- Enter a directory starting with a slash (/).
- Use commas (,) to separate multiple directory paths, for example, /test/folder01,/test/folder02.
- Enter up to 20 directory paths.
If Content Type is set to Full path:
- Enter a path start with a slash (/), for example, /test/index.html or /test/*.jpg.
- A file in the specified directory or file with the wildcard * can be matched.
Function
Select a function created in FunctionGraph. If no function is available, click Create Function to create one.
Function version
Select the related function version.
Priority
If there are multiple rules in a function stage, the priority determines which rule is executed first.
- Enter an integer ranging from 1 to 100. A greater number indicates a higher priority.
- The priority must be unique. Two rules cannot have the same priority.
- Click Save.
The deployment takes about 5 minutes. After it is complete, the function configuration will be deployed on the edge node. Then you can access CDN to trigger functions and run scripts on CDN edge nodes.Figure 4 Saving configurations
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