Managed identity for Azure automation
A job running in Azure can connect with no stored secret or certificate:
Connect-ExchangeOnline -ManagedIdentity -Organization contoso.onmicrosoft.com
-ManagedIdentity is supported in Azure Automation runbooks, Azure VMs, VM Scale Sets and Azure Functions, and it must be used with -Organization. A system-assigned identity needs nothing more.
A user-assigned identity also needs -ManagedIdentityAccountId with the identity's app ID GUID. Without it the module does not know which identity to use.
Interactive methods do not fit a runbook. -Device needs a person to type a code, -UserPrincipalName needs someone to finish the sign-in, and -InlineCredential still needs a password and fails with MFA.
Tokens you already hold
-AccessToken (module 3.1.0 and later) takes an OAuth JWT you obtained elsewhere. Use it with -Organization, -DelegatedOrganization or -UserPrincipalName, depending on the token type. It is a separate method, not the user-assigned identity switch.
Partners managing customers
A CSP partner connects to a customer tenant with -DelegatedOrganization, giving the customer's .onmicrosoft.com domain or tenant ID. It is for CSP partners only. -Organization with the partner's own domain would land in the partner tenant.
Government and sovereign clouds
-ExchangeEnvironmentName picks the cloud:
- O365Default (worldwide)
- O365USGovGCCHigh
- O365USGovDoD
- O365China
- O365GermanyCloud
It replaces -ConnectionUri and -AzureADAuthorizationEndpointUri, the endpoint parameters from RPS-era scripts. A GCC High admin who cannot connect with the defaults adds -ExchangeEnvironmentName O365USGovGCCHigh. -Organization never takes a cloud name; it takes the .onmicrosoft.com domain.
All of this is PowerShell-only: the EAC has no equivalent for how a script connects.