VS Code extension for local development

更新时间:
复制 MD 格式

The Realtime Compute for Apache Flink VS Code extension streamlines the local Flink job development process. Use it to develop, deploy, and manage SQL, JAR, and Python jobs, and to synchronize job configurations from the cloud. This topic explains how to use the extension.

Prerequisites

Limitations

  • Log configuration is not supported.

  • The extension does not support pulling existing jobs from the cloud.

Install and configure the extension

  1. Download and install the extension.

    • Method 1: Go to the VS Code Marketplace and click Install.

    • Method 2:

      1. Open VS Code and click EXTENSIONS in the left-side navigation pane.

      2. In the search bar, search for the Flink Realtime Compute Studio extension.

      3. Click Install.

  2. In the top menu bar, click File > Open Folder and select a local folder.

  3. Configure your AccessKey information.

    Current workspace

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

    2. Add the following configuration to the file:

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

      Parameter

      Description

      Notes

      accessKey

      The AccessKey ID of your Alibaba Cloud account.

      For more information, see How do I obtain an AccessKey ID and AccessKey Secret?

      secretKey

      The AccessKey Secret of your Alibaba Cloud account.

      namespace

      The name of the Flink namespace.

      For more information, see View and delete a namespace.

      workspace

      The ID of the Flink workspace.

      For more information, see How do I view the workspace ID and other information?.

      regionId

      The region ID.

      Find the region ID in Endpoints.

    Global

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

    2. In the Configure AK&SK section, click Configure in global user settings. VS Code opens the global settings page.

      Search for flinkStudio and set the following fields: Flink Studio: Access Key, Flink Studio: Secret Key, Flink Studio: Namespace, Flink Studio: Region ID (default: cn-hangzhou), and Flink Studio: Workspace.

    3. As needed, select User or Workspace for configuration.

      Note

      We recommend setting the scope to User, which applies the configuration to all projects. The Workspace scope applies the configuration only to the current workspace.

      Parameter

      Description

      Notes

      Access Key

      The AccessKey ID of your Alibaba Cloud account.

      For more information, see How do I obtain an AccessKey ID and AccessKey Secret?

      Secret Key

      The AccessKey Secret of your Alibaba Cloud account.

      For more information, see How do I obtain an AccessKey ID and AccessKey Secret?

      Namespace

      The name of the Flink namespace.

      For more information, see View and delete a namespace.

      Workspace

      The ID of the Flink workspace.

      For more information, see How do I view the workspace ID and other information?.

      Region ID

      The region ID.

      Find the region ID in Endpoints.

    Note

    Configuration priority: Current folder > Parent folder > Global.

    After you apply the configuration, the namespace name appears in the status bar at the bottom of the editor.

  4. (Optional) You can install the following extensions for a better development experience.

Procedure

Step 1: Create a job

  • Method 1: In the left-side navigation pane, click the image icon. In the QUICK START section, click Create a new deployment. Enter a name at the top and press Enter to create a file with the .vvp extension. The extension generates a job with default fields.

  • Method 2: Create a new file with the .vvp extension directly in the file explorer. The extension populates the file with a default job configuration.

Step 2: Configure the job

You can configure the parameters directly in the UI form.

If you are familiar with job configuration, click Raw File in the upper-left corner to configure the job in the source file. Clicking a parameter name in the UI form navigates to its definition in the source file.

{
  "name": "test",
  "artifact": {
    "kind": "SQLSCRIPT",
    "sqlArtifact": {
      "additionalDependencies": [],
      "sqlScript": ""
    }
  },
  "deploymentTarget": {
    "mode": "PER_JOB",
    "name": "default-queue"
  },
  ...
}
  • Basic: Configure basic parameters.

    SQL job

    Parameter

    Description

    Deployment Name

    The name of the deployment.

    Execution Mode

    The deployment mode. Use STREAM for streaming mode or BATCH for batch mode.

    Engine Version

    For more information about engine versions, see Engine versions. We recommend that you use the latest recommended version.

    Deployment Target

    The resource queue for the deployment. For more information, see Manage a resource queue.

    Deployment Type

    Select SQL.

    SQL Script

    Click Open in external editor to open the local editor. Write your DDL and DML code.

    Note

    The file opened in the editor is a virtual file that is not stored in the actual file system. Therefore, if you reopen VS Code, an editor tab for an unclosed virtual file will display the The editor could not be opened because the file was not found error message. To open the file, click Open in external editor again.

    Additional Dependencies

    The additional dependencies required by the job. Enter the URI of the target dependency file.

    Description

    Optional. Enter a description for the job.

    JAR job

    For more information about parameter configurations, see Deploy a JAR job.

    Parameter

    Description

    Deployment Name

    The name of the deployment.

    Execution Mode

    The deployment mode. Use STREAM for streaming mode or BATCH for batch mode.

    Engine Version

    The engine version. For more information, see Engine versions. We recommend that you use the latest recommended version.

    Deployment Target

    The resource queue for the deployment. For more information, see Manage a resource queue.

    Deployment Type

    The type of job to deploy. Select JAR.

    JAR URI

    The OSS path or URL of the JAR package.

    Make sure that you have uploaded the relevant dependency files to Artifacts in the Development Console or to a bound OSS bucket and have obtained the corresponding path.

    Entry Point Class

    The main class to execute. Required if the JAR manifest does not specify a main class.

    Entry Point Main Arguments

    Enter the input arguments to be passed to the main method.

    Additional Dependencies

    Enter the OSS path or URL of the additional dependency files. Currently, only URLs ending with a file name are supported.

    Make sure that you have uploaded the relevant dependency files to Artifacts in the Development Console or to a bound OSS bucket and have obtained the corresponding path.

    Description

    Optional. Enter a description for the job.

    Python job

    For more information about parameter configurations, see Deploy a Python job.

    Parameter

    Description

    Deployment Name

    The name of the deployment.

    Execution Mode

    The deployment mode. Use STREAM for streaming mode or BATCH for batch mode.

    Engine Version

    The engine version. For more information, see Engine versions. We recommend that you use the latest recommended version.

    Deployment Target

    The resource queue for the deployment. For more information, see Manage a resource queue.

    Deployment Type

    The type of job to deploy. Select Python.

    Python URI

    The URI of the Python job file, which can be a .py or .zip file.

    Entry Module

    The entry module to execute.

    • Not required for .py files.

    • Required for .zip files.

    Entry Point Main Arguments

    Enter the input arguments to be passed to the main method.

    Python Libraries

    Third-party Python packages. These packages are added to the PYTHONPATH of the Python worker process, making them directly accessible in Python user-defined functions. For information about how to use third-party Python packages, see Use third-party Python packages.

    Python Archives

    Archive files. 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 dependency files.

    Make sure that you have uploaded the relevant dependency files to Artifacts in the Development Console or to a bound OSS bucket and have obtained the corresponding path.

    Description

    Optional. Enter a description for the job.

  • Resources: For more information about job resource parameters, see Configure job resources.

  • Parameters: For more information about job running parameters, see Configure runtime parameters.

Step 3: Deploy the job

After you finish developing or configuring the job, click Create at the bottom to deploy a new job, or click Update to update and deploy an existing local job.

For SQL jobs, the extension validates the SQL script, resource plan, and other configurations, and then outputs the validation results.

Step 4: Start the job

For a deployed job, the latest status is displayed in the upper-right corner. You can click Start and select a startup mode. For more information about startup modes, see Start a job.

Step 5: Job O&M

After the job is deployed and running, a green RUNNING status appears in the action bar at the top of the editor. The Basic area displays key deployment information in a table, including Deployment ID, Deployment Name, Execution Mode, Engine Version (for example, vvr-8.0.7-flink-1.17), Deployment Target, and Deployment Type.

  • Open Online: Click Open Online to open the job O&M page in the Development Console, where you can view the running status and perform O&M operations.

  • Synchronize: Pulls the job configuration from the cloud. Clicking Synchronize opens a preview of the online configuration. Note: The preview does not include draft changes made to SQL jobs in the console. Click Accept to overwrite your local file with the online configuration.

  • Cancel: Stops the running job.

Related documentation