开始使用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 的详细信息,请参阅扩展插件创作扩展 APIVisual Studio Code 网站上的文档。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.tab)。Instead of specifying dashboard container inline (inside the dashboard.tab). 你可以注册使用 dashboard.containers 的容器。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 容器

    Web 视图将显示在整个容器。The webview will be displayed in the entire container. 它需要 web 视图 id 为也是选项卡 IDIt 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

    nav 部分

    导航部分将显示在容器中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. 数据库或者服务器。Either 'database' or 'server'. 例如:Ex. dashboardContext == 'database'