简体   繁体   English

在没有用户凭据的情况下登录 Azure 自动化帐户到 Azure AD

[英]Login Azure Automation account, without user credential, to Azure AD

is possible to connect with an azure automation account to azuread with cmdlet:可以使用 cmdlet 将 azure 自动化帐户连接到 azuread:

  • MsOnline Module MsOnline 模块
  • AzureAD Module AzureAD 模块

without use credential stored in automation account?不使用存储在自动化帐户中的凭据?

在此处输入图像描述

I'm using following code with credential and works fine:我正在使用以下带有凭据的代码并且工作正常:

$azureadcred = Get-AutomationPSCredential -Name 'AzureAD'
Connect-AzureAD -credential $azureadcred

$o365cred = Get-AutomationPSCredential -Name 'O365'
Connect-Msolservice -credential $o365cred

Any help is appreciated任何帮助表示赞赏

Thanks谢谢

How to connect AzureAD module without user如何在没有用户的情况下连接 AzureAD 模块

We can use the service principal to connect module AzureAD.我们可以使用服务主体来连接模块 AzureAD。 Meanwhile, you use the Azure Automation Account, we can directly use Azure Automation Run As accounts to connect the module.同时,您使用 Azure 自动化账户,我们可以直接使用Azure 自动化运行方式账户连接模块。

The detailed steps are as below.详细步骤如下。

  1. Assign Azure AD role to the Run As accounts.Azure AD 角色分配给运行方式帐户。 a.一个。 Get the object id of the Run As accounts获取运行方式帐户的 object id 在此处输入图像描述

    b.湾。 assign role分配角色

 Connect-AzureAD 

 $role =Get-AzureADDirectoryRole -Filter "DisplayName eq 'Company Administrator'" 

    Add-AzureADDirectoryRoleMember -ObjectId $role.ObjectId -RefObjectId <the object id you copy>
  1. PowerShell Script PowerShell 脚本
 $servicePrincipalConnection=Get-AutomationConnection -Name 'AzureRunAsConnection'
 $connectState = Connect-AzAccount `
       -ServicePrincipal `
       -TenantId $servicePrincipalConnection.TenantId `
       -ApplicationId $servicePrincipalConnection.ApplicationId `
       -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
 if ($connectState) {
        "Connected."
    } else {
        "Doesn't seem to be connected."
    }
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext
$context.Account
$graphToken = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($context.Account, $context.Environment, $context.Tenant.Id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, "https://graph.microsoft.com").AccessToken

$aadToken = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($context.Account, $context.Environment, $context.Tenant.Id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, "https://graph.windows.net").AccessToken

Connect-AzureAD -TenantId $context.tenant.id -AccountId $context.Account.Id -AzureEnvironmentName $context.Environment.Name -AadAccessToken $aadToken -MsAccessToken $graphToken 

get-azureaduser -Top 5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 自动化 - 使用 AD 用户登录会引发错误 - Azure Automation - Login with AD User throws error 无法使用 Python 自动化创建具有服务原则登录的 Azure AD 用户帐户 - Not able to create Azure AD user account with Service Principle login using Python Automation Azure AD登录没有用户浏览器重定向? - Azure AD Login Without user browser redirect? Azure AD登录-如果我的应用程序的缓存帐户错误,如何允许用户更改Azure帐户 - Azure AD login - how to allow user to change Azure account if cached account is wrong for my application Azure AD 可验证凭据 - Azure AD Verifiable Credential Azure 如果没有分配给没有用户分配的应用程序,则 AD 限制用户登录 - Azure AD restrict users to login if not assigned to aplication without user assignement Azure AD SSO 登录问题与管理员帐户 - Azure AD SSO login problem with admin account 使用不带参数的Get-Credential的Azure自动化运行手册 - Azure Automation Runbooks using Get-Credential without parameters 在Windows Azure中使用AD进行用户帐户管理 - Using AD in windows Azure for user account management 使用Azure AD创建Azure SQL数据库登录名/用户 - Creating Azure SQL Database login/user using Azure AD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM