The specified module 'Az.Accounts' was not loaded because no valid module file was found in any module directory

Mithila Lishan 141 Reputation points
2024-05-21T06:19:30.23+00:00

I am in the process of upgrading azure 'run-as-account' to 'manage-identities'. there were power-shell script that used to automate VM functionalities.

I import "Az.Accounts" module from Module section

User's image

Module Name - Az.Accounts

Module version - 2.19.0

Runtime version - 7.2

i import that module inside powershell (edit in portal) and used like below

Import-module 'Az.Accounts'

Connect-AzAccount -Identity

but i am getting below error

Import-module : The specified module 'Az.Accounts' was not loaded because no valid module file was found in any module directory. At line:7 char:1 + Import-module 'Az.Accounts' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (Az.Accounts:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

what should i do to avoid above issue ?

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,174 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,272 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Mithila Lishan 141 Reputation points
    2024-05-21T10:34:17.5266667+00:00

    instead of using "AzAccount" and its import statement , I used "AzureRMAccount" module.

    this piece of code fixed my issue - Connect-AzureRMAccount –Identity