How to Update Update manifest of AAD app via Az module PowerShell script or C# code

99 Views Asked by At

I am new to Microsoft Entra id and trying to create App register using Az module powerhsell script and also wants to update its manifest file with below

"trustedCertificateSubjects": [
    {
        "authorityId": "00000000-0000-0000-0000-000000000001",
        "subjectName": "subjectname1",
        "revokedCertificateIdentifiers": []
    },
    {
        "authorityId": "00000000-0000-0000-0000-000000000001",
        "subjectName": "subjectname2",
        "revokedCertificateIdentifiers": []
    }
]

Below Script I am using to create App register and need to modify this powershell script to update manifest file as well.

param(
    [Parameter(Mandatory=$true)]
    [string]$Environment,
    [Parameter(Mandatory=$true)]
    [string]$PartnerName
)
switch ($Environment) {
    'test' {
        $PartnerAppSuffix = '-test'
    }
    'dev' {
        $PartnerAppSuffix = '-dev'
    }
}
# Check if the app already exists
$App = Get-AzADServicePrincipal -Filter "DisplayName eq '$PartnerName$PartnerAppSuffix'"

if ($App -eq $null) {
    # If the app doesn't exist, create a new one
    $appName = $PartnerName+$PartnerAppSuffix
    $redirectUris = @("https://mscloud.onmicrosoft.com/$appName")
    $secretName = "secretKey"

    $App = New-AzADApplication -DisplayName $appName `
        -ReplyUrls $redirectUris `
        -Homepage "https://mscloud.onmicrosoft.com/$appName" `
        -IdentifierUris "https://mscloud.onmicrosoft.com/$appName" `
        -Web @{
            ImplicitGrantSetting = @{
                EnableAccessTokenIssuance = $true
                EnableIdTokenIssuance = $true
            }
        }

    # Create a new service principal for the app
    $ServicePrincipal = New-AzADServicePrincipal -ApplicationId $App.AppId

    Write-Host "New app registration created. AppId: $($App.AppId)"
} else {
    Write-Host "App registration '$PartnerName' already exists. AppId: $($App.AppId)"
}
0

There are 0 best solutions below