(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:
The CurrentUser installs modules in a location that is accessible only to the current user of the computer. For example:
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.