You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/azure-data-studio/tutorial-create-extension.md
+33-41Lines changed: 33 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,9 @@ ms.author: "kcunnane"
15
15
manager: craigg
16
16
---
17
17
18
-
# Tutorial: Create an Azure Data Studio extension
18
+
# Tutorial: Create an Azure Data Studio (preview) extension
19
19
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.
21
21
22
22
During this tutorial you learn how to:
23
23
> [!div class="checklist"]
@@ -30,24 +30,18 @@ During this tutorial you learn how to:
30
30
31
31
## Prerequisites
32
32
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:
34
34
35
35
-[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.
36
36
-[Visual Studio Code](https://code.visualstudio.com) to debug the extension.
37
37
- 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.
39
40
40
41
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
-
48
42
## Install the extension generator
49
43
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:
51
45
52
46
`npm install -g yo generator-sqlops`
53
47
@@ -59,30 +53,30 @@ To create an extension:
59
53
60
54
`yo sqlops`
61
55
62
-
2. Choose **New Keymap** from the list of extension types.
56
+
2. Choose **New Keymap** from the list of extension types:
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.
67
61
68
-
Open the folder in Visual Studio Code and you’re 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!
69
63
70
-
### Adding a keyboard shortcut
64
+
65
+
### Add a keyboard shortcut
71
66
72
67
**Step 1: Find the shortcuts to replace**
73
68
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.
76
70
77
-
The top things I saw were missing were:
71
+
The top things I saw missing were:
78
72
79
-
- Run a query with the actual execution plan enabled. This is Ctrl+M in SSMS and doesn’t 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**.
84
78
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).
@@ -91,8 +85,7 @@ It’s easy to find and replace these — run Open Keyboard Shortcuts to sho
91
85
92
86
**Step 2: Add shortcuts to the extension**
93
87
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:
96
89
97
90
```json
98
91
"contributes": {
@@ -125,26 +118,27 @@ This one’s easy — I opened up the package.json file in the extension and
125
118
}
126
119
```
127
120
121
+
## Test your extension
128
122
123
+
Ensure `azuredatastudio` is in your PATH by running the Install azuredatastudio command in PATH command in Azure Data Studio.
129
124
125
+
Ensure the Azure Data Studio Debug extension is installed in Visual Studio Code.
130
126
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:
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.
140
134
141
135
## Package your extension
142
136
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:
144
138
145
139
`npm install -g vsce`
146
140
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:
148
142
149
143
```json
150
144
"repository": {
@@ -156,16 +150,14 @@ Then I ran vsce package from the base directory of my extension. I did have to a
156
150
},
157
151
```
158
152
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!
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.
169
161
170
162
171
163
## Next steps
@@ -181,13 +173,13 @@ In this tutorial, you learned how to:
181
173
182
174
183
175
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)).
185
176
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)).
187
178
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.
188
180
189
181
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:
191
183
192
184
> [!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