Replies: 2 comments
-
To do this in the Graph SDK, you'll need to use the preview (2.x) version. More information can be found here, but basically, all you need to do once your managed identity is set up, and you've got the prerelease module is to:
I should probably note that at this stage, I wouldn't use this in production workloads, until the 2.x version leaves preview. @peombwa - Do you have any indications yet of when the 2.x version of the SDK is going GA? |
Beta Was this translation helpful? Give feedback.
-
@jpsebasti I just did this. @SeniorConsulting You don't need the preview SDK.
Once you have an access token you can then simply use it with -AccessToken option of Connect-MgGraph: Note: This assumes you already granted access to Microsoft Graph to your Identity account. At this moment you can only do this from PowerShell. See this link for a sample script that simplifies things a bit. In my case I added the roles |
Beta Was this translation helpful? Give feedback.
-
I'm really struggling here. I use Azure Automation. They are phasing out RunAs accounts and replacing them with Managed Identities. I have been able to convert numerous powershell run books to use the User Defined Managed Identity with no problem. But I have one run book that needs to deal with Azure AD users. This runbook uses the AzureAD module which is also being phased out and replaced with Microsoft Graph.
I don't see the ability to connect to Graph using Managed Identities. Does anyone know if this is planned? It seems like one team doesn't talk to the other at Microsoft on these different powershell teams at Microsoft. With the old RunAs method runbook the RunAs account had a certificate associated with it and I was easily able to connect both to Azure and then Azure AD so this connection method worked:
$runas="AzureRunAsConnection"
$rg = 'resourcegrouphere'
$aact='automationaccountnamehere'
$conn = Get-AutomationConnection -Name $runas
Connect-AzAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint | Out-Null
Connect-AzureAD -TenantID $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint | Out-Null
In my new runbook that uses Managed Identities, I can connect to Azure with the MI but I'm stumped as to how to connect to the Graph environment:
$subscriptionid="subscriptionidhere"
$tenantid="tenantidhere"
$managed_identity="managedidentityidhere"
connect-azaccount -Identity -AccountId $managed_identity -Subscription $subscriptionid -Tenant $tenantid
No idea here how to use the Managed Identity with the connect-mggraph which as I understand it is the replacement for connect-azuread.
Can anyone shed some light on this?
Beta Was this translation helpful? Give feedback.
All reactions