Вы можете использовать Get-AzADApplication с параметром -IdentifierUri
, чтобы проверить, существует ли уже приложение с этим IdentifierUri:
$appName = "yourappname123"
$uri = "http://yourappname123"
$secret = "yoursecret123"
$password = ConvertTo-SecureString -String $secret -AsPlainText -Force
# test if an app using that uri is already present
$app = (Get-AzADApplication -IdentifierUri $uri)
if ($app) {
Write-Warning "An app with identifier uri '$uri' already exists: '$($app.DisplayName)'"
# there already is an app that uses this identifier uri..
# decide what to do:
# - choose a new uri for the new app?
# - change the identifier uri on the existing app?
# you can do that using
# $app | Update-AzADApplication -IdentifierUri 'THE NEW URI FOR THIS APP'
}
else {
# all seems clear; create your new app
$azureAdApplication = New-AzADApplication -DisplayName $appName -HomePage $Uri -IdentifierUris $Uri -Password $password
}