首页 > 解决方案 > 如何在 AzureAutomation 中使用 ConnectionType 作为 Azure 登录 AzureRm

问题描述

我的 Azure 自动化是使用Create Azure Run As Account

我可以使用以下命令登录 Azure

$connectionName = "AzureRunAsConnection"
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName
    "Logging in to Azure..."
    Connect-AzureRmAccount -ServicePrincipal -TenantId $servicePrincipalConnection.TenantId -ApplicationId $servicePrincipalConnection.ApplicationId -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint

我现在正在调查连接类型为Azure

通过在证书中上传我自己的证书,我创建了一个作为Azure 类型的新连接

我自己的自动化证书

在此处输入图像描述

我的 Azure 连接

在此处输入图像描述

现在我正在考虑如何使用此abc连接登录到我的 Azure Rm 帐户

$connectionName = "abc"
$conn = Get-AutomationConnection -Name $connectionName
echo $conn
    "Logging in to Azure..."
    Connect-AzureRmAccount -SubscriptionId $conn.SubscriptionID 

我知道上面这不是正确的方法,但希望有人能帮助我得到正确的方法。

上面的查询给出了如下错误

Name                           Value                                                                                    
----                           -----                                                                                    
AutomationCertificateName      MyCertificate                                                                            
SubscriptionID                 xxxx-xxx-xxx-xxx-xxxxxxx


Logging in to Azure...
Connect-AzureRmAccount : Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'.
At line:5 char:5
+     Connect-AzureRmAccount -SubscriptionId $conn.SubscriptionID
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzureRmAccount], AadAuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

此外,我无法获得任何关于connectionTypeas Azure确切用法的参考文档。除了与Azure的连接类型相关的示例之外,我找不到任何示例

如果有人指导以Azure的形式获取有关 connectionType 的一些参考文档,那将是一个很大的帮助

标签: azurepowershellazure-automation

解决方案


Azure 运行方式帐户不仅仅是连接和证书资产。

在创建 Azure 运行方式帐户期间,还会为该服务主体分配一个 Azure AD 应用程序、Azure AD 服务主体和参与者权限。

查看https://docs.microsoft.com/en-us/azure/automation/manage-runas-account了解更多信息。文档还包含一个用于创建您自己的 Azure 运行方式帐户的 PowerShell 脚本,其中包括对以下配置的支持:

  • 使用自签名证书创建运行方式帐户。
  • 使用自签名证书创建运行方式帐户和经典运行方式帐户。
  • 使用企业证书颁发机构 (CA) 颁发的证书创建运行方式帐户和经典运行方式帐户。
  • 使用 Azure 政府云中的自签名证书创建运行方式帐户和经典运行方式帐户。

推荐阅读