“Could not find the modules: 'Az.Accounts' with Version: ''” error message and a story to remember

(2021-Dec-20) Part of the continuous integration and delivery for Azure Data Factory involves pre-deployment and post-deployment steps. Their main role is to stop triggers before deployment and restart them afterward, also they help to delete resources in the target environment that have been removed from its source control - https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-delivery-sample-script

To run these scripts, you will need to have Azure PowerShell installed on your DevOps agents (Azure Pipeline Agents). If your pipeline agents are Microsoft-hosted, then you’re good and all maintenance and software updates are taken care of for you. However, when you implement and install self-hosted agents, then additional software and component installation is solely your responsibility to maintain.

Recently, while I was configuring those pre- and post-deployment scripts for my Azure Data Factory deployment, I received the following error message, “Could not find the modules: 'Az.Accounts' with Version: ''”. 

So, I followed all the instructions from this information resource - Install the Azure Az PowerShell module, to install Azure PowerShell in my Azure VM that hosted my pipeline agent, however, the same error kept coming.

After troubleshooting this for a little while, I realized my first mistake was that installation was done not for the -AllUsers, but only for -CurrentUser

The AllUsers scope installs modules in a location that is accessible to all users of the computer:

$env:ProgramFiles\PowerShell\Modules

The CurrentUser installs modules in a location that is accessible only to the current user of the computer. For example:

$home\Documents\PowerShell\Modules

But even after installing the complete set of Azure PowerShell modules for the AllUsers scope, I kept getting this error message, that 'Az.Accounts' module was nowhere to be found.


Then I decided to take a leap of faith and manually copied all the Azure modules from my current user folder: C:\Users\<current user>\Documents\PowerShell\Modules to the system folder that Agent tried to use: C:\Windows\System32\WindowsPowerShell\v1.0\Modules.



I didn't expect this, but the next deployment run was successful, my family heard my shout of joy and my youngest daughter came down to my office in the basement to check on me :-)


I’m not %100 sure that this will solve all of my future Azure Data Factory deployment issues since I’m not a DevOps engineer, but I least I will remember it as a story and remind myself of one possible solution for this error message, “Could not find the modules: 'Az.Accounts' with Version: ''”.


Comments

Post a Comment