Azure Data Studio: Awesome Visualizations w/ JSON output

Jad Aboul Hosn
Oct 9, 2018 · 4 min read

In an earlier story, I walked through installing and testing Azure’s Data Studio connection to Azure SQL Database.

In this follow-up, I go through how to change the output type of queries or stored procedures into JSON. I also show how to get started with Azure’s data insights (really cool visualizations).

How to change your output to JSON

Starting from the stored procedure we used in the earlier story, we will output the data in a JSON format. Now, this might come in handy in different scenarios, but in my case: it fits perfectly for a visualization tool with a javascript front end.

Reminder: In this stored procedure, we fetch all the data for any customer with the input customer id.

Now, let’s aim to store the output in a JSON file. You just add this command after your query: FOR JSON PATH et voilà!

Let’s see how the output looks like below. You can even add this command after any query and the output will be in JSON format.

PS: Even if the command has a squiggly line underneath it — it still works, trust me, I tried it :)

How to create COOL visualizations

This is huge — I am super excited that Azure Data Studio lets you create your own mini visualizations instead of just a table. You can even add it to a dashboard that constantly refreshes (can become handy in query performance, PSI calculations or literally anything).

Let’s get started already!

Create an insight

  1. Write a small query just to try this out:
    SELECT title as Titles, count(*) as Count
    FROM SalesLT.Customer
    GROUP by Title

This query will fetch all the different titles for the customers, and then groups them and returns the count of each title.

2. Instead of the tabulated results, you can click on the plot icon on the right.

3. This will show you a bar plot that represents our data. Don’t forget to click Use First Column as row label in the bar plot’s settings. The actual plot is so cool, it shows you a clear legend with a tooltip functionality to check the actual counts.

Bar plot instead of tabulated data

How to turn this into a dashboard widget

  1. Click on Create Insight on the plots top left corner
  2. This will take you to a new file contains some widget settings (check image below)

3. Select all the widget settings, hit right-click and select Format Document. This will help you see it a bit more clearly :)

4. Hit CMD+comma (like this comma, ). This will open the dashboard settings where we want the widget to be. Just look at the image below, you can already see where our widget will be located.


5. Search for dashboard.database.widgets

6. Click on the tiny pencil next to dashboard.database.widgets. and select Copy to settings.

You can see a new yellow part shows up on the right hand side of your screen.

7. Now let’s focus a bit: remember the widget settings that we fixed the format for earlier? — in step 3 above — go back and copy those settings.

8. Where to paste them?
Look at Image Look at Me below. JSON is precise science, so you need to focus on this one.

Image Look at Me

9. Paste your settings after the last } before the ] . See that comma, don’t forget to add it right before your pasted settings.

10. We’re almost done, I promise!
Hit Save, and go to your server homepage.

11. Double-click on sql-test-medium (or your server’s name).

Et voilà! See, that wasn’t so hard.
I hope you enjoyed my quick walkthrough of Azure Data Studio!

Jad Aboul Hosn

Written by

If I can do it, you definitely can! — Data guy — Hummus ftw!