Cloud Functions FAQ
    • PDF

    Cloud Functions FAQ

    • PDF

    Article Summary

    The latest service changes have not yet been reflected in this content. We will update the content as soon as possible. Please refer to the Korean version for information on the latest updates.

    Available in Classic and VPC

    You can get your questions answered quickly by referring to the answers in the FAQ before reading the user guide. If your questions are not resolved in the FAQ, see the guides to find the information you want.

    The Cloud Functions FAQ covers the following topics:

    Service in general

    The following covers frequently asked questions and answers for Cloud Functions:

    Q. For what purposes can Cloud Functions be used?

    A. It can be used for a variety of purposes depending on the services connected with Cloud Functions, such as web server, API server, rule server for storing logs, batch jobs, etc. If you could finely divide a service, it can also be written like in regular microprogramming to implement a larger business logic.

    Q. What kind of users would Cloud Functions benefit more?

    A. It's great for anyone who wants to create a service by writing simple codes, like startups who may feel burdened by buying or building servers, small businesses who find server management challenging, college students, etc. It can also be used for apps or games, where generating profit is difficult until the usage reaches a certain point.

    System

    The following is frequently asked questions and answers related to the system:

    Q. Can native libraries be used?

    A. Native libraries not included in a runtime environment by default may be included in an attachment for an action code. It's not recommended however, because execution environments vary by runtime and they are subject to change without prior notice.

    Q. What are the types and versions of OSes supported by each runtime?

    A. The types and versions of OS supported for each runtime may change depending on internal policies. We recommend to write a code that is independent of OS environment.

    Restricted specifications

    The following is frequently asked questions and answers related to restricted specifications:

    Q. Is there a limitation to the code size?

    A. See Prerequisites for using Cloud Functions.

    Q. Is there a limitation to CPU usage?

    A. CPU usage is in proportion to memory usage, and there's no set limitations to it. It is also influenced by internal infrastructure and other actions, which makes it difficult to be controlled by a specific value. However, the maximum number of processes used by an action container is limited to 1024.

    Network

    The following covers frequently asked questions and answers related to environment configuration for a network that uses Cloud Functions:

    Q. Can I configure an ACG so that only Cloud Functions actions are allowed?

    A. You can add the cloudfunctions-vpc-<VPC_ID> ACG group to the inbound access source at ACG or set the VPC or the VPC Subnet band range connected to Cloud Functions actions as the ACG inbound access source in a VPC environment.

    Note

    If you use the Cloud Functions in a Classic environment, you need to set the ACG for the Source to be Any(0.0.0.0/0).

    Q. Are there any server IP range or IP rules where actions may run?

    A. An IP range is determined by the internal scheduling algorithm, depending on the circumstance of execution, which makes it hard to specify. For IP rules, see the answer about the ACG-related settings if you're using Cloud Functions in a VPC environment.

    Q. Can I call the Ncloud API without the NAT G/W in the Cloud Functions in a VPC environment?

    A You can call the Ncloud API without the NAT G/W in the Cloud Functions generated in a VPC environment. Even if you have conducted the VPC peering, you can privately communicate with another peered VPC environment. In addition, you can access also the Object Storage private endpoint through an internal network without an Internet access. For more information on Object Storage, see Object Storage Guide.

    Logs

    The following is frequently asked questions and answers related to logs:

    Q. Can I download execution result logs?

    A. The Cloud Functions execution result logs are stored in the Cloud Log Analytics in the NAVER Cloud Platform. You can download it in an Excel file in Cloud Log Analytics, or by using the export feature of Object Storage.

    Resource

    The following is frequently asked questions and answers related to actions, triggers, and packages:

    Q. How can I create actions using Java and C#?

    A. For Java, you can create an action by packaging the files in the format of Uber (FAT) JAR containing all the external library JARs when building a JAR. For C#, you can use the dotnet add package command to add packages needed and create an action. To learn how to create actions for each runtime other than Java and C#, see Cloud Functions examples > Creation and utilization of actions by runtime in this guide.

    Q. Can I make an action use or refer to a file on a specific path?

    A. The Cloud Functions execution environment is stateless, which means you can't use permanent location of some files on a specific path of a host executed. We recommend to use a cloud storage, such as Object Storage. However, you can attach files required in a compressed format and make your code to refer to them with a relative path, as in using an external library.

    Q. Can I reuse resources with high cost, such as DB connection?

    A. Execution of each action is stateless, and connection maintenance is not guaranteed. Accordingly, it's possible to reuse containers already executed and reuse connections as shown in the attached code to enhance the execution speed if an action is called frequently. However in such cases connections are not explicitly ended, which may cause failures. We don't recommend such usage. See the following example code:

    from kafka import KafkaProducer
    from kafka.errors import KafkaError
    import json, requests
     
    # Create NAVER Cloud Data Streaming Service connection
    producer = None
     
    def main(args):
        try:
            reuse = True
             
            global producer
            if producer is None:
                reuse = False
                producer = KafkaProducer(
                    bootstrap_servers=['10.0.20.6:9092', '10.0.20.7:9092', '10.0.20.8:9092'],
                    acks=1,
                    value_serializer=lambda v: json.dumps(v, ensure_ascii = False).encode('utf-8'),
                    key_serializer=lambda k: k.encode('utf-8'))
                     
            # Send messages
            producer.send('iot.demo', key=args['deviceId'], value=args)
            producer.flush()
      
            # Return a result
            return {"result": "success", "reuse": reuse}
      
        except Exception as ex:
            # Return an error result
            return {"result": "error", "error": str(ex)}
    

    Connected services

    The following is frequently asked questions and answers related to connected services:

    Q. How can I get the result value of an action executed through API Gateway in an HTTP response body?

    A. Add the value of "blocking=true&result=true" as the HTTP Request Query Parameter. However, if the action runs for a minute and more and the HTTP request exceeds 1 minute, only the activationId (execution UUID) value will be returned as the response.

    Q. Can I customize the HTTP response header of an action executed through API Gateway?

    A. You can enable the web action settings among action settings, and then request the web action type to be HTTP, not JSON. Then you'll be able to define response headers, bodies, etc., as shown in the following example code:

    function main(params) {
       return {
           statusCode: 200,
           headers: { 'Content-Type': 'application/json', 'Custom-Header': 'Cloud Functions' },
           body: { 'name': 'NAVER CLOUD'}
       };
    }
    

    Q. Can I connect other services to a Cloud Functions code?

    A. You can link them by calling the forwarded or processed data within the action code through OpenAPI of the service you'd like to connect. To learn how to use OpenAPI of each service, see APIs Guide.


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.