Using Non-SQL Languages in Azure Data Studio

,

Azure Data Studio (ADS) is a lightweight IDE built on Visual Studio Code. I've written a few articles on how ADS works, shown here:

If there are other features you're interested in, let me know. This article continues the series, looking at another aspect of ADS.

Non SQL Work in ADS

ADS is based on the VS Code shell, and it does support other languages. I'll look at how a few of these work, but keep in mind that Notebooks are a good way to run other kernels and execute different code.

PowerShell in ADS

I wrote an article on coding in PoSh, where I used Visual Studio Code. Someone at Microsoft asked me why I didn't use ADS, and I didn't have a good answer. Muscle memory, as I think of VS Code when I write PoSh or Python, or really most non-database languages. I can use ADS, and I tried it. It works, and you can use PowerShell with the default ADS install. If you open a new Query Window, you default to the SQL language, but in the bottom toolbar, you see some information to the right. As you can see in the image, I see my locationin the file, tab settings, and the line endings on the left. On the right I have my server and database connection. In the middle, I see SQL and MSSQL.

status bar in ADS

If I click on the "SQL" word, I get a menu at the top. This lets me choose from a number of languages, of which PoSh is one.

language list in ADS

If I click PowerShell, this changes the language at the bottom, but the rest of my ADS looks the same. However, if I start writing PoSh, I get the intellisense that matches this language. I wouldn't see this if the language were set to SQL.

Posh Intellisense

I can now write whatever PoSh I want, just as if I were coding in VS Code. I've added some code, and if I want to run it, I can do so in the integrated terminal. In this case, I can change to the folder where I saved this and run this from the CLI.

Running PowerShell in ADS

That's clunky, and not a great experience. VS Code is better. However, there's also a video from Microsoft that talks a bit about how to get PoSh to work in ADS better, by adding the PowerShell extension. If I click the Extensions, I see my installed extensions by default.

There is a mapping issue with F8, which is one of the reasons I like VS Code. When I press F8, the line I'm gets executed. When I do that in ADS, I get the Server Connection pane popping open. Not much fun.

However, I blogged about how to fix that. Essentially, search the command palette for keyboard mappings and alter the, Once you do, you can run PoSh in ADS.

running PoSh line by line

If I click the PoSh icon on the sidebar, I get the installed commands for my system, which is handy.

I don't love this experience, but I can't quite figure out why. If I run Visual Studio Code, it's very close, although the fonts and view seem to be easier for me in VS Code when I'm writing PoSh. That's small, and likely I could adjust the fonts, but there's enough friction here that even if I give it a chance, I find myself preferring VS Code.

Python

There were other options in the list, for example, Python. I can create a new file and set the language to Python. If I do this, I need to click on the "SQL" in the lower right corner of the status bar.

ADS Status Bar

This brings up a list of languages, and I can scroll down and select Python.

ADS language selection

From here, I do get highlighting, but no intellisense when I write code. This isn't terribly helpful for working with Python scripts directly, but I can edit them.

Python in ADS

If I try to execute this, there isn't a python shell in the Terminal that I can see. However, I do see a "Export as Notebook" at the top, but this doesn't work, producing a syntax error near "a".

This is in contrast to Visual Studio Code, where I can run this file in Python.

Running Python in VS Code

If I search extensions in ADS, I don't see any for Python.

ADS Extensions, none for python

It seems as though I can edit files, and I certainly could manually run this in the Terminal with the python prefix, as shown below. However, this isn't ideal for working with other languages.

Manually running Python in the terminal

Notebook support is good, and I can easily run a Python notebook in ADS. I've got another article on Notebooks in ADS.

Python code in notebook

However, I don't seem to be able to easily work with Python files directly and execute them. I would likely edit them here, if I wanted to use ADS, and then use a separate Windows Terminal (ConEmu in my case) to execute the code and see results. Actually, I'd rather use VS Code for most of this.

Other Languages

If I create a new file and change the type to Batch (.bat), I can save the file, but I can't run it. F8 doesn't work, and if I "run PowerShell", either the selection or the whole file, I get an error, which you can see in the image below.

Batch file error in ADS

I can create a JSON document, and I get some markers if it is invalid (mismatched braces), but overall,  there isn't a lot I can do here. I can't format, nor do I see any extensions to help.

For Markdown, things are better. I can actually create a markdown file, and then when I save it and use the command palette to find a preview, I see an entry (shown below).

Preview option for markdown in command palette

If I pick that, I get a real preview of my document. That's handy, as I find myself using markdown regularly.

Actual preview of markdown document

R scripts seem to be like Python. I can edit files, but it's on me. No way to execute the script, and no intellisense.

ADS R script

I would guess that other types (Docker, YAML, etc.) behave similar to those above, meaning really no support.

Conclusion

While ADS has better features for SQL and queries, and it does work with PowerShell, it doesn't seem to really integrate anything else outside of notebooks. Notebooks do make the execution of Python and other types of code interesting, but being forced to use notebooks when you might need to work on a different type of file isn't ideal. Certainly you can use VS Code, which is what I do, when I am outside of the SQL or PowerShell area.

I still tend to use VS Code for PowerShell, but researching this and playing with it shows me ADS does have good PoSh support, and I can certainly see myself using this tool if I'm doing SQL and PoSh work together.

If you haven't tried other languages in ADS, you might give PoSh a try the next time you need to edit a script.

Rate

5 (2)

Share

Share

Rate

5 (2)