Insights Provisioning Logs Fail With KeyNotFoundException

Insights provisioning logs fail with "KeyNotFoundException" .

Issue Description: Insights Provisioning logs fail with KeyNotFoundException.

The specific error will look like:

System.Collections.Generic.KeyNotFoundException: The given key 'XXXX-XXXX-XXXX-XXX' was not present in the dictionary.

at System.Collections.Generic.Dictionary`2.get_Item(TKey key)

at InsightsProvisioning.Jobs.OrchestratorTenantJob.Execute(IJobExecutionContext context) in D:\a\1\s\InsightsInstaller\Insights\Cloud\Provisioning\src\InsightsProvisioning\Jobs\OrchestratorTenantJob.cs:line 81

Root Cause: There are scenarios where the Orchestrator table dbo.tenants has the key and accountId columns in uppercase values. However, in newer versions they will be lowercase. This typically only happens with older versions of Orchestrator.

Diagnosing / Resolving:

  1. Check the logs under %programdata%/UiPath Insights/Provisioning
  2. There should be an error about the OrchestratorTenantJob failing.
  3. Login to the Orchestrator DB using a sql client.
  4. Check the dbo.Tenants table. (Just do a select top 1000)
  5. See if the columns 'Key' and 'AccountId' are all capitalized.
  6. If they are, this is the issue. Making them lowercase will fix the problem.
  7. If there is a tenant that is lowercase, try just enabling that tenant and see if the error still occurs.
  8. To fix the issue, change the case of the fields (make sure to backup the DB before hand. Also make a note of the KEYs that are already lowercase).
    • UPDATE [UiPath].[dbo].[Tenants]

      set [key] = LOWER([key]), [AccountId] = LOWER([AccountId])

  9. To revert the change, run
    • UPDATE [UiPath].[dbo].[Tenants]

      set [key] = UPPER([key]), [AccountId] = UPPER([AccountId])

      WHERE [key] NOT IN ('xx-xx-xx-xx', 'xx-xx-xx-xx');

  10. Doing an IIS reset (or just recycling the Provisioning application pool) maybe necessary. The provisioning service tries to provision instance every 10 minutes so if this is not done, just wait 10 minutes at most.
  11. If the issue is still occuring, raise a ticket with UiPath and include the following
    • Screenshot of the dbo.tenants table
    • The provisioning logs mentioned above.