How to authenticate PowerShell cmdlets in Runbooks with managed identities?

Florian Hein 0 Reputation points
2023-06-09T10:06:05.6666667+00:00

Hi there.

This is regarding Azure Automation Runbooks.

I'm attempting to replace AzureRunAs connections with user/system managed identities.

One problem I ran into with this is that I have no idea how to get the PowerShell cmdlet's used

in those Runbooks to authenticate.

For example for a Runbook that relies on the ExchangeOnline cmdlet's I was able to use the

AzureRunAs connections credentials via Get-AutomationConnection –Name "AzureRunAsConnection".

Since this AzureRunAs connection is also an App Registration in Azure, I could assign API

permissions to them, like for ExchangeOnline. The AzureRunAs connection also comes with

a certificate that I could make use of for authentication purposes.

On way I thought I could achieve this is for example with:

Connect-ExchangeOnline -ManagedIdentity -Organization 
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
43,934 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.