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>
35 lines
7.7 KiB
HTML
35 lines
7.7 KiB
HTML
<a name="functiongraph_04_0102"></a><a name="functiongraph_04_0102"></a>
|
|
|
|
<h1 class="topictitle1">Creating a Function Using a Template</h1>
|
|
<div id="body0000001297274413"><div class="section" id="functiongraph_04_0102__section2077511611339"><h4 class="sectiontitle">Introduction</h4><p id="functiongraph_04_0102__p193317101035">FunctionGraph provides templates to automatically complete code and running environment configurations when you create a function, helping you quickly build applications.</p>
|
|
</div>
|
|
<div class="section" id="functiongraph_04_0102__section0418520193311"><h4 class="sectiontitle">Step 1: Prepare the Environment</h4><p id="functiongraph_04_0102__functiongraph_04_0101_p722313491535">To perform the operations described in this section, ensure that you have the <strong id="functiongraph_04_0102__functiongraph_04_0101_b571115773214">FunctionGraph FullAccess</strong> permissions, that is, all permissions for FunctionGraph. For more information, see section "Permissions Management".</p>
|
|
</div>
|
|
<div class="section" id="functiongraph_04_0102__section2450193783315"><h4 class="sectiontitle">Step 2: Create a Function</h4><ol id="functiongraph_04_0102__ol1614414555101"><li id="functiongraph_04_0102__li7794535128">Log in to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_04_0102__b42000592229">Functions</strong> > <strong id="functiongraph_04_0102__b92001659122210">Function List</strong>.</li><li id="functiongraph_04_0102__li27941371211">Click <strong id="functiongraph_04_0102__b13451113742212">Create Function</strong> in the upper right corner and choose <strong id="functiongraph_04_0102__b12988737142619">Select template</strong>.</li><li id="functiongraph_04_0102__li12226824191318">Select the template shown in <a href="#functiongraph_04_0102__fig1910584114193">Figure 1</a> and click <strong id="functiongraph_04_0102__b870213172710">Configure</strong>.<div class="fignone" id="functiongraph_04_0102__fig1910584114193"><a name="functiongraph_04_0102__fig1910584114193"></a><a name="fig1910584114193"></a><span class="figcap"><b>Figure 1 </b>Selecting a template</span><br><span><img id="functiongraph_04_0102__image51051841161919" src="en-us_image_0000001679586377.png"></span></div>
|
|
</li></ol><ol start="4" id="functiongraph_04_0102__ol1548345201514"><li id="functiongraph_04_0102__li551782482816">Set <strong id="functiongraph_04_0102__b13453185445120">Function Name</strong> to <strong id="functiongraph_04_0102__b1474915013529">context</strong>, select any agency from the <strong id="functiongraph_04_0102__b209021915195214">Agency</strong> drop-down list, retain default values for other parameters, and click <strong id="functiongraph_04_0102__b17360183519525">Create Function</strong>.<div class="note" id="functiongraph_04_0102__note20468134822616"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="functiongraph_04_0102__ul157521325164511"><li id="functiongraph_04_0102__li16752825164510">If no agency is configured, the following message will be displayed when the function is triggered:<pre class="screen" id="functiongraph_04_0102__screen2182424112711">Failed to access other services because no temporary AK, SK, or token has been obtained. Please set an agency.</pre>
|
|
</li></ul>
|
|
</div></div>
|
|
<div class="fignone" id="functiongraph_04_0102__fig24414171232"><span class="figcap"><b>Figure 2 </b>Setting basic information</span><br><span><img id="functiongraph_04_0102__image1744111710237" src="en-us_image_0000001679586957.png"></span></div>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="functiongraph_04_0102__section1054774683313"><h4 class="sectiontitle">Step 3: Test the Function</h4><ol id="functiongraph_04_0102__ol138801929154513"><li id="functiongraph_04_0102__li118801429194518">On the function details page, click <strong id="functiongraph_04_0102__b2686526182810">Test</strong>. In the displayed dialog box, create a test event.</li><li id="functiongraph_04_0102__li1355343014466">Select <strong id="functiongraph_04_0102__b18840132132913">blank-template</strong>, set <strong id="functiongraph_04_0102__b48401222917">Event Name</strong> to <strong id="functiongraph_04_0102__b10111104792919">test</strong>, and click <strong id="functiongraph_04_0102__b48409222917">Create</strong>.<div class="fignone" id="functiongraph_04_0102__fig1149135632414"><span class="figcap"><b>Figure 3 </b>Configuring a test event</span><br><span><img id="functiongraph_04_0102__image514935692414" src="en-us_image_0000001679467421.png"></span></div>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="functiongraph_04_0102__section587765273314"><h4 class="sectiontitle">Step 4: View the Execution Result</h4><p id="functiongraph_04_0102__p552811143539">Click <strong id="functiongraph_04_0102__b1295418343012">Test</strong> and view the execution result on the right.</p>
|
|
<ul id="functiongraph_04_0102__ul1714875285210"><li id="functiongraph_04_0102__li20148952105216"><strong id="functiongraph_04_0102__b8151721103019">Function Output</strong>: displays the return result of the function.</li><li id="functiongraph_04_0102__li1659264116539"><strong id="functiongraph_04_0102__b1383472273017">Log Output</strong>: displays the execution logs of the function.</li><li id="functiongraph_04_0102__li1014811523528"><strong id="functiongraph_04_0102__b45541124163015">Summary</strong>: displays key information of the logs.</li></ul>
|
|
<div class="note" id="functiongraph_04_0102__note1035002210544"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_04_0102__functiongraph_04_0101_p1235012235414">A maximum of 2 KB logs can be displayed. For more log information, see section "Querying Function Logs".</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="functiongraph_04_0102__section0486613514"><h4 class="sectiontitle">Step 5: View Monitoring Metrics</h4><p id="functiongraph_04_0102__functiongraph_04_0101_p68574255014">On the function details page, click the <strong id="functiongraph_04_0102__functiongraph_04_0101_b1337097146">Monitoring</strong> tab.</p>
|
|
<ul id="functiongraph_04_0102__functiongraph_04_0101_ul514673445811"><li id="functiongraph_04_0102__functiongraph_04_0101_li1814673415587">On the <strong id="functiongraph_04_0102__functiongraph_04_0101_b152431737165312">Monitoring</strong> tab page, choose <strong id="functiongraph_04_0102__functiongraph_04_0101_b17548418101316">Metrics</strong>, and select a time range (such as 5 minutes, 15 minutes, or 1 hour) to query the function.</li><li id="functiongraph_04_0102__functiongraph_04_0101_li88981734907">The following metrics are displayed: invocations, errors, duration (including the maximum, average, and minimum durations), and throttles.</li></ul>
|
|
</div>
|
|
<div class="section" id="functiongraph_04_0102__section5661458145412"><h4 class="sectiontitle">Step 6: Delete a Function</h4><ol id="functiongraph_04_0102__ol07481824023"><li id="functiongraph_04_0102__functiongraph_04_0101_li197481224129">On the function details page, choose <strong id="functiongraph_04_0102__functiongraph_04_0101_b6137103021213">Operation</strong> > <strong id="functiongraph_04_0102__functiongraph_04_0101_b12443175210478">Delete Function</strong> in the upper right corner.</li><li id="functiongraph_04_0102__functiongraph_04_0101_li0745531425">In the confirmation dialog box, enter <strong id="functiongraph_04_0102__functiongraph_04_0101_b3374104583013">DELETE</strong> and click <strong id="functiongraph_04_0102__functiongraph_04_0101_b179661748143013">OK</strong> to release resources in a timely manner.</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_01_0505.html">Getting Started</a></div>
|
|
</div>
|
|
</div>
|
|
|