forked from docs/doc-exports
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com> Co-authored-by: Chen, Junjie <chenjunjie@huawei.com> Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
138 lines
18 KiB
HTML
138 lines
18 KiB
HTML
<a name="functiongraph_03_0280"></a><a name="functiongraph_03_0280"></a>
|
|
|
|
<h1 class="topictitle1">What Are the Rules for Packaging a Function Project?</h1>
|
|
<div id="body1529027800470"><p id="functiongraph_03_0280__p18109133173619"></p>
|
|
<p id="functiongraph_03_0280__p8060118">In addition to inline code editing, you can create a function by uploading a ZIP or JAR file, or uploading a ZIP file from OBS. For details, see <a href="#functiongraph_03_0280__section1314181003718">Packaging Rules</a> and <a href="#functiongraph_03_0280__section237534633713">Example ZIP Project Packages</a>.</p>
|
|
<div class="section" id="functiongraph_03_0280__section1314181003718"><a name="functiongraph_03_0280__section1314181003718"></a><a name="section1314181003718"></a><h4 class="sectiontitle">Packaging Rules</h4><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p8060118">In addition to inline code editing, you can create a function by uploading a local ZIP file or JAR file, or uploading a ZIP file from Object Storage Service (OBS). <a href="#functiongraph_03_0280__en-us_topic_0000001212904604_table12861932162314">Table 1</a> describes the rules for packaging a function project.</p>
|
|
|
|
<div class="tablenoborder"><a name="functiongraph_03_0280__en-us_topic_0000001212904604_table12861932162314"></a><a name="en-us_topic_0000001212904604_table12861932162314"></a><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_03_0280__en-us_topic_0000001212904604_table12861932162314" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Function project packaging rules</caption><thead align="left"><tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row17862183213231"><th align="left" class="cellrowborder" valign="top" width="23%" id="mcps1.3.3.3.2.5.1.1"><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p2862133282315">Runtime</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.3.3.2.5.1.2"><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1842418309506">JAR File</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="28.999999999999996%" id="mcps1.3.3.3.2.5.1.3"><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1686263282311">ZIP File</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="23%" id="mcps1.3.3.3.2.5.1.4"><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p5862832182312">ZIP File on OBS</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row0862332152314"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p17862203211234">Node.js</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p104258309509">Not supported.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><ul id="functiongraph_03_0280__en-us_topic_0000001212904604_ul6730102619368"><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li07301026143613">If the function project files are saved under the <strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b439612132157">~/Code/</strong> directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li115801029153616">If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.</li></ul>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p6862113211233">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row145996311146"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p65991311846">PHP</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1540510130518">Not supported.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><ul id="functiongraph_03_0280__en-us_topic_0000001212904604_ul540510131754"><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li154050131056">If the function project files are saved under the <strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b624085553">~/Code/</strong> directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li44062132513">If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.</li></ul>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1040611316511">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row7862732192318"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1886273217236">Python 2.7</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p114271530115014">Not supported.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><ul id="functiongraph_03_0280__en-us_topic_0000001212904604_ul728216330401"><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li1228212337401">If the function project files are saved under the <strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b103217563218">~/Code/</strong> directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li784105224013">If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.</li></ul>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p20862133216238">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row1186223217235"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p12862133210238">Python 3.6</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1542913302507">Not supported.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><ul id="functiongraph_03_0280__en-us_topic_0000001212904604_ul15655183384116"><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li565553334117">If the function project files are saved under the <strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b109759521229">~/Code/</strong> directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li96569339415">If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.</li></ul>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p15862732172310">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row1486213328238"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p138621232112317">Java 8</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p104311430145017">If the function does not reference third-party components, compile only the function project files into a JAR file.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p178621032172320">If the function references third-party components, compile the function project files into a JAR file, and compress all third-party components and the function JAR file into a ZIP file.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1692313542474">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row1317895502214"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p91801855112216">Go 1.x</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p479121332310">Not supported.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1719532592313">Zip the compiled file and ensure that the name of the binary file is consistent with that of the handler. For example, if the name of the binary file is <strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b793210519115">Handler</strong>, set the name of the handler to <strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b12937155111112">Handler</strong>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p57961320233">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row137201136201016"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1572083612105">C#</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1172023610107">Not supported.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p12720336181019">Compress project files into a ZIP file. The ZIP file must contain the following files: <em id="functiongraph_03_0280__en-us_topic_0000001212904604_i1618011444018">Project_name</em><strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b51817418403">.deps.json</strong>, <em id="functiongraph_03_0280__en-us_topic_0000001212904604_i8181114164016">Project_name</em><strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b1918215419409">.dll</strong>, <em id="functiongraph_03_0280__en-us_topic_0000001212904604_i818364114017">Project_name</em><strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b51839412407">.runtimeconfig.json</strong>, <em id="functiongraph_03_0280__en-us_topic_0000001212904604_i1418418415405">Project_name</em><strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b12185840402">.pdb</strong>, and <strong id="functiongraph_03_0280__en-us_topic_0000001212904604_b618674124013">HC.Serverless.Function.Common.dll</strong>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p5468174361720">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_03_0280__en-us_topic_0000001212904604_row1398182715413"><td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.1 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p998527155419">Custom</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.3.2.5.1.2 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p203801940195515">Not supported.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.3.3.3.2.5.1.3 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p499172745414">Compress project files into a ZIP file. The ZIP file must contain a bootstrap file.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23%" headers="mcps1.3.3.3.2.5.1.4 "><p id="functiongraph_03_0280__en-us_topic_0000001212904604_p1799112785417">Compress project files into a ZIP file and upload it to an OBS bucket.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="functiongraph_03_0280__section237534633713"><a name="functiongraph_03_0280__section237534633713"></a><a name="section237534633713"></a><h4 class="sectiontitle">Example ZIP Project Packages</h4><ul id="functiongraph_03_0280__en-us_topic_0000001212904604_ul1727812284141"><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li2278182818143">Example directory of a Nods.js project package<pre class="codeblock" id="functiongraph_03_0280__en-us_topic_0000001212904604_codeblock17665152418412">Example.zip Example project package
|
|
|--- lib Service file directory
|
|
|--- node_modules NPM third-party component directory
|
|
|--- index.js .js handler file (mandatory)
|
|
|--- package.json NPM project management file</pre>
|
|
</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li82051447141011">Example directory of a PHP project package<pre class="codeblock" id="functiongraph_03_0280__en-us_topic_0000001212904604_codeblock4205174751015">Example.zip Example project package
|
|
|--- ext Extension library directory
|
|
|--- pear PHP extension and application repository
|
|
|--- index.php PHP handler file</pre>
|
|
</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li176311257191419">Example directory of a Python project package<pre class="codeblock" id="functiongraph_03_0280__en-us_topic_0000001212904604_codeblock15284555968">Example.zip Example project package
|
|
|--- com Service file directory
|
|
|--- PLI Third-party dependency PLI directory
|
|
|--- index.py .py handler file (mandatory)
|
|
|--- watermark.py .py file for image watermarking
|
|
|--- watermark.png Watermarked image</pre>
|
|
</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li19221956141416">Example directory of a Java project package<pre class="codeblock" id="functiongraph_03_0280__en-us_topic_0000001212904604_codeblock152720498713">Example.zip Example project package
|
|
|--- obstest.jar Service function JAR file
|
|
|--- esdk-obs-java-3.20.2.jar Third-party dependency JAR file
|
|
|--- jackson-core-2.10.0.jar Third-party dependency JAR file
|
|
|--- jackson-databind-2.10.0.jar Third-party dependency JAR file
|
|
|--- log4j-api-2.12.0.jar Third-party dependency JAR file
|
|
|--- log4j-core-2.12.0.jar Third-party dependency JAR file
|
|
|--- okhttp-3.14.2.jar Third-party dependency JAR file
|
|
|--- okio-1.17.2.jar Third-party dependency JAR file</pre>
|
|
</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li10447254171418">Example directory of a Go project package<pre class="codeblock" id="functiongraph_03_0280__en-us_topic_0000001212904604_codeblock136532317569">Example.zip Example project package
|
|
|--- testplugin.so Service function package</pre>
|
|
</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li66537318560">Example directory of a C# project package<pre class="codeblock" id="functiongraph_03_0280__en-us_topic_0000001212904604_codeblock14743514132419">Example.zip Example project package
|
|
|--- fssExampleCsharp2.0.deps.json File generated after project compilation
|
|
|--- fssExampleCsharp2.0.dll File generated after project compilation
|
|
|--- fssExampleCsharp2.0.pdb File generated after project compilation
|
|
|--- fssExampleCsharp2.0.runtimeconfig.json File generated after project compilation
|
|
|--- Handler Help file, which can be directly used
|
|
|--- HC.Serverless.Function.Common.dll .dll file provided by FunctionGraph</pre>
|
|
</li><li id="functiongraph_03_0280__en-us_topic_0000001212904604_li115941342152318">Custom<pre class="codeblock" id="functiongraph_03_0280__en-us_topic_0000001212904604_codeblock25945428233">Example.zip Example project package
|
|
|--- bootstrap Executable boot file</pre>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_03_0344.html">Function Creation FAQs</a></div>
|
|
</div>
|
|
</div>
|
|
|