Skip to content

Commit 6837da4

Browse files
author
Steve Stein
authored
Merge pull request #7298 from stevestein/sql-ads-091701
Merging into release branch
2 parents 8d813c6 + c85ffca commit 6837da4

1 file changed

Lines changed: 33 additions & 41 deletions

File tree

docs/azure-data-studio/tutorial-create-extension.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ ms.author: "kcunnane"
1515
manager: craigg
1616
---
1717

18-
# Tutorial: Create an Azure Data Studio extension
18+
# Tutorial: Create an Azure Data Studio (preview) extension
1919

20-
This tutorial demonstrates how to create a new Azure Data Studio (preview) extension.
20+
This tutorial demonstrates how to create a new Azure Data Studio extension. The extension creates familiar SSMS keybindings in Azure Data Studio.
2121

2222
During this tutorial you learn how to:
2323
> [!div class="checklist"]
@@ -30,24 +30,18 @@ During this tutorial you learn how to:
3030
3131
## Prerequisites
3232

33-
Azure Data Studio is built on the same framework as Visual Studio Code, so we'll build our extension in Visual Studio Code. To get started, you need the following components:
33+
Azure Data Studio is built on the same framework as Visual Studio Code, so extensions for Azure Data Studio are built using Visual Studio Code. To get started, you need the following components:
3434

3535
- [Node.js](https://nodejs.org) installed and available in your `$PATH`. Node.js includes [npm](https://www.npmjs.com/), the Node.js Package Manager, which is used to install the extension generator.
3636
- [Visual Studio Code](https://code.visualstudio.com) to debug the extension.
3737
- The Azure Data Studio [Debug extension](https://marketplace.visualstudio.com/items?itemName=ms-mssql.sqlops-debug).
38-
- Ensure sqlops is on your path. For Windows, make sure you choose the "Add to Path" option in the setup.exe. For Mac/Linux, you can run the Install 'sqlops' command in PATH option.
38+
- Ensure sqlops is in your path. For Windows, make sure you choose the `Add to Path` option in setup.exe. For Mac or Linux, run the *Install 'sqlops' command in PATH* option.
39+
- SQL Operations Studio Debug extension (optional). This lets you test your extension without needing to package and install it into Azure Data Studio.
3940

4041

41-
## Create a new extension project
42-
43-
Visual Studio Code
44-
Node.js installed and added to your path
45-
SQL Operations Studio Debug extension (optional). This lets you test your extension without packaging it and installing into Ops Studio
46-
It’ll take about 10 minutes to install all of the above, so we only have 5 minutes left to get our extension going. Luckily it’s pretty easy!
47-
4842
## Install the extension generator
4943

50-
We’ve built an [extension generator](https://code.visualstudio.com/docs/extensions/yocode) using Yeoman. To install it, run the following from the command prompt:
44+
To simplify the process of creating extensions, we've built an [extension generator](https://code.visualstudio.com/docs/extensions/yocode) using Yeoman. To install it, run the following from the command prompt:
5145

5246
`npm install -g yo generator-sqlops`
5347

@@ -59,30 +53,30 @@ To create an extension:
5953

6054
`yo sqlops`
6155

62-
2. Choose **New Keymap** from the list of extension types.
56+
2. Choose **New Keymap** from the list of extension types:
6357

6458
![extension generator](./media/tutorial-create-extension/extension-generator.png)
6559

66-
3. Follow the steps to fill in the extension name (in our case, *ssmskeymap*) and a description, and the generator creates a new folder.
60+
3. Follow the steps to fill in the extension name (for this tutorial, use **ssmskeymap**), and add a description.
6761

68-
Open the folder in Visual Studio Code and youre ready to create your own keybindings!
62+
Completing the previous steps creates a new folder. Open the folder in Visual Studio Code and you're ready to create your own keybinding extension!
6963

70-
### Adding a keyboard shortcut
64+
65+
### Add a keyboard shortcut
7166

7267
**Step 1: Find the shortcuts to replace**
7368

74-
Now that we have our extension ready to go, I want to add some keyboard shortcuts (or keybindings) used in SSMS into Ops Studio.
75-
I used Andy Mallon’s Cheatsheet and RedGate’s keyboard shortcuts list for inspiration.
69+
Now that we have our extension ready to go, add some SSMS keyboard shortcuts (or keybindings) into Azure Data Studio. I used [Andy Mallon's Cheatsheet](https://am2.co/2018/02/updated-cheat-sheet/) and RedGate's keyboard shortcuts list for inspiration.
7670

77-
The top things I saw were missing were:
71+
The top things I saw missing were:
7872

79-
- Run a query with the actual execution plan enabled. This is Ctrl+M in SSMS and doesnt have a binding in Ops Studio.
80-
- Having Ctrl+Shift+E as a 2nd way of running a query. Some people complained this was missing
81-
- Having Alt+F1 run sp_help. We added this in Ops Studio but since that binding was in use we put it as Alt+F2 instead
82-
- Toggle full screen (shift+alt+enter)
83-
- F8 to show your Object Explorer / Servers view
73+
- Run a query with the actual execution plan enabled. This is **Ctrl+M** in SSMS and doesn't have a binding in Azure Data Studio.
74+
- Having **CTRL+SHIFT+E** as a 2nd way of running a query. User feedback indicated that this was missing.
75+
- Having **ALT+F1** run `sp_help`. We added this in Azure Data Studio but since that binding was already in use, we mapped it to **ALT+F2** instead.
76+
- Toggle full screen (**SHIFT+ALT+ENTER**).
77+
- **F8** to show **Object Explorer** / **Servers view**.
8478

85-
It’s easy to find and replace these — run Open Keyboard Shortcuts to show the Keyboard Shortcuts tab in Ops Studio, search for query and then choose to Change Keybinding. Once you’ve done so you can see it in the keybindings.json file (run Open Keyboard Shortcuts File to see it).
79+
It’s easy to find and replace these keybindings. Run *Open Keyboard Shortcuts* to show the **Keyboard Shortcuts** tab in Azure Data Studio, search for *query* and then choose **Change Keybinding**. Once you're done changing the keybinding you can see the updated mapping in the keybindings.json file (run *Open Keyboard Shortcuts* to see it).
8680

8781
![keyboard shortcuts](./media/tutorial-create-extension/keyboard-shortcuts.png)
8882

@@ -91,8 +85,7 @@ It’s easy to find and replace these — run Open Keyboard Shortcuts to sho
9185

9286
**Step 2: Add shortcuts to the extension**
9387

94-
This one’s easy — I opened up the package.json file in the extension and replaced the contributes section with the following:
95-
88+
To add shortcuts to the extension, open the *package.json* file (in the extension) and replace the `contributes` section with the following:
9689

9790
```json
9891
"contributes": {
@@ -125,26 +118,27 @@ This one’s easy — I opened up the package.json file in the extension and
125118
}
126119
```
127120

121+
## Test your extension
128122

123+
Ensure `azuredatastudio` is in your PATH by running the Install azuredatastudio command in PATH command in Azure Data Studio.
129124

125+
Ensure the Azure Data Studio Debug extension is installed in Visual Studio Code.
130126

131-
## Test your extension
132-
133-
To test, I made sure sqlops was in my PATH by running the Install 'sqlops'command in PATH command in Ops Studio, and had the SQL Operations Studio Debug extension installed in VSCode. Then I hit F5 to launch Ops Studio in debug mode with my extension running:
127+
Select **F5** to launch Azure Data Studio in debug mode with the extension running:
134128

135129
![install extension](./media/tutorial-create-extension/install-extension.png)
136130

137131
![test extension](./media/tutorial-create-extension/test-extension.png)
138132

139-
Success! It’s all working and ready to share. Keymaps are one of the quickest extensions so feel free to make your own!
133+
Keymaps are one of the quickest extensions to create, so your new extension should now be successfully working and ready to share.
140134

141135
## Package your extension
142136

143-
To share with others I needed to package the extension into a single file. This can be published in an extension marketplace or just shared among your team / community. To do this, I first needed to install another npm package from the command line:
137+
To share with others you need to package the extension into a single file. This can be published to the Azure Data Studio extension marketplace, or just shared among your team or community. To do this, you need to install another npm package from the command line:
144138

145139
`npm install -g vsce`
146140

147-
Then I ran vsce package from the base directory of my extension. I did have to add in a couple of extra lines to stop the vsce tool complaining:
141+
Navigate to the base directory of the extension, and run `vsce package`. I had to add in a couple of extra lines to stop the *vsce* tool from complaining:
148142

149143
```json
150144
"repository": {
@@ -156,16 +150,14 @@ Then I ran vsce package from the base directory of my extension. I did have to a
156150
},
157151
```
158152

159-
160-
Once this was done, my ssmskeymap-0.1.0.vsix file was created and ready to install / share with the world!
153+
Once this was done, my ssmskeymap-0.1.0.vsix file was created and ready to install and share with the world!
161154

162155
![install extension](./media/tutorial-create-extension/extensions.png)
163156

164157

165158
## Publish your extension to the marketplace
166159

167-
As this is early days, SQL Operations Studio is just rolling out the process for publishing to the Extensions list inside Ops Studio. We’ll be documenting the exact steps in our [wiki](https://github.com/Microsoft/sqlopsstudio/wiki/Getting-started-with-Extensibility), and the basic process will be to host the extension VSIX somewhere (a Github Release page is a good idea) then submit a PR changing [this JSON file](https://github.com/Microsoft/sqlopsstudio/blob/release/extensions/extensionsGallery.json) to add you extension info.
168-
I’ll be following this process myself to get the SSMS Keymaps extension published and update this page once I’ve completed it!
160+
The Azure Data Studio extension marketplace is not totally implemented yet, but the current process is to host the extension VSIX somewhere (for example, a GitHub Release page) then submit a PR updating [this JSON file](https://github.com/Microsoft/azuredatastudio/blob/release/extensions/extensionsGallery.json) with your extension info.
169161

170162

171163
## Next steps
@@ -181,13 +173,13 @@ In this tutorial, you learned how to:
181173
182174

183175
I hope after reading this you’ll be inspired to build your own extension for Azure Data Studio. We have support for Dashboard Insights (pretty graphs that run against your SQL Server), a number of SQL-specific APIs, and a huge existing set of extension points inherited from Visual Studio Code.
184-
If you have an idea but are not sure how to get started please open an issue or tweet at the team ([sqlopsstudio](https://twitter.com/sqlopsstudio), [me](https://twitter.com/kevcunnane), [Alan](https://twitter.com/alanyusql), [Abbie](https://twitter.com/ppookpetch)).
185176

186-
Help and documentation are getting written on our [wiki](https://github.com/Microsoft/sqlopsstudio/wiki/Getting-started-with-Extensibility), and you can always refer to the [VSCode extension guide](https://code.visualstudio.com/docs/extensions/overview) because it covers all the existing APIs and patterns.
177+
If you have an idea but are not sure how to get started please open an issue or tweet at the team ([azuredatastudio](https://twitter.com/azuredatastudio), [me](https://twitter.com/kevcunnane), [Alan](https://twitter.com/alanyusql), [Abbie](https://twitter.com/ppookpetch)).
187178

179+
You can always refer to the [Visual Studio Code extension guide](https://code.visualstudio.com/docs/extensions/overview) because it covers all the existing APIs and patterns.
188180

189181

190-
To learn how to backup and restore databases, complete the next tutorial:
182+
To learn how to work with T-SQL in Azure Data Studio, complete the T-SQL Editor tutorial:
191183

192184
> [!div class="nextstepaction"]
193-
> [Backup and restore databases](tutorial-backup-restore-sql-server.md).
185+
> [Use the Transact-SQL editor to create database objects](tutorial-sql-editor.md).

0 commit comments

Comments
 (0)