Azure / azure-powershell-migration

Tools and resources to help migrate PowerShell scripts between incompatible versions of Az and AzureRM modules
MIT License
35 stars 18 forks source link

Connect-azAccount is not working and I still see things like AzurerRm.Profile in my scripts #135

Open Blueposey opened 10 months ago

Blueposey commented 10 months ago

when I do Connect-AzAccount I get: Warning Unable to acquire token for tenant 'organizations with error Exception has been thrown by the target of an invocation Connect-azAccount : Exception has been thrown by the target of the invocation at line:1 Char:1 Connect-AzAccount category Info : CloseError (:) [Connect-AzAccount, TartetInvocationException FullyQualifiedErrorId: Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

*Component** [] Az.resources 6.14.0

Environment windows 11 I am running Powershell ISE as Administrator

Error output Warning Unable to acquire token for tenant 'organizations with error Exception has been thrown by the target of an invocation Connect-azAccount : Exception has been thrown by the target of the invocation at line:1 Char:1 Connect-AzAccount category Info : CloseError (:) [Connect-AzAccount, TartetInvocationException FullyQualifiedErrorId: Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

Additional context I originally had AzureRm installed and upgraded it to azureRm 6.13.3 per the tool migration instructions I ran my scripts and they all worked I uninstalled AzureRm and Installed Azure Az ran the migration tool Everything says it converted successfully without issue.

but when I ran my scripts I got some errors. I still see things like AzureRm.Profile in my scripts even though I ran the migrate tool and I thought those items would have been updated? I tried just doing Connect-AzAccount to see if I could connect and I do get a pop up to select my azure account but after that I get the above error.
I can't send a bunch of logs from my work computer but I am wondering if everything with AzureRm should have been converted by the tool in my scripts and how can I connect? I tried doing the Update-Module Az.* but still can not login. Please help!

isra-fel commented 9 months ago

@Blueposey Hi, thanks for the feedback. Module names are not in the scope of the conversion today. But you can simply replace AzureRm.Profile with Az.Accounts.

isra-fel commented 9 months ago

Regarding the error of Connect-AzAccount the error message itself doesn't tell us much. Best if you could provide the full debug log (remove any sensitive info before posting). Other things to try:

  1. Run Get-Module Az* -ListAvailable to double check you have uninstalled azurerm and installed az only
  2. Run Clear-AzContext -Force to clean up token cache
  3. Run it in PowerShell 7 instead of Windows PowerShell