All Products
Search
Document Center

Realtime Compute for Apache Flink:Use the Visual Studio Code extension

Last Updated:Jul 31, 2024

Realtime Compute for Apache Flink provides the Visual Studio Code extension to help you develop, deploy, and manage SQL, JAR, and Python jobs in an on-premises environment. You can also use the extension to synchronize updated deployment configurations from the development console of Realtime Compute for Apache Flink. This topic describes how to use the Visual Studio Code extension.

Prerequisites

Limits

  • The extension does not support log configuration.

  • The extension cannot synchronize deployments created in the development console of Realtime Compute for Apache Flink.

Install and configure the extension

  1. Download and install the extension.

    • Method 1: Go to the Visual Studio Code Marketplace page and click Install.

    • Method 2:

      1. Open Visual Studio Code on your computer. In the left-side navigation pane, click EXTENSIONS.

      2. Enter Flink Realtime Compute Studio in the search box.

      3. Find the matched extension and click Install.

  2. In the top navigation bar, choose File > Open Folder and select the folder you want to use.

  3. Configure the AccessKey pair.

    Configure only for the current folder

    1. In the left-side navigation pane, click image. In the Configure AK&SK section, click Configure in a .vvprc file. The extension automatically creates a file suffixed with .vvprc.

      截屏2024-07-16 13

    2. Open the created file and add the following configurations:

      {
        "accessKey": "xxx",
        "secretKey": "xxx",
        "namespace": "xxx",
        "workspace": "xxx",
        "regionId" : "xxx"
      }

      Parameter

      Description

      References

      accessKey

      The AccessKey ID of your Alibaba Cloud account.

      How do I view information about the AccessKey ID and AccessKey secret of the account?

      secretKey

      The AccessKey secret of your Alibaba Cloud account.

      namespace

      The name of the Realtime Compute for Apache Flink namespace you want to use.

      View and delete a namespace

      workspace

      The ID of the Realtime Compute for Apache Flink workspace you want to use.

      How do I view information about a workspace, such as the workspace ID?

      regionId

      The ID of the region in which the workspace is created.

      Endpoints

    Configure for the current workspace or user

    1. In the left-side navigation pane, click image.

    2. In the Configure AK&SK section, click Configure in global user settings to open the Settings editor in Visual Studio Code.

      image

    3. Select the User or Workspace tab based on your business requirements.

      Note

      We recommend that you select the User tab. This way, the parameter configurations apply to all projects and workspaces in Visual Studio Code.

      Parameter

      Description

      References

      Access Key

      The AccessKey ID of your Alibaba Cloud account.

      How do I view information about the AccessKey ID and AccessKey secret of the account?

      Secret Key

      The AccessKey secret of your Alibaba Cloud account.

      How do I view information about the AccessKey ID and AccessKey secret of the account?

      Namespace

      The name of the Realtime Compute for Apache Flink namespace you want to use.

      View and delete a namespace

      Workspace

      The ID of the Realtime Compute for Apache Flink workspace you want to use.

      How do I view information about a workspace, such as the workspace ID?

      Region ID

      The ID of the region in which the workspace is created.

      Endpoints

    Note

    Configuration precedence: Current-folder configuration > Workspace configuration > User configuration.

    After the configurations take effect, the name of the Realtime Compute for Apache Flink namespace is displayed in the status bar in the lower part of the code editor.

  4. (Optional) Install the following extensions to improve coding efficiency:

Use the extension

Step 1: Create a deployment

  • Method 1: In the left-side navigation pane, click image. In the QUICK START section, click Create a new deployment. In the top navigation bar, enter a name and press the Enter key to create a file suffixed with .vvp. The file includes pre-populated deployment configurations.

    vscode0

  • Method 2: Create a file suffixed with .vvp in the current folder. The file includes pre-populated deployment configurations.

Step 2: Configure the deployment

You can configure the deployment in the form view.

image

If you are familiar with the parameters, you can also click Raw File in the upper left corner to configure the deployment in the raw file view. You can click the name of a field in the form to quickly locate the corresponding parameter in the raw file.

image

  • Basic: This section includes basic deployment parameters.

    SQL deployment

    Parameter

    Description

    Deployment Name

    Enter a name for the deployment.

    Execution Mode

    Select the deployment mode. Valid values: STREAM (streaming mode) and BATCH (batch mode).

    Engine Version

    Select the version of the Ververica Runtime (VVR) engine. For more information, see Engine versions. We recommend that you select the version labeled with RECOM.

    Deployment Target

    Select the queue you want to use for the deployment. For more information, see Manage queues.

    Deployment Type

    Select the type of the deployment. In this example, select SQL.

    SQL Script

    Click Open in external editor to open the code editor in which you can write DDL and DML statements.

    Note

    The changes you make in the code editor are saved in a virtual file. If you exit and reopen Visual Studio Code without closing the editor, the corresponding editor window displays the following error message: The editor could not be opened because the file was not found. To resolve the error, click Open in external editor again.

    Additional Dependencies

    Enter the URIs of the additional dependencies required in the deployment.

    Description

    Optional. Enter a description for the deployment.

    JAR deployment

    The following table describes the parameters. For more detailed parameter descriptions, see Create a JAR deployment.

    Parameter

    Description

    DeploymentName

    Enter a name for the deployment.

    Execution Mode

    Select the deployment mode. Valid values: STREAM (streaming mode) and BATCH (batch mode).

    Engine Version

    Select the version of the VVR engine. For more information, see Engine versions. We recommend that you select the version labeled with RECOM.

    Deployment Target

    Select the queue you want to use for the deployment. For more information, see Manage queues.

    Deployment Type

    Select the type of the deployment. In this example, select Jar.

    JAR URI

    Enter the Object Storage Service (OSS) path or URL of the JAR package you want to use for the deployment.

    To obtain the OSS path or URL, make sure that you upload the JAR package on the Artifacts page in the development console of Realtime Compute for Apache Flink or in the OSS bucket associated with the workspace.

    Entry Point Class

    Enter the entry point class of the Java application. If you do not specify a main class in the JAR package, make sure that you set this parameter to the fully qualified class name of the main class.

    Entry Point Main Arguments

    Enter the arguments you want to pass to the main method.

    Additional Dependencies

    Enter the OSS path or URL of the additional dependencies required in the deployment. The URL must end with a file name.

    To obtain the OSS path or URL, make sure that you upload the dependency files on the Artifacts page in the development console of Realtime Compute for Apache Flink or in the OSS bucket associated with the workspace.

    Description

    Optional. Enter a description for the deployment.

    Python deployment

    The following table describes the parameters. For more detailed parameter descriptions, see Create a Python deployment.

    Parameter

    Description

    Deployment Name

    Enter a name for the deployment.

    Execution Mode

    Select the deployment mode. Valid values: STREAM (streaming mode) and BATCH (batch mode).

    Engine Version

    Select the version of the VVR engine. For more information, see Engine versions. We recommend that you select the version labeled with RECOM.

    Deployment Target

    Select the queue you want to use for the deployment. For more information, see Manage queues.

    Deployment Type

    Select the type of the deployment. In this example, select Python.

    Python Uri

    Enter the URI of the Python deployment file that you want to use. The file can be a .py or .zip file.

    Entry Module

    Enter the entry point class of the Python application.

    • If you use a .py file, leave this parameter empty.

    • If you use a. zip file, you must configure this parameter.

    Entry Point Main Arguments

    Enter the arguments you want to pass to the main method.

    Python Libraries

    Enter the third-party Python libraries you want to use. The specified libraries are automatically passed to the PYTHONPATH environment variable of the corresponding worker process in the deployment. This way, you can use the libraries in Python user-defined functions (UDFs). For information about how to use third-party Python libraries, see Use a third-party Python package.

    Python Archives

    Enter the archive files you want to use. For more information, see Use a custom Python virtual environment and Use data files.

    Additional Dependencies

    Enter the OSS path or URL of the additional dependencies required in the deployment.

    To obtain the OSS path or URL, make sure that you upload the dependency files on the Artifacts page in the development console of Realtime Compute for Apache Flink or in the OSS bucket associated with the workspace.

    Description

    Optional. Enter a description for the deployment.

  • Resources: For information about the parameters in this section, see Configure resources for a deployment.

  • Parameters: For information about the parameters in this section, see Parameters section.

Step 3: Submit the deployment

Click Create in the lower part of the editor to submit the deployment. If you update an existing deployment, click Update to submit the updated deployment.

If you submit a SQL deployment, the extension checks the SQL script, resource plan, and other configurations and generates the check result.

Step 4: Start the deployment

After you submit a deployment, the latest status of the deployment is displayed in the upper right corner. Click Start and select a startup mode. For more information about startup modes, see Procedure.

image

Step 5: Manage the deployment

vscode.png

  • To view the detailed running status or perform O&M operations, click Open Online in the upper-left corner to go to the Deployments page in the development console of Realtime Compute for Apache Flink.

  • To quickly synchronize a deployment, click Synchronize to open the preview page, confirm the configurations on the preview page, and then click Accept in the upper right corner. This allows the extension to overwrite the configurations by using those from the development console of Realtime Compute for Apache Flink. Take note that the preview page does not display the SQL script updates you perform in the console.

  • To cancel a deployment, click Cancel in the upper right corner.

References