【问题标题】:Get-AzTrafficManagerProfile command is not running from inside the pipelineGet-AzTrafficManagerProfile 命令未从管道内部运行
【发布时间】:2021-04-26 15:12:45
【问题描述】:

我需要更新管道中的流量管理器配置文件以切换资源,当我在我登录的本地 az cli 中运行命令 Get-AzTrafficManagerProfile 时,它​​运行没有问题, 但是当我将它作为 Azure 管道的任务部分运行时,它抛出了以下错误:

Get-AzTrafficManagerProfile :在上下文中找不到帐户。请使用 Connect-AzAccount 登录。

还尝试从管道内部调用 Connect-AzAccount,但没有成功。

【问题讨论】:

    标签: azure azure-traffic-manager


    【解决方案1】:

    要在 devops 中成功运行命令 Get-AzTrafficManagerProfile,您需要使用 Azure PowerShell task 并使用 Azure Resource Manager service connection 进行身份验证。

    请参考以下步骤。

    1.创建一个Azure PowerShell task,在Azure subscription -> Available Azure subscriptions -> 选择您要运行Get-AzTrafficManagerProfile 的订阅。

    2.然后点击Authorize按钮,它会自动为你创建一个Azure Resource Manager service connection,并在订阅范围内分配一个Contributor RBAC role

    注意:请确保您登录devops的用户账号是订阅中的Owner/User Access administrator,否则您无权成功。

    3.然后在Inline Script中,直接使用Get-AzTrafficManagerProfile即可,无需手动登录,因为它会自动使用服务连接登录。

    4.测试任务,效果很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多