AzurePowerShell@5 找不到参数 FederatedToken

问题描述 投票:0回答:1

我正在使用 Azure PowerShell 版本 2.6.0 在 Azure DevOps 管道中使用

- task: AzurePowerShell@5
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-powershell -v5?view=azure-pipelines

  - task: AzurePowerShell@5
    displayName: ${{ parameters.name }}
    inputs:
      azureSubscription: ${{ parameters.AzureSubscription }}
      ScriptType: InlineScript
      Inline: |
        Save-AzContext -Path <pathname>
      FailOnStandardError: true
      azurePowerShellVersion : 2.6.0
      pwsh: true

azureSubscription 设置为使用联合凭据进行身份验证的 Azure DevOps 服务连接。

AzurePowerShell@5 任务在运行

Connect-AzAccount
进行身份验证时失败。

Connect-AzAccount 失败并出现以下错误:

找不到与参数名称“FederatedToken”匹配的参数。

FederatedToken 应该是基于本文档的受支持参数:https://learn.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-11.6.0

更详细的日志:

##[debug]Connect-AzAccount: D:\a\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.239.9\ps_modules\VstsAzureHelpers_\InitializeAzModuleFunctions.ps1:438
##[debug]Line |
##[debug] 438 |              & $command @args
##[debug]     |                         ~~~~~
##[debug]     | A parameter cannot be found that matches parameter name 'FederatedToken'.

PowerShell 版本 2.6.0 可能不支持 FederatedToken 作为参数,但我没有看到任何表明该信息的文档。

azure-devops azure-pipelines azure-powershell azure-pipelines-build-task
1个回答
0
投票

我可以在

azurePowerShellVersion
为2.6.0时重现该问题,该版本已不再支持。根据官方文档Azure PowerShell支持生命周期

Az PowerShell 模块支持生命周期属于 Azure SDK 生命周期策略。我们支持 Az PowerShell 模块当前主要版本的最后两个次要版本以及先前主要版本的最后一个次要版本。

目前,Windows 和 Ubuntu 映像上的 azure powershell 默认版本为 11.3.1 及更高版本。 (请参阅 MS 托管代理上的默认软件此处。)使用 11.3.1 进行测试,工作正常。

pool:
  vmImage: windows-latest

steps:
- task: AzurePowerShell@5
  inputs:
    azureSubscription: '${{ parameters.AzureSubscription }}'
    ScriptType: 'InlineScript'
    Inline: 'Save-AzContext -Path <pathname>'
    FailOnStandardError: true
    azurePowerShellVersion: 'LatestVersion'
    pwsh: true

enter image description here

到目前为止,azure powershell 的最新版本是11.6.0。您可以通过

preferredAzurePowerShellVersion: '11.6.0'
在管道中使用它。

© www.soinside.com 2019 - 2024. All rights reserved.