Azure广告应用程序-以编程方式更新清单 [英] Azure ad app - Updating manifest programmatically
问题描述
我正在尝试找到一种方法,利用json文件通过Powershell更新Azure Ad注册的应用程序的清单.
I am trying to find a way to update an Azure Ad registered app's manifest via powershell, utilizing a json file.
Json文件包含所有应用程序角色,我想简单地将应用程序角色:[]直接插入到应用程序角色括号中
The Json file contains all of the app roles, and i would like to simple inject the App Roles: [] right into the App Role Brackets
有没有一种方法可以通过Power Shell或CLI来实现?
Is there a way to achieve this via power shell or CLI?
推荐答案
是的,您可以通过PowerShell更新Azure AD应用程序的清单.
Yes you can update the Azure AD Application's manifest through PowerShell.
专门用于添加应用程序角色,这是一个PowerShell脚本.
Specifically to add App Roles, here's a PowerShell script.
如果您在创建新应用程序时尝试执行此操作,只需使用New-AzureADApplication
而不是Set-AzureADApplication
.
In case you're trying to do this while creating a new application, just use New-AzureADApplication
instead of Set-AzureADApplication
.
Connect-AzureAD -TenantId <Tenant GUID>
# Create an application role of given name and description
Function CreateAppRole([string] $Name, [string] $Description)
{
$appRole = New-Object Microsoft.Open.AzureAD.Model.AppRole
$appRole.AllowedMemberTypes = New-Object System.Collections.Generic.List[string]
$appRole.AllowedMemberTypes.Add("User");
$appRole.DisplayName = $Name
$appRole.Id = New-Guid
$appRole.IsEnabled = $true
$appRole.Description = $Description
$appRole.Value = $Name;
return $appRole
}
# ObjectId for application from App Registrations in your AzureAD
$appObjectId = "<Your Application Object Id>"
$app = Get-AzureADApplication -ObjectId $appObjectId
$appRoles = $app.AppRoles
Write-Host "App Roles before addition of new role.."
Write-Host $appRoles
$newRole = CreateAppRole -Name "MyNewApplicationRole" -Description "This is my new Application Role"
$appRoles.Add($newRole)
Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $appRoles
这篇关于Azure广告应用程序-以编程方式更新清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!