Security Compliance

Importing ARM template causes the error "The given key was not present in the dictionary."

Following this article, you will be able to solve template errors in ARM.

First published date

1/27/2022 10:40 AM

Last published date

7/26/2023 4:22 PM

Overview

This article will help you to troubleshoot the ARM template issue and solve the problem for the error "The given key was not present in the dictionary."

Product section

Access Rights Manager

Cause

The error "The given key was not present in the dictionary" is caused by two possible problems listed below.
  1. The wrong "DefaultValue" value was entered in the template.
  2. The default value was not listed as an item per se in the list above its definition.

Resolution

From the error message "The given key was not present in the dictionary" we know that we didn't made mistake for the Items definition and value for OU. If the OU path was wrong, it would tell us that there is no OU like we have defined in our domain.

Instead what error points out is to the "DefaultValue" key.
Here is the OU code section again:
 
     "OrganizationalUnit": {
      "IsHiddenFromRequester": false,
      "Definition": {
        "Type": "DropDownList",
        "Label": "['en-us:Organizational unit', 'de-de:Organisationseinheit', 'fr-fr:Unité organisationnelle']",
        "Items": [
          {
            "Value": "OU=ARM-Test,DC=arm,DC=local",
            "DisplayValue": "Test OU"
          },
        ],
        "DefaultValue": "OU=ARM-Tsest,DC=arm,DC=local"
      }
    },

Notice the "DefaultValue" and how it is different than the actual OU value.
This small typo is causing the issue and all that needs to be done is to change it to the correct value, like so:
 
     "OrganizationalUnit": {
      "IsHiddenFromRequester": false,
      "Definition": {
        "Type": "DropDownList",
        "Label": "['en-us:Organizational unit', 'de-de:Organisationseinheit', 'fr-fr:Unité organisationnelle']",
        "Items": [
          {
            "Value": "OU=ARM-Test,DC=arm,DC=local",
            "DisplayValue": "Test OU"
          },
        ],
        "DefaultValue": "OU=ARM-Test,DC=arm,DC=local"
      }
    },