如何通过 Az 模块 PowerShell 脚本或 C# 代码更新 AAD 应用程序的更新清单

问题描述 投票:0回答:1

我是 Microsoft Entra id 的新手,正在尝试使用 Az 模块 powerhsell 脚本创建应用程序注册,并且还想使用以下内容更新其清单文件

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

下面的脚本我用来创建应用程序注册,并且需要修改此 powershell 脚本以更新清单文件。

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)"
}
manifest azure-powershell azure-app-registration microsoft-entra-id powershell-az-module
1个回答
0
投票

AFAIK,目前 Azure Az

 PowerShell 模块中没有可用的命令,可直接允许使用 
trustedCertificateSubjects 更新 Azure AD 应用程序的清单。
仅可以通过编程方式更新此 

MS 文档

中定义的预定义清单参数。 目前,您只能通过 Azure 门户中的

Manifest

选项卡手动更新它,如下所示:

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

enter image description here要使用

Az

PowerShell 更新这些属性,您可以在 Azure 反馈门户 发布此想法,该门户由产品团队监控以进行功能增强。

© www.soinside.com 2019 - 2024. All rights reserved.