CLI-based instance management

Updated at:

Connect to a running Function Compute instance from the Function Compute console or by using Function Compute SDKs and run shell commands directly in its execution environment. This is useful when you need to investigate issues that are difficult to diagnose from logs alone—for example, inspecting environment variables, running Profiling or Coredump tools, or checking the file system of a live instance.

How it works

Function Compute allocates the most appropriate instance for each incoming request and releases it after the request completes. CLI-based instance management lets you attach to an active elastic instance and interact with it through a shell, without interrupting normal function execution.

Limitations

ConstraintDetails
Supported instance typeActive elastic instances in the Running state only. If an instance is released or in an unhealthy state and about to be destroyed, you may not be able to connect.
Concurrency quotaCLI management requests do not count against the concurrency quota of a function. Even if instance concurrency is set to 1, you can invoke the function and run CLI commands on its instances simultaneously.
Custom Container runtimeIf your function uses a custom image, the container image must include the /bin/bash or /bin/sh directory. Without one of these, the instance client cannot start.

Billing

  • Each command you run on an instance counts as one function invocation and is charged based on the metering rules for regular function invocations.

  • While a WebSocket connection is open, the instance remains active and billing continues until you close the connection.

  • If you connect through the Function Compute console, the session disconnects automatically 10 minutes after the last piece of data is transferred from the Function Compute console.

Warning

Running commands on an instance that is handling a live request can alter the execution environment and cause that request to fail. Subsequent tasks scheduled on the same instance are also affected. Failures caused by CLI-based instance management are not counted in the Function Compute service-level agreement (SLA).

Prerequisites

Before you begin, ensure that you have:

Connect to an instance

  1. Log on to the Function Compute console. In the left-side navigation pane, choose Function Management > Functions.

  2. In the top navigation bar, select a region. On the Functions page, click the name of the function you want to manage.

  3. On the Function Details page, click the Instances tab. Locate the target instance ID, then click Connect to Instance in the Actions column.

  4. (Optional) Read the warning message, then click I understand the risks.

    Function Compute opens a WebSocket connection to the instance and redirects you to an interactive CLI session. Run commands based on your requirements.

Note

You can connect only to instances in the Running state. Destroyed instances cannot be accessed.