microsoft / Dynamics365Commerce.Solutions

Repository for hosting the Dynamics 365 Commerce end to end sample solutions
Other
54 stars 26 forks source link

Error running install task #98

Closed pkilli closed 5 months ago

pkilli commented 1 year ago

I am getting error on step 16/27 when trying to install and having UseSelfHost = true:

Microsoft.Dynamics.Commerce.Installers.Framework.Security.SetCertificatePrivateKeyPermission: Grant the user account a permission to read a certificate's private Key

GrantingReadPermission Granting account xxx a Read permission to the file C:\ProgramData\Application Data\Microsoft\Crypto\RSA\MachineKeys\xxxx representing the certificate's private key.

StepFailedWithException [16/27] Step Microsoft.Dynamics.Commerce.Installers.Framework.Security.SetCertificatePrivateKeyPermission failed with System.InvalidOperationException: The method failed with unexpected error code 3.

when searching for the Machine key in C:\ProgramData\Application Data\Microsoft\Crypto\RSA\MachineKeys, i notice that there are no such directory.

The machineKey is located at C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys

The commerce scale unit is: 10.0.32 - Commerce Scale Unit (SEALED)

Pikhulya commented 1 year ago

How did you run the installer - by using VS Code or from within the command line? If from the command line - please share:

a) the command line used b) The edition and version of the Windows c) Specific version of the Commerce Scale Unit Installer as seen in LCS's Shared Assets Library d) Whether the user used to run the installer had an Admin permissions or not e) Re-run the installer by appending --Verbosity Trace and see if the log will contain more information, in particular, I'm interested to know if the log will contain something like: Granting account {accountName} a Read permission to the file {filePath} representing the certificate's private key and/or a stack trace corresponding to the exception.

pkilli commented 1 year ago

I ran the installer using VS Code.

The edition of windows i am using: Windows 11 Enterprise 22H2 Windows Feature Experience Pack 1000.22641.1000.0

specific version og scale unit installer: Retail version 9.43.23125.15 Asset ID 9104665b-f8a6-4960-bed2-dd686622029c

user used to run the installer had an Admin permission.

[Information] ExecutingStep [16/27] Executing step Microsoft.Dynamics.Commerce.Installers.Framework.Security.SetCertificatePrivateKeyPermission: Grant the user account a permission to read a certificate's private Key 14:23:46 [Debug] GrantingReadPermission Granting account {accountName} a Read permission to the file C:\ProgramData\Application Data\Microsoft\Crypto\RSA\MachineKeys\{MachineKey} representing the certificate's private key. 14:23:46 [Debug] StepFailedWithException [16/27] Step Microsoft.Dynamics.Commerce.Installers.Framework.Security.SetCertificatePrivateKeyPermission failed with System.InvalidOperationException

Pikhulya commented 1 year ago

@pkilli , I could not reproduce the issue by using Windows 11 Enterprise 22H2 and the same version of the installer you used.

Can you confirm the Visual Studio Code was run by using "Run as administrator" option ?

Please do these experiments:

a) Open Certificate store: mmc.exe to add Certificates snap-in->Computer account->Local Computer->Finish->OK b) Navigate to Personal->Certificates and locate there the certificate where the "Issued by" equals to "Dynamics 365 Self-Hosted Sample Retail Server" c) Right click the certificate->All tasks->Managed Private Keys - do you see there the account used to run the VS Code? If not - can you add it there and then try executing the "install" command in the VS Code to see if there will be any differences? d) If the same issue will still take place try to open the private key file seen in the log in a notepad - will you be able to do that? e) If by this time VS Code still produces the issue then remove the certificate and re-run the "install" command through VS Code again. f) If the same issue still takes place run the installer from within Command Line, outside of VS Code, by following Deploying in a Self-Hosted mode

pkilli commented 1 year ago

I can confirm that i ran Visual Studio Code by using "Run as administrator"

None of the above experiments worked.

I did manage to execute the install command by creating the path C:\ProgramData\Application Data\Microsoft\Crypto\RSA\MachineKeys\ on my machine and copying the Machine key the installer was trying to granting permission to, from C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys

Pikhulya commented 10 months ago

We still are unable to reproduce it in several different environments, are you still seeing the issue (if you don't apply your above workaround) with recent versions of the SDK ?

pkilli commented 5 months ago

I am closing this issue as i am able to build the and install