首页 > 解决方案 > 使用 Set-AzureADApplicationProxyApplication 设置 ConnectorGroupId 的问题

问题描述

我的代码如下:

$aadapConnectorGroups=Get-AzureADApplicationProxyConnectorGroup -Top 100000 


foreach ($item in $aadapConnectorGroups)
 {
    
   If ($item.ConnectorGroupType -eq "applicationProxy" -And $item.Name -eq $ConnectorGroupIdName)
    {
        
         New-AzureADApplicationProxyApplication `
        -DisplayName  $ApplicationName `
        -ExternalUrl $ExternalUrl `
        -InternalUrl $InternalUrl `
        -IsHttpOnlyCookieEnabled $isHttpOnlyCookieEnabled `
        -ApplicationServerTimeout $applicationServerTimeout `
        -IsPersistentCookieEnabled $isPersistentCookieEnabled `
        -ConnectorGroupId $item.ObjectID             
        
    }

 } 

当我尝试设置ConnectorGroupIdwith时出现以下错误Set-AzureADApplicationProxyApplication

Error occurred while executing SetApplicationProxyApplication Code:
Request_ResourceNotFound Message: Resource
'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx' does not exist or one of its queried
reference-property objects are not present.

我在创建新的 Azure AD 应用程序代理应用程序时遇到同样的错误New-AzureADApplicationProxyApplication

当我尝试默认的ConnectorGroupId时,它工作得很好。所以我想问题出在我最近创建的ConnectorGroup上。但是,在门户上,我看到我的新连接器组已创建并且运行良好。

使用Get-AzureADApplicationProxyConnectorGroup命令,我也可以看到我的新连接器组。

我可以从门户将它分配给 AzureADApplicationProxyApplication 。所以从逻辑上讲,它也应该在 cli 中工作。

你知道为什么我有这个错误吗?

编辑:我也尝试了以下命令:

 Set-AzureADApplicationProxyApplication -ObjectId $item2.ObjectID
 -ConnectorGroupId $item.ObjectID -Verbose

虽然它返回了成功消息,但它并没有更改应用程序的 ConnectorGroupId。我已经从门户网站和 cli 进行了验证。

标签: azureazure-active-directoryazure-powershell

解决方案


Error occurred while executing SetApplicationProxyApplication Code:
Request_ResourceNotFound Message: Resource
'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx' does not exist or one of its queried
reference-property objects are not present.

此错误意味着-ObjectId不存在,而不是-ConnectorGroupId.

当您使用 来创建新的 Azure AD 应用程序代理应用程序时New-AzureADApplicationProxyApplication,您不需要指定-ObjectId,所以我不确定您为什么会收到此错误。

您需要指定正确的对象 ID:

New-AzureADApplicationProxyApplication -DisplayName "Finance Tracker10" -ExternalUrl $externalUrl -InternalUrl $internalUrl -ConnectorGroupId $connectorGroupId

$app = Get-AzureADApplication -Filter "DisplayName eq 'Finance Tracker10'"

Set-AzureADApplicationProxyApplication -ObjectId $app.ObjectId -ConnectorGroupId $newConnectorGroupId -ExternalUrl $newExternalUrl -InternalUrl $newInternalUrl1

推荐阅读