Files
doc-exports/docs/fg/umn/functiongraph_04_0102.html
liusiying01 904c1aad8b FG UMN 20250526 version
Reviewed-by: Mützel, Andrea <andrea.muetzel@t-systems.com>
Co-authored-by: liusiying01 <liusiying@huawei.com>
Co-committed-by: liusiying01 <liusiying@huawei.com>
2025-10-06 15:14:20 +00:00

39 lines
7.9 KiB
HTML

<a name="functiongraph_04_0102"></a><a name="functiongraph_04_0102"></a>
<h1 class="topictitle1">Creating a Function Using a Template and Executing the Function</h1>
<div id="body0000001297274413"><p id="functiongraph_04_0102__p193317101035">FunctionGraph provides multiple templates to automatically complete code and running environment configurations when you create a function, helping you quickly build applications. This section uses <strong id="functiongraph_04_0102__b139385016291">context-class-introduction</strong> as an example.</p>
<div class="section" id="functiongraph_04_0102__section0418520193311"><h4 class="sectiontitle">Prerequisites</h4><ol id="functiongraph_04_0102__functiongraph_04_0101_ol8106132642719"><li id="functiongraph_04_0102__functiongraph_04_0101_li4257144418303">Grant the FunctionGraph operation permissions to the user.<p id="functiongraph_04_0102__functiongraph_04_0101_p722313491535"><a name="functiongraph_04_0102__functiongraph_04_0101_li4257144418303"></a><a name="functiongraph_04_0101_li4257144418303"></a>To perform the operations described in this section, ensure that you have the <strong id="functiongraph_04_0102__functiongraph_04_0101_b14529817145619">FunctionGraph FullAccess</strong> permissions, that is, all permissions for FunctionGraph. For more information, see section <span class="uicontrol" id="functiongraph_04_0102__functiongraph_04_0101_uicontrol17648524536"><b>"Permissions Management"</b></span>.</p>
</li></ol>
</div>
<div class="section" id="functiongraph_04_0102__section2450193783315"><h4 class="sectiontitle">Step 1: 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__b104434964010">Functions</strong> &gt; <strong id="functiongraph_04_0102__b744549124019">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__b071567103011">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" title="Click to enlarge" class="imgResize"></span></div>
<p id="functiongraph_04_0102__p1468532841813"></p>
</li></ol><ol start="4" id="functiongraph_04_0102__ol1548345201514"><li id="functiongraph_04_0102__li551782482816">On the displayed page, set function parameters and click <strong id="functiongraph_04_0102__b13992202614128">Create Function</strong>.<ul id="functiongraph_04_0102__ul0608101195812"><li id="functiongraph_04_0102__li17608181105814"><strong id="functiongraph_04_0102__b940715018318">Templates</strong>: name of the selected template. To change the template, click <strong id="functiongraph_04_0102__b16160190183217">Reselect</strong> on the right.</li><li id="functiongraph_04_0102__li13119014185811"><strong id="functiongraph_04_0102__b1315135017305">Region</strong>: The default value is used. You can select other regions.<p id="functiongraph_04_0102__p4822192710425"><strong id="functiongraph_04_0102__b2657103415612">Regions are geographic areas isolated from each other. Resources are region-specific and cannot be used across regions through internal network connections. For low network latency and quick resource access, select the nearest region.</strong></p>
</li><li id="functiongraph_04_0102__li1315614416597"><strong id="functiongraph_04_0102__b468681715324">Function Name</strong>: enter <strong id="functiongraph_04_0102__b11687217203216">context</strong>.</li><li id="functiongraph_04_0102__li1818413119017"><strong id="functiongraph_04_0102__b9339448123214">Enterprise Project</strong>: The default value is <strong id="functiongraph_04_0102__b3339248113212">default</strong>. You can select the created enterprise project.<p id="functiongraph_04_0102__p1214812438429">Enterprise projects let you manage cloud resources and users by project.</p>
</li><li id="functiongraph_04_0102__li517031911248"><strong id="functiongraph_04_0102__b1877195312321">Agency</strong>: By default, no agency is used. You can select an existing agency.<p id="functiongraph_04_0102__p3533145312423">Specify an agency if you want to delegate FunctionGraph to access other cloud services, such as LTS and VPC.</p>
</li><li id="functiongraph_04_0102__li15230557182710"><strong id="functiongraph_04_0102__b18929103616126">Runtime</strong>: Select a runtime to compile the function. Default: <strong id="functiongraph_04_0102__b19291436181210">Python 3.6</strong>. You can select another runtime.</li></ul>
<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" title="Click to enlarge" class="imgResize"></span></div>
<p id="functiongraph_04_0102__p162795732010"></p>
</li></ol>
</div>
<div class="section" id="functiongraph_04_0102__section1054774683313"><h4 class="sectiontitle">Step 2: 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" title="Click to enlarge" class="imgResize"></span></div>
</li></ol>
</div>
<div class="section" id="functiongraph_04_0102__section587765273314"><h4 class="sectiontitle">Step 3: 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 <a href="functiongraph_01_0170.html">Querying Function Logs</a>.</p>
</div></div>
</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>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>