tencent cloud

Feedback

Usage Method

Last updated: 2024-12-02 18:12:22
    This document describes how to use image to deploy function via the console.

    Prerequisites

    SCF supports the image repositories of TCR Enterprise Edition and Personal Edition. You can select the image repository as needed.
    Purchase a TCR Enterprise Edition instance. For more information, see Quick Start.
    Use a TCR Personal Edition image repository. For more information, see Getting Started.

    Creating functions via the console

    Image pushing

    Run the following code to push the built image to your image repository.
    # Switch to the file download directory
    cd /opt
    
    # Download Demo
    git clone https://github.com/awesome-scf/scf-custom-container-code-snippet.git
    
    # Log in to the image repository. Replace $YOUR_REGISTRY_URL with your image repository, and replace $USERNAME and $PASSWORD with your login credentials respectively.
    docker login $YOUR_REGISTRY_URL --username $USERNAME --password $PASSWORD
    
    # Build images. Replace $YOUR_IMAGE_NAME with your image address.
    docker build -t $YOUR_IMAGE_NAME .
    
    # Push images
    docker push $YOUR_IMAGE_NAME

    Creating a function

    1. Log in to the SCF console and click Function Service in the left sidebar.
    2. At the top of the page, select the region and the namespace where to create a function, and click Create to enter the function creation process.
    3. Select Use TCR image and specify the basic function information.
    Parameter
    Operation
    Function type
    Select Event-triggered function or HTTP-triggered Function.
    Function name
    Define the function name.
    Region
    Select the region where to deploy the function. The function must be in the same region as the image repository.
    time zone
    SCF uses the UTC time by default, which you can modify by configuring the TZ environment variable. After you select a time zone, the TZ environment variable corresponding to the time zone will be added automatically.
    Images
    Select the Personal Edition or Enterprise Edition image repository you created.
    Image tag
    Select the image tag. If this parameter is left empty, the latest version of the image will be used by default.
    Entrypoint
    Enter the bootstrap command of the container. Parameter input specification: enter an executable command, such as a python command. This parameter is optional. If it is left empty, the Entrypoint value in the Dockerfile will be used by default.
    CMD
    Enter the bootstrap parameter of the container. Parameter input specification: use "space" as the parameter separator, for example, -u app.py. This parameter is optional. If it is left empty, the CMD value in the Dockerfile will be used by default.
    Image acceleration
    Enable image acceleration as needed. After image acceleration is enabled, SCF can pull images more efficiently. It takes over 30 seconds to enable image acceleration, so please be patient.
    4. Click Complete.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support