You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Remove-AzureADApplication删除Azure应用注册报错,寻求协助

解决Remove-AzureADApplication执行时的Request_BadRequest错误

我正在构建清理脚本,用于删除Azure云账户中的应用注册。已参考Azure文档编写删除命令,且拥有手动删除应用注册的权限,但执行命令时失败。

执行的命令:

Remove-AzureADApplication -ObjectId "$appRegistryObjectId"

收到的错误信息:

Remove-AzureADApplication: Error occurred while executing RemoveApplication
Code: Request_BadRequest
Message: Value cannot be null.
Parameter name: requestContext
RequestId: 948d5c0c-e012-4ae8-b042-e6ae84ad4512
DateTimeStamp: Sun, 15 Oct 2023 12:31:29 GMT
HttpStatusCode: BadRequest
HttpStatusDescription: Bad Request
HttpResponseStatus: Completed

排查及解决建议

  • 检查AzureAD模块版本:旧版本的AzureAD模块存在requestContext参数的已知bug,先运行Get-Module AzureAD查看当前版本,执行Update-Module AzureAD更新到最新稳定版后重试。
  • 验证ObjectId有效性:确认$appRegistryObjectId变量已正确赋值,无空值或格式错误。可先执行Get-AzureADApplication -ObjectId "$appRegistryObjectId",验证是否能正常返回目标应用注册信息。
  • 重新建立AzureAD连接:若模块更新后问题依旧,先执行Connect-AzureAD重新建立会话,确保上下文加载正常后再执行删除命令。
  • 迁移到Microsoft Graph模块:AzureAD模块已进入维护状态,推荐使用Microsoft Graph PowerShell模块替代,对应删除命令为:
    # 先安装模块(首次使用)
    Install-Module Microsoft.Graph.Applications
    # 连接并授予权限
    Connect-MgGraph -Scopes "Application.ReadWrite.All"
    # 删除应用注册
    Remove-MgApplication -ApplicationId "$appRegistryObjectId"
    

内容的提问来源于stack exchange,提问作者omer blechman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 08:07:09