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

AzurePowerShell@5执行Connect-AzAccount时提示FederatedToken参数不存在

问题解决:Azure PowerShell 2.6.0 中 Connect-AzAccount 找不到 FederatedToken 参数

问题根源

Az PowerShell 2.6.0 版本不支持-FederatedToken参数,该参数是在 Az PowerShell 3.0.0 及以上版本才引入的,用于联合身份认证场景。而 AzurePowerShell@5 任务在使用联合凭证类型的服务连接时,会自动向Connect-AzAccount传递该参数,导致旧版本模块无法识别,触发报错。

解决方案

1. 升级 Az PowerShell 模块版本

在 AzurePowerShell@5 任务中指定 3.0.0 及以上版本的 Az 模块,配置示例:

- task: AzurePowerShell@5
  inputs:
    azureSubscription: '你的联合凭证服务连接名称'
    ScriptType: 'InlineScript'
    Inline: '# 无需手动调用 Connect-AzAccount,任务会自动完成认证'
    azurePowerShellVersion: 'OtherVersion'
    AzModuleVersion: '3.0.0' # 也可指定'Latest'使用最新稳定版

2. 移除手动调用的 Connect-AzAccount

AzurePowerShell@5 任务在配置正确的联合凭证服务连接后,会自动完成 Azure 账户的认证流程,不需要在脚本中手动执行Connect-AzAccount,手动调用反而会和任务内置的认证逻辑冲突。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 00:42:08