Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

AADApplication: Error Parsing HTML Report - Resource 'MSFT_MicrosoftGraphAppRole' requires that a value of type 'String' be provided for property 'Value'

Open jan-kre opened this issue 7 months ago • 10 comments

Description of the issue

When generating an HTML Report for the Resource AADApplication it fails with the error: ConvertTo-DSCObject : Error parsing DSC configuration: Exception calling "ConvertToDscObject" with "4" argument(s): "Error parsing configuration: Resource 'MSFT_MicrosoftGraphAppRole' requires that a value of type 'String' be provided for property 'Value'."

Microsoft 365 DSC Version

1.26.408.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

AppId                   = "ad1eae0f-XXXXXXXXXXXXXXXXXXXXXXX";
            ApplicationId           = 25f7a27f-XXXXXXXXXXXXXXXXXXXXXXX;
            ApplicationTemplateId   = "dee2cdc2-XXXXXXXXXXXXXXXXXXXXXXX";
            AppRoles                = @(
                MSFT_MicrosoftGraphappRole{
                    AllowedMemberTypes = @("User")
                    Description = "msiam_access"
                    DisplayName = "msiam_access"
                    Id = "7af25167-XXXXXXXXXXXXXXXXXXXXXXX"
                    IsEnabled = $True
                    Origin = "Application"
                }
                MSFT_MicrosoftGraphappRole{
                    AllowedMemberTypes = @("User")
                    Description = "User"
                    DisplayName = "User"
                    Id = "8d17fe88-XXXXXXXXXXXXXXXXXXXXXXX"
                    IsEnabled = $True
                    Origin = "Application"
                }
            );

Verbose logs showing the problem

ConvertTo-DSCObject : Error parsing DSC configuration: Exception calling "ConvertToDscObject" with "4" argument(s):
"Error parsing configuration: Resource 'MSFT_MicrosoftGraphAppRole' requires that a value of type 'String' be provided
for property 'Value'."
At C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.26.408.1\Modules\M365DSCReport.psm1:1895 char:22
+     $parsedContent = ConvertTo-DSCObject @params
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,ConvertTo-DSCObject

Exception calling "ConvertToDscObject" with "4" argument(s): "Error parsing configuration: Resource
'MSFT_MicrosoftGraphAppRole' requires that a value of type 'String' be provided for property 'Value'."
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\3.0.0.2\DSCParser.psm1:164 char:13
+             $result = [DSCParser.CSharp.DscParser]::ConvertToDscObjec ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidOperationException

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2022 Datacenter Azure Edition
OsOperatingSystemSKU : 407
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Key   : PSVersion
Value : 5.1.20348.4294
Name  : PSVersion

Key   : PSEdition
Value : Desktop
Name  : PSEdition

Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions

Key   : BuildVersion
Value : 10.0.20348.4294
Name  : BuildVersion

Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion

Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion

Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion

jan-kre avatar Apr 14 '26 12:04 jan-kre

As the error implies the property Value is missing from your blueprint, did you create it manually or exported it with an old M365DSC version? It's highly likely you exported this before Value was changed from Write to Required so you need to take a new export which includes that property.

@FabienTschanz I bet this resource also reports a drift because of Id just like the one I've reported on #7062 which is mildly annoying if you have to scavenge through every single resource and all their CIM instances and having to exclude the properties individually so that they're not compared.

ricmestre avatar Apr 14 '26 13:04 ricmestre

@ricmestre Gotcha. I should probably update my PR from two minutes ago to always exclude Id per default and make the resources explicitly include it that really require it. How does that sound?

FabienTschanz avatar Apr 14 '26 13:04 FabienTschanz

That probably will fix a ton thank you, but I still think there will always be an odd duck here and there like Identity or something similar, this wasn't a problem before with the old comparison engine as far as I can remember?

ricmestre avatar Apr 14 '26 13:04 ricmestre

As the error implies the property Value is missing from your blueprint, did you create it manually or exported it with an old M365DSC version? It's highly likely you exported this before Value was changed from Write to Required so you need to take a new export which includes that property.

Hi @ricmestre I did a fresh DSC Export with the current DSC Version and tried to generate the HTML Report for it.

jan-kre avatar Apr 14 '26 13:04 jan-kre

@ricmestre The only affected resources with child instances that have the Id parameter are the ones for the authentication methods. I suggest we exclude Id and Identity for now and watch if they drift - The main key comparison should still catch them for the comparison.

Regarding the other issue that the value is empty... Microsoft outdid themselves again. How do you create an app role with an empty value? No idea, but it's there. You cannot update it without assigning it a value. Please don't ask me why that is.

Image

I need to check now if we can somewhat fix this.

FabienTschanz avatar Apr 14 '26 15:04 FabienTschanz

Yeah I saw your PR let's hope that covers most of the false positives and yeah graph api can sometimes make your blood boil, someone just forgot to set value as required in their metadata...

ricmestre avatar Apr 14 '26 15:04 ricmestre

@FabienTschanz is there a way for me to manually patch the ComplexObjectConverter.cs file so that I can test this fix before the official release?

jan-kre avatar Apr 15 '26 11:04 jan-kre

You can download the source code, patch the file, build the module, generate the SchemaDefinition.json and then try it. Or you ping me on LinkedIn and I‘ll share a zip with a version for you to test.

FabienTschanz avatar Apr 15 '26 12:04 FabienTschanz

Just tested the fix: works like a charm!

jan-kre avatar Apr 15 '26 14:04 jan-kre

I also have this issue, hope the official release is soon :)

Sheep-NZ avatar Apr 22 '26 04:04 Sheep-NZ