Skip to content

AADServicePrincipal - BUG - Subsequent run Fails on App Display name #5312

@pangjaa

Description

Description of the issue

DSC is able to provision and App Registration (AADApplication) and Service principal (AADServicePrincipal) with the AADServicePrincipal.AppId = AADApplication.DisplayName. However, a subsequent run of DSC fails for AAD Service Principal.

Image

Updating the AADServicePrincipal.AppId = AADApplication.ObjectId corrects the issue.

Related Bug: #4965 (comment)

Microsoft 365 DSC Version

1.24.1016.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

AADApplication 'AADApplication-NEWTESTAPP' {
    DependsOn               = @(
        '[AADApplication]AADApplication-Microsoft365DSC'
    )
    AvailableToOtherTenants = $False
    DisplayName             = 'NEWTESTAPP'
    Description             = 'NEWTESTAPP'
    Ensure                  = 'Present'
    # IdentifierUris          = @()
    KnownClientApplications = @()
    IsFallbackPublicClient  = $False
    Owners                  = @(
        $AppOwners.IliadIdentityApp
    )
    PublicClient            = $False
    ReplyURLs               = @()
    ApplicationId           = $ApplicationId
    TenantId                = $TenantId
    CertificateThumbprint   = $Thumbprint
}

# https://microsoft365dsc.com/resources/azure-ad/AADServicePrincipal/
AADServicePrincipal 'AADServicePrincipal-NEWTESTAPPSP' {
    DependsOn               = @(
        '[AADApplication]AADApplication-Microsoft365DSC'
    )
    AppId = 'NEWTESTAPP'
    DisplayName             = 'NEWTESTAPP'
    Ensure                  = 'Present'
    ServicePrincipalType    = 'Application'
    ApplicationId           = $ApplicationId
    TenantId                = $TenantId
    CertificateThumbprint   = $Thumbprint
}

Verbose logs showing the problem

##[error][Request_MultipleObjectsWithSameKeyValue] : The service principal cannot be created, updated, or restored because the 
service principal name c83defb3-cabc-48a2-b697-2a8a218e6a6f is already in use.
    + CategoryInfo          : InvalidOperation: ({ Headers = , b...vicePrincipal }:) [], CimException
    + FullyQualifiedErrorId : Request_MultipleObjectsWithSameKeyValue,Microsoft.Graph.PowerShell.Cmdlets.NewMgServiceP 
   rincipal_CreateExpanded

Environment Information + PowerShell Version

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions