Skip to content

Store dbatools PowerShell module as a package in Azure DevOps

Reading Time: 4 minutes

In this post I want to cover how you can store dbatools PowerShell module as a package in Azure DevOps. By using the Azure Artifacts service.

I want share some knowledge about this because did a demo of it at Malta Data Saturday. By the end of this post you will have a better understanding of Azure Artifacts and a workaround if you encounter a problem publishing a package.


Just to recap, dbatools is a popular PowerShell that can be used for SQL Server. I covered it in a previous post about PowerShell modules here.

Azure Artifacts on the other hand, is the name of the package management service available in Azure DevOps.

To share packages you create what is known as a feed. For those of you who know Linux, you can think of a feed as a repository.

You can find out more about Azure Artifacts it by clicking here.

On the link above you will see it highlights the fact that it supports various package types. In addition, one called ‘Universal Package’ for your binaries. However, you can also use this package type for your PowerShell modules as well.

Publishing the dbatools PowerShell module

I used dbatools as an example of how you can do this at Malta Data Saturday. Before the event I created a feed to host the package. Like the below example:

Create new feed to store dbatools PowerShell module as a package in Azure DevOps
Creating a new feed

Once I had created the feed I downloaded an offline copy of the the dbatools module. You can do this using the official instructions on the dbatools website here.

After downloading an offline copy I opened up PowerShell. From there, I checked that I had the latest versions of both Azure CLI and the Azure DevOps extension for Azure CLI installed.

From there I logged into Azure CLI.

Potential issue publishing to Azure DevOps

Note: You may experience some issues performing the below publishing command section in PowerShell if you login using the ‘az login’ command with your own Azure account. If you do have this issue use the ‘az logout’ command to logout.

Afterwards, look to login using the ‘az devops login’ command to login with a Personal Access Token (PAT) instead. You can find out how to do this in detail here.

One thing to note is that if you do this in PowerShell you can only paste the PAT using the right click of from the console menu. In addition to this, the paste is silent as well, so do it once and then press enter to login. If there is no error message then the login has worked.

Publishing the dbatools package in Azure DevOps

Once logged into Azure CLI I set out to publish the package. To do this quickly I went into Azure DevOps and clicked on the blue ‘Connect to feed’ button in the feed. From there I selected the ‘Universal packages’ feed to get the right command to publish the package.

Selecting Universal packages

I copied the command to Publish the package and altered it slightly as below, to cater for the version number of dbatools.

az artifacts universal publish --organization --project="Test Scrum" --scope project --feed PowerShell --name dbatools --version 1.0.145 --description "dbatools" --path .

I then ran the command and got some nice JSON on the screen once it had completed. So, I went back into the feed in Azure DevOps and hit refresh for the package to appear.


Downloading the dbatools package from Azure DevOps

To make sure that the package was fine I also downloaded the package. I got the command below by simply clicking on the package name above.

az artifacts universal download --organization "" --project {Project GUID} --scope project --feed "PowerShell" --name "dbatools" --version "1.0.145" --path dbatools

Only thing I changed was the –path value to be dbatools. Doing this will create a new subfolder in the location I was in when I ran the PowerShell command.

Once done, I quickly checked the contents of the new dbatools folder.

Contents of dbatools folder

Universal packages potential in Azure DevOps

As you can see there is a lot of potential when using Universal packages in Azure Artifacts.

Here, I used the popular dbatools PowerShell module to highlight the possibilities.

Because you can look to publish the dbatools PowerShell module as a package. Afterwards, you can then specify the package as part of a CI/CD pipeline in Azure DevOps to download the latest version of dbatools onto servers.

Of course, Universal packages can be used for other PowerShell modules and binaries as well. In fact, Microsoft states here that Universal packages have been tested up to 1TB in size. I’m sure this opens up some interesting possibilities for some of you.

Final words about storing dbatools module as a package in Azure DevOps

I hope this post about how you can store dbatools PowerShell module as a package in Azure DevOps has given some of you ideas. Because there are some interesting possibilities you can achieve using Azure Artifacts to store packages.

Of course, if you have any views or comments about this post feel free to reach out to me.

Published inAzure DevOpsSQL Server


Leave a Reply

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