Adventures with Azure DevOps: Create a Custom Dashboard Widget

I have been doing a lot with Azure DevOps lately, from building pipelines to dashboard.

As I was building out a dashboard with various widget, I wondered if it was possible to create a custom dashboard widget!

What do you know? You can!

The widget are a combination of HTML, JavaScript and CSS.

So I decided to create a simple sample custom widget that would display two lists, a list of characters from Star Trek, and another list of characters from Star Wars.

This is a very academic sample, just something to get familiar with the widget creation/deployment process.

I started with VS Code to build the custom widget.

I followed the article at https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-dashboard-widget?view=azure-devops, specifically Part 1: Hello World!, to create the bare bones structure.

While the jQuery library is imported by default, I would recommend, where you can, you stick with JavaScript, one less library you need to rely on, and the more I work with JavsScript the more I discover how far it has come with ease of DOM manipulation.

Next, I created two fake APIs using https://www.mocky.io to return my list of characters.

The first API returns a list of Star Trek characters in a JSON format.

The second API returns a list of Star Wars characters in a JSON format.

Next, add a widget.js file to the scripts directory. This file will contain the JavaScript function to add li elements to the parent ul element.

Update your hello-world.html with the following code:

We will want to make sure that our JavaScript library, widget.js, is pulled in, which is why we add <script src="scripts/widget.js"></script> to the head element.

You are now ready to publish your widget, but first you will need to visit the Visual Studio Marketplace Publishing Portal to creating a publisher profile, don’t worry, your widget will only be available to those organizations you share it with.

Package up your extension as explained at https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-dashboard-widget?view=azure-devops#package-your-extension.

In the vss-extension.json file replace the publisher name fabrikam with the name of your publisher profile.

Some things to be aware of:

As you rebuild your widget, you will want to increment the version number in the vss-extension.json file.

To include an additional folder, like in my example, the scripts folder, you will need to include it in the files node of the vss-extension.json.

To allow for different sizes for your widget, add them to the supportedSizes node.

That’s it, pretty straight forward!

Related Links


Discover more from Matt Ruma

Subscribe to get the latest posts to your email.

1 Reply to “Adventures with Azure DevOps: Create a Custom Dashboard Widget”

Leave a Reply

Your email address will not be published. Required fields are marked *