Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Missing or incomaptible module version. #317

Closed
ranabanerjee15 opened this issue Nov 19, 2020 · 7 comments
Closed

Missing or incomaptible module version. #317

ranabanerjee15 opened this issue Nov 19, 2020 · 7 comments
Assignees

Comments

@ranabanerjee15
Copy link

ranabanerjee15 commented Nov 19, 2020

Getting the following error while executing Get-AzMigDependenciesAgentless

I have tried running in Version 5.1 Powershell 7.1, both have the same error
Az.Accounts version is 2.2.1
image

On further investigation found that

$TokenCache = $CurrentContext.TokenCache in the function function GetRequestProperties() is null. I have tried with Az module 1.9.5 still no luck. my scenario is B2B. I am assuming this should work regardless

maybe Get-AzAccessToken can be used to make it compatible

Is there any other way to extract this data? am keen to use the Bi template

hope for a fix soon, Plz Help

@mikefrobbins mikefrobbins assigned musa-57 and Vikram1988 and unassigned musa-57 Nov 20, 2020
@shoootyou
Copy link

shoootyou commented Nov 23, 2020

Hello @ranabanerjee15 ,
I had the same escenario but, when i checked on the debug process I found the problem for my case.
I changed my username a couple days ago but, on Azure still said the older login name and on the code use the name of the token. It was the old UPN. I force to use my current UPN by:

Change the line 26 from
$UserId = $CurrentContext.Account.Id
to this:
$UserId = Read-Host -Prompt "Type your UPN"

After this, import the module againg and write your actual UPN when the code ask. With this, everything works. I used Az.Account 1.9.5 version. For the version 2.2.1 the field TokenCache it's missing, so I highly recommend use the module on version 1.9.5

Try for yourself!

Hello @Vikram1988,

I didn't find any way to get the current user, maybe you know a way for this cases.

Thanks!

@Vikram1988
Copy link
Contributor

Vikram1988 commented Nov 23, 2020

@shoootyou , your analysis about TokenCache missing for the latest Az.Account version is correct as found here: Azure/azure-powershell#13337

While it is recommended even in this thread to use the lower version of 1.9.5, I am working towards the changes required in AzMig_Dependencies.psm1 with the dev team.

@Vikram1988
Copy link
Contributor

AzMig_Dependencies.txt

I have made some edits to the module AzMig_Dependencies.psm1 and tested it with PowerShell 5.1 and Cloud Shell.

PFA the module (renamed as .txt), rename the extension to .psm1 and import the module and try running the following cmdlet again: Get-AzMigDependenciesAgentless.

Please let me know if you continue to hit the issue.

@MSNina123456
Copy link

Hi Team,
Per update here: Azure/azure-powershell#13337, the issue should be fixed with version 2.2:
erich-wang commented 11 days ago
Close the issue as Get-AzAccessToken has been provided in Az.Accounts 2.2 which will be released on Nov 17.

However our cx updated to version 2.2.1 but still have same issue, please reopen to check:
image
11/26/2020 5:48:58 AM Warning TenantId 'fedfd771-b82e-47b1-a705-959f02fe7ded' contains more than one active subscription. First one will be selected

for further use. To select another subscription, use Set-AzContext.

11/26/2020 5:49:09 AM Output 1 - Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext

11/26/2020 5:49:09 AM Error You cannot call a method on a null-valued expression.

At line:69 char:1

  • $cacheItem = $cache.ReadItems()

  • 
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    
      + FullyQualifiedErrorId : InvokeMethodOnNull
    
    
    
    

11/26/2020 5:49:10 AM Error Cannot index into a null array.

At line:70 char:1

  • $AccessToken = $cacheItem[$cacheItem.Count -1].AccessToken

  • 
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    
      + FullyQualifiedErrorId : NullArray
    

@mikefrobbins
Copy link
Contributor

Closing this issue based on the response from @MSNina123456. @ranabanerjee15 if you still experience problems, let us know and we'll reopen this issue.

@MSNina123456
Copy link

Closing this issue based on the response from @MSNina123456. @ranabanerjee15 if you still experience problems, let us know and we'll reopen this issue.

?? I mentioned the issue should be fixed, but it still persists, could you please check my update with error message again? Thanks

@MSNina123456
Copy link

I got possible solution: TokenCache is removed from the updated Az.Accounts, you should use Get-AzAccessToken in the script

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants