BestPaid guides · Azure · Microsoft Entra ID

Azure mandatory MFA phase 2: move automation that signs in with a user's password to workload identities

Since October 1, 2025, Microsoft has been rolling out MFA enforcement, gradually across tenants, for create, update and delete requests that user accounts send to Azure Resource Manager through Azure CLI, Azure PowerShell, the Azure SDKs, REST or IaC tools. Scripts that sign in with a user's password can't complete MFA, so their changes fail. Here is how to find them and move them to workload identities.

Sources: Microsoft's mandatory MFA plan (dated April 3, 2026; revised October 6, 2026), MFA verification page and phase 2 blog post (September 5, 2025); ROPC; Azure CLI MFA impact, troubleshooting and sign-in pages (interactive, managed identity, service principal); Azure PowerShell MFA impact, troubleshooting, non-interactive sign-in and Connect-AzAccount; Azure.Identity changelog, README and WorkloadIdentityCredential reference; MSAL.NET changelog; sign-in log details and filters; SigninLogs and AADNonInteractiveUserSignInLogs tables; security operations for applications; Azure Policy MFA tutorial; workload identity federation; GitHub Actions with OpenID Connect; Azure Resource Manager service connections. Checked on November 21, 2026. This page is our own summary; follow the vendor's documentation for every detail.

What phase 2 enforces, and when

WhenWhat Microsoft says
October 1, 2025Phase 2 enforcement gradually begins for create, update and delete operations through Azure CLI, Azure PowerShell, the Azure mobile app, IaC tools, REST API (control plane) endpoints and the Azure SDKs. Read operations don't require MFA.
Up to July 1, 2026Tenants with complex environments or technical barriers could postpone phase 2 up to this date, which a Global Administrator set at aka.ms/postponePhase2MFA. Postponing phase 1 also postponed phase 2 to the same date; a later one could be chosen.
After enforcement beginsA Global Administrator can submit a request to Microsoft Help and Support to lift enforcement temporarily.

July 1, 2026 has passed, and Microsoft says there's no way to opt out. To check a tenant, a Global Administrator opens aka.ms/postponePhase2MFA in the Azure portal; its Multifactor authentication (Phase 2) page shows a banner once enforcement has begun.

Why automation that signs in with a password breaks

A job that signs in with a user's password uses the OAuth 2.0 Resource Owner Password Credentials (ROPC) grant, which sends the password straight to Microsoft Entra ID with no step where anyone can complete MFA. Microsoft says ROPC is incompatible with MFA and ROPC-based APIs throw exceptions once MFA applies. Expect one of two failures:

Look for az login --username … --password …, Connect-AzAccount -Credential with a user account, MSAL.NET AcquireTokenByUsernamePassword (public client API deprecated as of 4.74.0), Azure.Identity UsernamePasswordCredential (deprecated as of 1.14.0-beta.2), and DefaultAzureCredential or EnvironmentCredential with AZURE_USERNAME and AZURE_PASSWORD set. Service accounts synced from Active Directory are user identities too.

Azure CLI 2.76.0 or later and Azure PowerShell 14.3.0 (Az.Accounts 5.2.0) or later, which Microsoft recommends, add a sign-in command with the claims challenge to the RequestDisallowedByPolicy error (az login … --claims-challenge or Connect-AzAccount … -ClaimsChallenge), so a person can sign in again interactively with MFA. An unattended job can't.

1. Find the automation in the sign-in logs

  1. In the Microsoft Entra admin center (Reports Reader is enough), open Entra ID → Monitoring & health → Sign-in logs; check both interactive and non-interactive user sign-ins.
  2. With Add filters, filter Application on the tools below; in a second pass, filter Authentication Protocol on ROPC to catch your own apps, as Microsoft's security operations guide does (with Status = Success).
  3. In a sign-in's details, an Authentication requirement of singleFactorAuthentication usually means no MFA was required; Microsoft lists exceptions, such as attempts where MFA was required but primary authentication failed. Scheduled sign-ins from a server IP point to a job.
ClientApp ID
Azure CLI04b07795-8ddb-461a-bbee-02f9e1bf7b46
Azure PowerShell1950a258-227b-4e31-a9cf-717495945fc2
Azure mobile app0c1307d4-29d6-4389-a11c-5cbe7f65d7fa
IaC toolsMicrosoft points to the Azure CLI and Azure PowerShell IDs
REST API, Azure SDKsNone listed: look for your own app registrations with ROPC sign-ins

With sign-in logs in Log Analytics, this query lists the last 30 days' candidates:

union SigninLogs, AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(30d)
| where AppId in ("04b07795-8ddb-461a-bbee-02f9e1bf7b46", "1950a258-227b-4e31-a9cf-717495945fc2")
    or AuthenticationProtocol == "ropc"
| summarize SignIns = count(), LastSeen = max(TimeGenerated)
    by UserPrincipalName, AppDisplayName, AuthenticationProtocol, AuthenticationRequirement, IPAddress
| order by SignIns desc

Assigned in audit mode, the built-in Azure Policy definition Users must authenticate with multi-factor authentication to create or update resources and its counterpart for deletes log each change by a user without MFA as an Activity Log event. Also search code, scheduled tasks and pipeline variables for UsernamePasswordCredential, AcquireTokenByUsernamePassword, AZURE_PASSWORD, grant_type=password, and Connect-AzAccount -Credential or az login -u without the service principal switch.

2. Pick a workload identity for each job

Where the job runsUse
Azure VM, App Service, Azure FunctionsManaged identity, system- or user-assigned
GitHub ActionsA federated credential for the repository on an app registration or user-assigned managed identity
Azure PipelinesAn Azure Resource Manager service connection with workload identity federation
Kubernetes, Google Cloud, AWS, other OIDC platformsWorkload identity federation
On-premises servers, everything elseA service principal with a certificate

This follows Microsoft's ROPC guidance: a managed identity on Azure, federation when another OAuth 2.0-compliant identity provider such as GitHub issues the tokens, otherwise a certificate, which Microsoft prefers to client secrets. Give each identity an Azure role at the smallest scope the job needs, then remove the old account's roles and stored password.

3. Azure PowerShell and Azure CLI: before and after

# Before: a user account and its password (ROPC)
$cred = [pscredential]::new($userName, $securePassword)
Connect-AzAccount -Credential $cred -Tenant $tenantId

# After, option A: on an Azure VM, App Service or Azure Functions, the managed identity
Connect-AzAccount -Identity                              # system-assigned
# Connect-AzAccount -Identity -AccountId $uamiClientId   # user-assigned

# After, option B: anywhere else, a service principal with a certificate in the local store
Connect-AzAccount -ServicePrincipal -ApplicationId $appId -Tenant $tenantId `
    -CertificateThumbprint $thumbprint

# Unchanged
New-AzResourceGroup -Name 'rg-nightly' -Location 'westeurope'

For a .pfx file instead of the certificate store, use -CertificatePath. In Azure CLI, the PEM file must hold the private key with the certificate appended:

# Before
az login --username "$AZ_USER" --password "$AZ_PASS"

# After
az login --identity
az login --service-principal --username "$APP_ID" --certificate /path/to/cert.pem --tenant "$TENANT_ID"

4. .NET with Azure.Identity: before and after

// Before: ROPC. UsernamePasswordCredential is marked [Obsolete] and fails once MFA applies.
var credential = new UsernamePasswordCredential(userName, password, tenantId, clientId);
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;

// After: only the credential changes. Pick the one for where the code runs.
TokenCredential credential =
    new ManagedIdentityCredential(ManagedIdentityId.SystemAssigned);            // on Azure
//  new ManagedIdentityCredential(ManagedIdentityId.FromUserAssignedClientId(uamiClientId));
//  new ClientCertificateCredential(tenantId, clientId, "/etc/app/cert.pfx");   // outside Azure
//  new WorkloadIdentityCredential();                                           // Kubernetes

var arm = new ArmClient(credential);
SubscriptionResource subscription = await arm.GetDefaultSubscriptionAsync();
await subscription.GetResourceGroups().CreateOrUpdateAsync(
    WaitUntil.Completed, "rg-nightly", new ResourceGroupData(AzureLocation.WestEurope));

Without options, WorkloadIdentityCredential reads AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_FEDERATED_TOKEN_FILE. With DefaultAzureCredential or EnvironmentCredential, you may need no code change: replace AZURE_USERNAME and AZURE_PASSWORD with AZURE_TENANT_ID, AZURE_CLIENT_ID (the new app's ID) and AZURE_CLIENT_CERTIFICATE_PATH (a PFX or PEM file with the private key). Switching to a managed identity through DefaultAzureCredential? Remove the old AZURE_CLIENT_ID, or it is read as a user-assigned identity's client ID. MSAL.NET code moves to a confidential client with WithCertificate and AcquireTokenForClient.

5. Pipelines: GitHub Actions and Azure DevOps

In GitHub Actions, give an app registration or user-assigned managed identity a federated credential for the repository and store the client, tenant and subscription IDs as secrets:

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      id-token: write            # lets the job fetch an OIDC token
    steps:
      - uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
          enable-AzPSSession: true   # also signs in Azure PowerShell
      - run: az group create --name rg-nightly --location westeurope

In Azure DevOps, Microsoft recommends Azure Resource Manager service connections with workload identity federation. A secret-based connection that Azure DevOps created and only one project uses can be switched with Convert under Project settings → Service connections, and reverted within seven days. .NET code in a pipeline can use the connection through AzurePipelinesCredential.

Scripts and apps still signing in to Azure with someone's password? We move scripts and apps that sign in as a user to workload identities and modern authentication at a fixed price: a script or scheduled job from $690, an app or service from $1,490. One app gets a free estimate within 2 business days. We never ask for passwords, secrets or admin access: your admin creates the identity and grants access.
See the Microsoft 365 migration offer