-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIXED: Az Registration script RegisterWithAzure.psm1 throwing -- InvalidRegistrationToken : The registration token is malformed. #597
Comments
I have worked through this issue and have successfully registered my ASDK. The issue was a Win32_PhysicalMemory WMI query incorrectly returning the number of slots of RAM (returning 21 slots instead of 32, and returning 32 MB per slot, rather than 32GB per slot. It is almost like the WMI query was returning the total RAM across all CPU sockets for each slot. For example, my MB has 4 CPUs, of 8 slots each, each with 8GB of RAM, but the WMI query would report something like all slot1 memory across all CPU sockets, returning slot1=32MB, slot2=32MB, [...] up to 21 times (rather than the expected 32 times). Ideally, if done correctly, it would have reported on a per slot per socket basis, and returned 8GB 32 times (once per physical slot per physical CPU socket). Since the WMI query was also returning number of bytes, incorrectly by a factor of 1000, I was considering the bad workaround of dividing by 1MB rather than 1GB, but found a better solution. Both of these two WMI issues (number of slots, and MB instead of GB) were worked around by not using the WMI query and using the "CsTotalPhysicalMemory" property of "get-computerinfo", which is shown further below. In summary, this is the file with the line of text responsible for the issue: This is the line responsible for the issue: It can be fixed by replacing it with: Below are the details on how I figured it out. ============================================================================ I opened a remote PowerShell session to AzS-ERCS01: I entered the following command to AS-ERCS01 , which was being used in C:\AzureStack-Tools-az\Registration\RegisterWithAzure.psm1
This gave me the same registration token that was in the output of the registration script, to use for troubleshooting.
Which returned:
I then knew to look into a module called "Microsoft.Azurestack.Activation" to see how the registration token was being formed. I found the module responsible for the token here: The code responsible for creating forming the token is in between lines 272 and go to 290.
I pasted my registration token (the output of the New-RegistrationToken command above) into a variable called $registrationtoken. I then converted the string to a byte array:
Then from the byte array to a string: I was then left with about a 3000 character single line of text that was human readable but all squished onto a single line. I pasted it into Notepad++ and reformatted into something more friendly using the "Hex Editor" plugin, by searching for a the hex value of a comma (2c), and replacing with a comma followed by carriage return line feed (2c 0d 0a). I then tabbed out the sections based on curly braces and separated the sections with carriage returns. I did this again for my registration token that I had recorded from a prior successful ASDK registration from last year on build 1.1910.0.58 and compared it to the 1.2008.0.59 token. I used ComareIt to compare the two human readable registration arrays. New values in registration array compared between build 1910 and 2008:
Seeing the "TotalMemoryInGB" value of 0.65625 GB did not make sense to me, since my ASDK host has 256GB installed.
This line looked like it might be suspect, so I ran the following WMI query:
It returned the following, incorrectly saying that I have 21 slots of 32MB sticks. 33554432 Summing them together: Dividing by 1GB: My ASDK host actually has 4 sockets of AMD Opteron 8439 hexa-core CPUs (4x6 = 24 total cores), each CPU has 8 RAM slots fully populated with 8GB sticks (4x8x8 = 256GB total). The WMI query is at fault, saying that it has just over half a GB of RAM. The WMI query should have returned 8589934592 (8GB sticks) and returned it 32 times (rather than 21), as the motherboard has 32 memory slots that are fully populated. The sum of which should have been 274877906944 (256GB). I commented out the line with the faulty WMI query and added a line to replace it: This correctly set TotalMemoryInGB=256, and fixed the malformed registration token error, allowing my ASDK to successfully register. Please update the function The fix above will allow those of us with these older AMD Opteron motherboards to continue to use the ASDK with the Azure marketplace in our affordable home-built labs. If you decide not to update with this fix, then please let this comment remain for those of us in the future who would like to have a process to troubleshoot malformed oken related issues. I am very glad to finally see this: |
|
I have deployed ASDK version 1.2008.0.59. The installation was successful. I am now trying to register the ASDK under one of my subscription's tenant.
The resource group "azurestack" is successfully created in 'westcentralus' by the registration script, as I can see it show up in the Azure portal.
I've been deleting this resource group each time I reattempt the ASDK registration command.
I'm performing an AzureCloud deployment (not ADFS). I'm running it under the context of the global admin account of the tenant.
Here's my PowerShell version that I'm running:
I'm running the "Az" branch of the AzureStack-Tools on GitHub:
https://github.com/Azure/AzureStack-Tools/archive/az.zip
Here is what I'm using for the ASDK registration (with xxx in replacing sensitive info).
I am getting following error right after the resource group is created:
Line 1386 of RegisterWithAzure.psm1
It is called from:
Line 426 of RegisterWithAzure.psm1
The values of the variables in the above line look correct with the exception of the $RegistrationToken, which does not end in a double equal sign as I would expect.
I successfully registered my ASDK using this same tenant last year. I blew that ASDK install away to upgrade to 1.2008.0.59. I deleted the old resource group in Azure before attempting this registration.
The only thing that might be different this time is that I'm using the newer Az modules, rather than the older AzureRM modules.
Here is the LOG, with my sensitive info XXX'ed out.
Do you have any ideas to try troubleshooting the validity of the $RegistrationToken.
Shouldn't a valid token end in "==", rather than just a single "=" ?
As a troubleshooting step, I also tried this:
The token returned by "New-RegistrationToken" on AzS-ERCS01 appears the same as the one returned by the RegisterWithAzure.psm1 script. Both tokens are 4096 chars long and end in a single "=".
I'm thinking the issue must be in one of three areas:
I have not yet tried the AzureRM modules yet, as it appears those will be retired soon.
Thank you in advance for your ideas in troubleshooting!
==================================================================================
The text was updated successfully, but these errors were encountered: