【问题标题】:Get-AutomationConnection not working as per MS DocsGet-AutomationConnection 无法按照 MS Docs 工作
【发布时间】:2018-08-21 12:40:35
【问题描述】:

当我使用 cmdlet 时

$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID 
-ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint

验证我的天蓝色资源。我找不到-Tenant$conn.TenantID,智能也找不到$Conn.ApplicationID

引用的文档:https://docs.microsoft.com/en-us/azure/automation/automation-first-runbook-textual-powershell"

【问题讨论】:

    标签: azure powershell azure-automation


    【解决方案1】:

    第一个 Get-AutomationConnection 仅用于自动化 Runbook 以在内部从 Azure 自动化检索数据,您不能在本地 PowerShell 中运行它。

    如果您在您所指的同一doc 中看到备注

    重要

    Add-AzureRmAccountLogin-AzureRmAccount 现在是 连接-AzureRMAccount。如果 Connect-AzureRMAccount cmdlet 没有 存在,您可以使用 Add-AzureRmAccountLogin-AzureRmAccount,或者您 可以将您的自动化帐户中的模块更新到最新版本 版本。

    因此,您可以使用Add-AzureRmAccount/Login-AzureRmAccount 而不是Connect-AzureRMAccount

    确保将 AzureRM.Profile 模块导入您的自动化帐户。

    回到你的问题

    $conn.TenantID,$Conn.ApplicationID 将由 Azure自动根据你的自动化帐户凭据检索。 (您不需要为此参数提供任何值)

    如何找到租户 ID?

    【讨论】:

    • 谢谢杰,这真的很有帮助!!
    【解决方案2】:

    您的代码看起来正确,但请确保:

    • 您是从自动化运行手册调用此代码,而不是从独立的 PS 会话;和
    • 您的自动化帐户有一个名为“AzureRunAsConnection”的connection 资产。创建此连接资产的最简单方法是在创建自动化帐户时指定“创建 Azure 运行方式帐户:是”。

    【讨论】:

      猜你喜欢
      • 2019-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-24
      • 2011-04-11
      • 2016-09-01
      • 1970-01-01
      相关资源
      最近更新 更多