通过创建 Azure Data Studio 扩展来扩展功能Extend the functionality by creating Azure Data Studio extensions

Azure Data StudioAzure Data Studio擴充模組提供一個簡單的方式,可以新增更多功能至基礎 Azure Data StudioAzure Data Studio 安裝。Extensions in Azure Data StudioAzure Data Studio provide an easy way to add more functionality to the base Azure Data StudioAzure Data Studio installation.

扩展是团队提供的 Azure Data Studio (Microsoft) 以及第三方社区 (你 !)。Extensions are provided by the Azure Data Studio team (Microsoft), as well as the 3rd party community (you!).

创作了一个扩展Author an extension

如果有兴趣扩展 Azure Data Studio,可以创建自己的扩展,并将其发布到扩展库。If you're interested in extending Azure Data Studio, you can create your own extension and publish it to the extension gallery.

编写扩展Writing an Extension

先决条件Prerequisites

若要开发扩展需要 Node.js 已安装并在你 $PATH 中可用。To develop an extension you need Node.js installed and available in your $PATH. Node.js 包含 npm,Node.js 包管理器,它将用于安装的扩展生成器。Node.js includes npm, the Node.js Package Manager, which will be used to install the extension generator.

若要启动新的扩展名,可以使用 Azure 数据 Studio 扩展生成器。To start your new extension, you can use the Azure Data Studio Extension generator. Yeoman扩展生成器可以非常轻松创建简单的扩展项目。The Yeoman extension generator makes it very easy to create simple extension projects. 若要启动生成器,请在命令提示符下键入以下内容:To Launch the generator, type the following in a command prompt:

npm install -g yo generator-azuredatastudio

yo azuredatastudio

扩展引用Extensibility References

若要了解有关 Azure 数据 Studio 可扩展性,请参阅扩展性概述To learn about Azure Data Studio Extensibility see Extensibility overview. 您还可以查看有关如何使用现有 API 的示例示例You can also see examples of how to use the API in existing samples.

调试扩展Debug an extension

您可以调试你使用 Visual Studio Code 扩展的新扩展Azure 数据 Studio 调试You can debug your new extension using Visual Studio Code extension Azure Data Studio Debug.

步骤Steps

  • 打开你的扩展使用Visual Studio CodeOpen your extension with Visual Studio Code
  • 安装 Azure 数据 Studio 调试扩展Install Azure Data Studio Debug extension
  • F5或单击调试图标,然后单击启动Press F5 or click the Debug icon and click Start.
  • Azure Data Studio 的新实例启动 (扩展开发主机) 以特殊模式,此新实例现已了解你的扩展。A new instance of Azure Data Studio starts in a special mode (Extension Development Host) and this new instance is now aware of your extension.

创建扩展包Create an extension package

在编写您的扩展插件之后, 您需要创建 VSIX 包,以便能够将其安装在 Azure Data Studio。After writing your extension, you need to create a VSIX package to be able to install it in Azure Data Studio. 可以使用vsce创建 VSIX 包。You can use vsce to create the VSIX package.

npm install -g vsce

vsce package

发布扩展Publish an extension

若要发布到 Azure Data Studio 的新的扩展名:To publish your new extension to Azure Data Studio:

  1. 添加你的扩展 https://github.com/Microsoft/azuredatastudio/blob/release/extensions/extensionsGallery.jsonAdd your extension to https://github.com/Microsoft/azuredatastudio/blob/release/extensions/extensionsGallery.json
  2. 我们目前没有支持添加到主机的第三方扩展,因此,Azure Data Studio 而不是下载的扩展,必须浏览到下载页的选项。We currently don't have support to host third party extensions, so instead of downloading the extension, Azure Data Studio has the option to browse to a download page. 若要设置您的扩展插件的下载页,设置资产"Microsoft.AzureDataStudio.DownloadPage"的值。To set a download page for your extension, set the value of asset "Microsoft.AzureDataStudio.DownloadPage".
  3. 创建针对发布/扩展分支的拉取请求。Create a PR against release/extensions branch.
  4. 向团队发送评审请求。Send a review request to the team.

您的扩展插件将进行审查和添加到扩展库。Your extension will be reviewed and added to the extension gallery.

发布扩展更新发布更新的过程是类似于发布扩展。Publishing Extension Updates The process to publish updates is similar to publishing the extension. 请确保在 package.json 中更新版本Please make sure the version is updated in package.json