Azure Data StudioAzure Data Studio 扩展性入门Getting started with Azure Data StudioAzure Data Studio extensibility

Azure Data StudioAzure Data Studio 具有多种扩展性机制,可以自定义用户体验并使这些自定义项可供整个用户社区使用。has several extensibility mechanisms to customize the user experience and make those customizations available to the entire user community. 核心 Azure Data StudioAzure Data Studio 平台基于 Visual Studio Code 构建,因此大多数 Visual Studio Code 扩展性 API 都可用。The core Azure Data StudioAzure Data Studio platform is built upon Visual Studio Code, so most of the Visual Studio Code extensibility APIs are available. 此外,我们还为特定于数据管理的活动提供了额外的扩展点。Additionally, we've provided additional extensibility points for data management-specific activities.

下面是一些关键扩展点:Some of the key extensibility points are:

  • Visual Studio Code 扩展性 APIVisual Studio Code extensibility APIs
  • Azure Data Studio 扩展创作工具Azure Data Studio extension authoring tools
  • 管理仪表板选项卡面板贡献Manage Dashboard tab panel contributions
  • 包含操作体验的见解Insights with Actions experiences
  • Azure Data Studio 扩展性 APIAzure Data Studio extensibility APIs
  • 自定义数据提供程序 APICustom Data Provider APIs

Visual Studio Code 扩展性 APIVisual Studio Code extensibility APIs

由于核心 Azure Data StudioAzure Data Studio 平台是基于 Visual Studio Code 构建的,因此,Visual Studio Code 网站上的扩展创作扩展 API 文档中提供了有关 Visual Studio Code 扩展性 API 的详细信息。Because the core Azure Data StudioAzure Data Studio platform is built upon Visual Studio Code, details about the Visual Studio Code extensibility APIs are found in the Extension Authoring and Extension API documentation on the Visual Studio Code website.

管理仪表板选项卡面板贡献Manage Dashboard tab panel contributions

有关详细信息,请参阅贡献点上下文变量For details, see Contribution Points and Context Variables.

Azure Data Studio 扩展性 APIAzure Data Studio extensibility APIs

有关详细信息,请参阅扩展性 APIFor details, see Extensibility APIs.

贡献点Contribution points

本部分介绍 package.json 扩展清单中定义的各种贡献点。This section covers the various contribution points that are defined in the package.json extension manifest.

azuredatastudio 中支持 IntelliSense。The IntelliSense is supported inside azuredatastudio.

贡献仪表板Contributes dashboard

向仪表板贡献选项卡、容器、见解小组件。Contribute tab, container, insight widget to the dashboard.

面板

dashboard.tabs

Dashboard.tabs 用于在仪表板页面内创建选项卡部分。Dashboard.tabs creates the tab sections inside the dashboard page. 它需要对象或对象数组。It expects an object or an array of objects.

"dashboard.tabs": [
{
    "id": "test-tab1",
    "title": "Test 1",
    "description": "The test 1 displays a list of widgets.",
    "when": "connectionProvider == 'MSSQL' && !mssql:iscloud",
    "alwaysShow": true,
    "container": {
        ...
    }
}
]

dashboard.containers

可以使用 dashboard.containers 注册容器,Instead of specifying dashboard container inline (inside the dashboard.tab). 而不是内联指定仪表板容器(在 dashboard.tab 内)。You can register containers using dashboard.containers. 它接受对象或对象数组。It accepts an object or an array of the object.

"dashboard.containers": [
{
    "id": "innerTab1",
    "container": {
        ...
    }
},
{
    "id": "innerTab2",
    "container": {
       ...
    }
}
]

若要引用已注册的容器,请指定该容器的 IDTo refer to registered container, specify the id of the container

"dashboard.tabs": [
{
    ...
    "container": {
        "innerTab1": {             
        }
    }
}
]

dashboard.insights

可以使用 dashboard.insights 注册见解。You can register insights using dashboard.insights. 这类似于教程:生成自定义见解小组件This is similar to Tutorial: Build a custom insight widget

"dashboard.insights": {
"id": "my-widget"
"type": {
    "count": {
        "dataDirection": "vertical",
        "dataType": "number",
        "legendPosition": "none",
           "labelFirstColumn": false,
        "columnsAsLabels": false
       }
   },
   "queryFile": "{your file folder}/activeSession.sql"
}

仪表板容器类型Dashboard container types

目前有四种受支持的容器类型:There are currently four supported container types:

  1. widgets-container

    小组件容器

    将在容器中显示的小组件的列表。The list of widgets that will be displayed in the container. 它采用流布局。It's a flow layout. 它接受小组件列表。It accepts the list of widgets.

    "container": {
        "widgets-container": [
        {
            "widget": {
                "query-data-store-db-insight": {
                }
            }
        },
        {
            "widget": {
                "explorer-widget": {
                }
            }
        }
      ]
    }
    
  2. webview-container

    webview 容器

    webview 将显示在整个容器中。The webview will be displayed in the entire container. 它要求 webview ID 与选项卡 ID 相同It expects webview id to be the same is tab ID

    "container": {
        "webview-container": null
    }
    
  3. grid-container

    网格容器

    将在网格布局中显示的小组件或 webview 的列表The list of widgets or webviews that will be displayed in the grid layout

    "container": {
        "grid-container": [
        {
            "name": "widget 1",
            "widget": {
                "explorer-widget": {
                }
            },
            "row":0,
            "col":0
        },
        {
            "name": "widget 2",
            "widget": {
                "tasks-widget": {
                    "backup", 
                    "restore",
                    "configureDashboard",
                    "newQuery"
                }
            },
            "row":0,
            "col":1
        },
        {
            "name": "Webview 1",
            "webview": {
                "id": "google"
            },
            "row":1,
            "col":0,
            "colspan":2
        },
        {
            "name": "widget 3",
            "widget": {
                "explorer-widget": {}
            },
            "row":0,
            "col":3,
            "rowspan":2
        },
    ]
    
  4. nav-section

    导航部分

    导航部分将显示在容器中The navigation section will be displayed in the container

    "container": {
        "nav-section": [
            {
                "id": "innerTab1",
                "title": "inner-tab1",
                "icon": {
                    "light": "./icons/tab1Icon.svg",
                    "dark": "./icons/tab1Icon_dark.svg"
                }
                "container": {
                    ...
                }
            },
            {
                "id": "innerTab2",
                "title": "inner-tab2",
                "icon": {
                    "light": "./icons/tab2Icon.svg",
                    "dark": "./icons/tab2Icon_dark.svg"
                }
                "container": {
                    ...
                }
            }
        ]
    }
    

上下文变量Context variables

有关 Visual Studio Code 中的上下文以及随后的 Azure Data Studio 的常规信息,请参阅扩展性For general information about context in Visual Studio Code and subsequently Azure Data Studio, see Extensibility.

在 Azure Data Studio 中,我们有关于数据库连接的特定上下文,可用于扩展。In Azure Data Studio, we have specific context around database connections available for extensions.

面板Dashboard

在仪表板中,我们提供以下上下文变量:In dashboard, we provide the following context variables:

上下文变量context variable descriptiondescription
connectionProvider 当前连接的提供程序的标识符字符串。A string of the identifier for the provider of the current connection. 例如:Ex. connectionProvider == 'MSSQL' 列中的一个值匹配。connectionProvider == 'MSSQL'.
serverName 当前连接的服务器名称字符串。A string of the server name of the current connection. 例如:Ex. serverName == 'localhost' 列中的一个值匹配。serverName == 'localhost'.
databaseName 当前连接的数据库名称字符串。A string of the database name of the current connection. 例如:Ex. databaseName == 'master' 列中的一个值匹配。databaseName == 'master'.
connection 当前连接的完整连接配置文件对象 (IConnectionProfile)The full connection profile object for the current connection (IConnectionProfile)
dashboardContext 当前打开的仪表板页面的上下文字符串。A string of the context of the page of the dashboard is currently on. “database”或“server”。Either 'database' or 'server'. 例如:Ex. dashboardContext == 'database'