Get-AutomationConnection 无法按照 MS Docs 工作
Get-AutomationConnection not working as per MS Docs
当我使用 cmdlet 时
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID
-ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
验证我的 azure 资源。我找不到 -Tenant
和 $conn.TenantID
,智能也找不到 $Conn.ApplicationID
。
参考文档:https://docs.microsoft.com/en-us/azure/automation/automation-first-runbook-textual-powershell"
首先 Get-AutomationConnection
用于自动化 运行books 单独从 Azure Automation 内部检索数据,你不能 运行 在本地 PowerShell 中这样做。
如果您在您所指的 doc 中看到 注释,
Important
Add-AzureRmAccount and Login-AzureRmAccount are now aliases for
Connect-AzureRMAccount. If the Connect-AzureRMAccount cmdlet does not
exist, you can use Add-AzureRmAccount or Login-AzureRmAccount, or you
can update your modules in your Automation Account to the latest
versions.
所以您可以使用 Add-AzureRmAccount/Login-AzureRmAccount
而不是 Connect-AzureRMAccount
确保将 AzureRM.Profile
模块导入到您的自动化帐户。
回到你的问题
$conn.TenantID
、$Conn.ApplicationID
将由 Azure 根据您的自动化帐户凭据自动 检索。 (您不需要为此参数提供任何值)
如何找到租户ID?
您的代码看起来正确,但请确保:
- 您正在从自动化运行手册中调用此代码,而不是从独立的 PS 会话中;和
- 您的自动化帐户有一个名为 "AzureRunAsConnection" 的 connection 资产。创建此连接资产的最简单方法是在创建自动化帐户时指定 "Create Azure Run As account: YES"。
当我使用 cmdlet 时
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID
-ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
验证我的 azure 资源。我找不到 -Tenant
和 $conn.TenantID
,智能也找不到 $Conn.ApplicationID
。
参考文档:https://docs.microsoft.com/en-us/azure/automation/automation-first-runbook-textual-powershell"
首先 Get-AutomationConnection
用于自动化 运行books 单独从 Azure Automation 内部检索数据,你不能 运行 在本地 PowerShell 中这样做。
如果您在您所指的 doc 中看到 注释,
Important
Add-AzureRmAccount and Login-AzureRmAccount are now aliases for Connect-AzureRMAccount. If the Connect-AzureRMAccount cmdlet does not exist, you can use Add-AzureRmAccount or Login-AzureRmAccount, or you can update your modules in your Automation Account to the latest versions.
所以您可以使用 Add-AzureRmAccount/Login-AzureRmAccount
Connect-AzureRMAccount
确保将 AzureRM.Profile
模块导入到您的自动化帐户。
回到你的问题
$conn.TenantID
、$Conn.ApplicationID
将由 Azure 根据您的自动化帐户凭据自动 检索。 (您不需要为此参数提供任何值)
如何找到租户ID?
您的代码看起来正确,但请确保:
- 您正在从自动化运行手册中调用此代码,而不是从独立的 PS 会话中;和
- 您的自动化帐户有一个名为 "AzureRunAsConnection" 的 connection 资产。创建此连接资产的最简单方法是在创建自动化帐户时指定 "Create Azure Run As account: YES"。