简体   繁体   中英

Azure Automation / Runbooks / Authentication

I would like to run a Azure Automation Runbook (PowerShell) and run connect-PnPOnline or connect-MicrosoftExchange

clientid & clientsecret will be deprecating User is MFA enabled

Can't I connect trough managed identity or keyvault or something else? Who can point me in the right direction?

Run connect-PnPOnline or connect-MicrosoftExchange trough managed identity:

I tried authenticating to the required conections using Azure PowerShell as well as Azure Automation runbook as follow:

SystemAssigned Managed Identity:

Connect-PnPOnline -Url "https://microsoftapc.sharepoint.com/teams/<Site_Name>"-ManagedIdentity

UserAssigned Managed Identity:

Connect-PnPOnline -Url ""-ManagedIdentity -UserAssignedManagedIdentityObjectId <ObjectId of UserAssigned Managed Identity>

Client_ID & Client_secret:

Install-Module -Name PnP.PowerShell
connect-pnponline -url "https://microsoftapc.sharepoint.com/teams/<Site_Name>"-ClientId "48b4f657-904f-496d-b02a-49cc492b3ee3" -ClientSecret "Tis8Q~Pxn3F2t8kllVCV5pCC2u2SMkxcSEeOrds2" -WarningAction Ignore

Output(AZ Powershell):

在此处输入图像描述

Azure runbook:

First of all, Add the required modules by going to Automation Account -> Shared Resources -> Modules -> Add a Module

在此处输入图像描述

To check whether modules are successfully imported, Give

Install-Module -Name ExchangeOnlineManagement -Scope AllUsers
Get-command -Module ExchangeOnlineManagement

在此处输入图像描述

Azure PowerShell:

在此处输入图像描述

Connect-ExchangeOnline -ManagedIdentity -Organization "xxxxx" -ManagedIdentityAccountId  "<UserManagedIdentityID>"

References:

Check here for other possible ways to Connect-PnPOnline & connect-ExchangeOnline .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM