Does Conditional Access for Workload Identities apply to Service Principal authentication used by Azure SDK or Terraform via environment variables?

U R 20 Reputation points
2026-03-16T05:47:31.7+00:00

In Microsoft Entra, Conditional Access policies allow you to restrict user account logins to the Portal and logins via Azure CLI/Azure PowerShell based on location or IP address.

Additionally, Conditional Access for Workload Identities allows you to restrict logins using service principals via Azure CLI/Azure PowerShell based on location or IP address.

Based on this, I have a question.

When authenticating with Azure SDKs or Infrastructure-as-Code (IaC) tools in Azure using a service principal configured through environment variables, will Conditional Access for Workload Identities also be applied?

Azure SDK: https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication/on-premises-apps?tabs=azure-portal%2Cwindows%2Ccommand-line#3---configure-environment-variables-for-application

Authentication for Azure IaC tools: https://learn.microsoft.com/en-us/azure/developer/terraform/authenticate-to-azure-with-service-principle?tabs=azure-powershell#specify-service-principal-credentials

Microsoft Security | Microsoft Entra | Microsoft Entra ID

1 answer

Sort by: Most helpful
  1. VEMULA SRISAI 13,890 Reputation points Microsoft External Staff Moderator
    2026-03-16T06:26:17.2166667+00:00

    Hello U R,

    Yes. Conditional Access for Workload Identities is evaluated at token issuance time in Microsoft Entra ID, not based on the client used.

    So if Azure SDKs or IaC tools like Terraform authenticate using a service principal via environment variables, the sign‑in is treated as a service principal (workload identity) sign‑in, and any Conditional Access policies scoped to Workload identities (for example, IP/location‑based blocking or service principal risk) will be applied.

    The authentication method (CLI, SDK, Terraform, env vars, etc.) does not bypass Conditional Access—as long as the policy is directly assigned to the service principal and you have Entra Workload ID Premium, enforcement occurs.

    Note: Managed identities are excluded from Conditional Access for workload identities; this applies only to service principals.

    For your reference: https://learn.microsoft.com/en-us/entra/identity/conditional-access/workload-identity

    Was this answer helpful?


Your answer

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