question

PKQTech-9892 avatar image
0 Votes"
PKQTech-9892 asked JamesOrlando-8391 answered

Unable to register ASDK: Get-AzToken : Unable to find type

Hi,

I have deployed ASDK version 1.2008.0.59. The installation was successful. I am now trying to register the ASDK using one of the accounts we have in our team. I am getting following error:

WARNING: Attempting to find a refresh token and an access token from the existing token cache data...
VERBOSE: 2021-02-16.06-24-32: Removing any existing PSSession...
Get-AzToken : Unable to find type [Microsoft.Azure.Commands.Common.Authentication.Authentication.Clients.AuthenticationClientFactory].
At C:\AzureStack-Tools-az\Registration\RegisterWithAzure.psm1:404 char:26
+ ... eshToken = (Get-AzToken -Context $AzureContext -FromCache -Verbose).G ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Azure...onClientFactory:TypeName) [Get-AzToken], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound,Get-AzToken

PS C:\Windows\system32>


We had registered ASDK using same account before but for some reason we had to re-deploy ASDK. We did that without de-registering. From what I have read online, we dont have to de-register in order re-deploy. Any idea what the error above is about?


I am using following script which is mentioned in ASDK docs:

Add the Azure cloud subscription environment name.


Supported environment names are AzureCloud, AzureChinaCloud, or AzureUSGovernment depending which Azure subscription you're using.

Connect-AzAccount -EnvironmentName "<environment name>"

Register the Azure Stack Hub resource provider in your Azure subscription

Register-AzResourceProvider -ProviderNamespace Microsoft.AzureStack

Import the registration module that was downloaded with the GitHub tools

Import-Module C:\AzureStack-Tools-az\Registration\RegisterWithAzure.psm1

If you have multiple subscriptions, run the following command to select the one you want to use:

Get-AzSubscription -SubscriptionID "<subscription ID>" | Select-AzSubscription


Register Azure Stack Hub

$AzureContext = Get-AzContext
$CloudAdminCred = Get-Credential -UserName AZURESTACK\CloudAdmin -Message "Enter the credentials to access the privileged endpoint."
$RegistrationName = "<unique-registration-name>"
Set-AzsRegistration -PrivilegedEndpointCredential $CloudAdminCred
-PrivilegedEndpoint AzS-ERCS01 -BillingModel Development
-RegistrationName $RegistrationName `
-UsageReportingEnabled:$true

azure-stack-hub
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Does anyone have any idea how to resolve this error?

0 Votes 0 ·
TravisCragg-MSFT avatar image
0 Votes"
TravisCragg-MSFT answered

Something tells me that there could be issues with your local PowerShell. Have you tried using the AzureRM module, as the Az module is still fairly new for the ASDK (its a different tab on the same page)?

Also, if this is not working on the ASDK host computer, you can always do the offline registration.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JamesOrlando-8391 avatar image
0 Votes"
JamesOrlando-8391 answered

This can be resolved by reinstalling the modules. I ran into this exact issue on a machine that previously had AzureRM installed. I removed Azure RM (Uninstall-AzureRM from Az module), then followed this doc: https://docs.microsoft.com/en-us/azure-stack/operator/powershell-install-az-module?view=azs-2008#:~:text=%20Install%20PowerShell%20Az%20module%20for%20Azure%20Stack,PowerShell%20modules.%20Before%20installing%20the%20required...%20More%20

Main thing being:
Get-Module -Name Azure* -ListAvailable | Uninstall-Module -Force -Verbose -ErrorAction Continue
Get-Module -Name Azs. -ListAvailable | Uninstall-Module -Force -Verbose -ErrorAction Continue
Get-Module -Name Az.
-ListAvailable | Uninstall-Module -Force -Verbose -ErrorAction Continue

After closing that PS session and starting with a fresh AZ install I was good to go. Also, make sure your Azure Stack Tools are AZ as well. The folder should be AzureStack-Tools-Az and not AzureStack-Tools-Master.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.