
A build agent that signs in to Azure with a client secret keeps that secret in a pipeline variable or a script. Every copy of it is a credential that can leak. Microsoft's workload identity federation documentation says such credentials "pose a security risk and have to be stored securely and rotated regularly". It adds that a service can go down when one expires. With Microsoft Entra ID, a build agent that deploys to Microsoft Foundry can sign in without storing a secret at all.
Securing Foundry build agents with Entra ID takes three steps. First, give each agent its own identity that holds no secret. Use a managed identity when the agent runs on Azure. Use workload identity federation when it runs in GitHub Actions, Azure Pipelines, on premises or in another cloud. Second, give that identity the narrowest Foundry role its job needs, on the project or resource it works in and nothing wider. Third, send its sign-ins to a Log Analytics workspace, so every token it requested can be reviewed later.
Entra ID treats build agents as workload identities. These are applications, service principals (the identities applications sign in with) and managed identities. They sit in the same directory as user accounts but sign in with no person present. With workload identity federation, the agent never holds an Entra ID credential. It asks the platform it runs on, such as GitHub, for a signed token, and the platform issues one. The agent sends that token to the Microsoft identity platform. The identity platform checks the trust relationship set up on the agent's identity and validates the token against the issuer's OpenID Connect URL. When the checks pass, Entra ID issues an access token, and the agent calls the Foundry project with it.
For build agents running on Azure compute, managed identities are the cleanest option. Microsoft lists the first benefit as "You don't need to manage credentials. Credentials aren't even accessible to you." The agent's code requests a token through the Azure.Identity library or MSAL, with no secret. A system-assigned identity exists only as long as its resource. When the resource is deleted, Azure deletes its service principal too.
Workload identity federation covers build agents that run outside Azure. That includes GitHub Actions workflows, Kubernetes clusters on premises or in other clouds, workloads in Google Cloud and AWS, and Azure Pipelines service connections. The agent carries no permanent key. It shows a token issued by the platform it runs on. Entra ID checks who issued the token and which workload it names, then issues an access token. No secret sits on the agent's disk.
The setup takes care. You register an application in Entra ID, or create a user-assigned managed identity. Then you add a federated credential whose issuer, subject and audience match the values in the external token exactly, including upper and lower case. If they do not match, Entra ID refuses the exchange. Once that trust is in place, Microsoft's documentation says, you "eliminate the maintenance burden of manually managing credentials" and the risk of leaking secrets or having certificates expire. There is no rotation schedule for the credential, because there is no secret to rotate.
Where a legacy integration still needs a client secret, keep it in Azure Key Vault. Automate its rotation instead of updating each copy by hand. In Microsoft's Key Vault rotation tutorial, Key Vault publishes a "near expiry" event 30 days before the secret expires. A function triggered by Event Grid then creates the new secret version and updates the service that uses it.
An identity's lifecycle needs the same care as its sign-in. Create a service principal for a temporary build environment together with that environment, and remove it at teardown. Do not leave it unused with its roles still attached. Creating both from the same infrastructure-as-code pipeline keeps the identities in step with the workloads that use them. Some will still slip through. To catch them, access reviews in Privileged Identity Management can include service principals with direct access to an Azure resource role. Reviewing service principals needs a Microsoft Entra Workload ID Premium plan on top of Entra ID P2 or ID Governance.
Least privilege means each identity gets only the access its job needs. Microsoft Foundry assigns roles at three scopes: the Foundry resource, a Foundry project inside it, and a single agent. Microsoft's role-based access control guide for Foundry names Foundry User as the least-privilege role for developers building and testing agents. It names Foundry Agent Consumer for an identity that only calls agents through their endpoints. Publishing agents needs Foundry Project Manager on the Foundry resource. Give a build agent's identity the narrowest of these roles that covers its job. Then even a compromised agent holding a valid token cannot act on projects its role does not cover. Sign in with Entra ID rather than the resource's API key, because roles apply only to Entra ID sign-ins. With a key, Microsoft warns, "the key grants full access without role restrictions."
Development teams sometimes warn that tight access limits will break automated pipelines and delay releases. Poorly scoped permissions break pipelines too, later and at higher cost. Build one template for each kind of pipeline. It holds a pre-approved identity, a standard federated credential and the role assignments for each environment. Teams then stop negotiating access project by project. A new pipeline starts from a secure baseline instead of a policy document someone has to interpret.
Authentication and access control set the limits, and the logs show whether they hold. Entra ID records each kind of identity in its own log. It keeps service principal sign-ins for apps and service principals, and managed identity sign-ins for managed identities. Audit logs record changes to applications, groups, users and licences in the tenant.
Diagnostic settings route those logs, as ServicePrincipalSignInLogs, ManagedIdentitySignInLogs and AuditLogs, to the destination you choose. One destination is a Log Analytics workspace that Azure Monitor queries. Another is an event hub that feeds a SIEM, the system your security team uses to watch for threats. A third is a storage account for long-term retention. With a separate identity for each pipeline, each sign-in names the pipeline that made it. The Conditional Access tab of a service principal sign-in shows how each policy was evaluated.
Federated identities remove the stored secret. Scoped roles limit what one compromised agent can reach. The sign-in logs give the security team a record of every token each identity requested. Ovidius builds custom agents on Microsoft Foundry that IT and security can sign off. They run on Azure with Entra ID, private networking and audit logs, and access runs through your own Entra ID roles.
It lets a user-assigned managed identity or an app registration in Entra ID trust tokens from an external identity provider, such as GitHub. A workload outside Azure sends its provider's token to the Microsoft identity platform. The platform checks the trust relationship and issues an access token in return. The workload never stores an Entra ID secret, so there is no secret to rotate or leak.
Use a managed identity when the build agent runs on Azure compute, such as a virtual machine or an App Service app. Azure manages its credentials, and they are not accessible to you. Use workload identity federation when the agent runs anywhere else: GitHub Actions, an Azure Pipelines service connection, a Kubernetes cluster on premises, Google Cloud or AWS.
It should get the narrowest built-in role that covers its job, at the narrowest scope. Foundry User is the least-privilege role for building and testing agents in a project. Foundry Agent Consumer suits an identity that only calls agent endpoints. Publishing agents needs Foundry Project Manager on the Foundry resource. Avoid key-based authentication, which grants full access without role restrictions.
Yes, for service principals. A Conditional Access policy for workload identities can block a single-tenant service principal's token requests from outside known public IP ranges. It can also block them when Entra ID Protection detects risk. Managed identities are not covered. Creating or changing these policies needs Workload Identities Premium licences. Microsoft notes that managed identities could be included in an access review instead.
They go wherever Entra ID diagnostic settings send them. The options are a Log Analytics workspace for Azure Monitor queries, an event hub that feeds a SIEM, or a storage account for long-term retention. A build agent's sign-ins arrive as ServicePrincipalSignInLogs for an app or service principal, and as ManagedIdentitySignInLogs for a managed identity. Both sit beside the AuditLogs that record changes to applications, groups and users.
Keep the secret in Azure Key Vault and automate its rotation rather than updating copies by hand. In Microsoft's Key Vault rotation tutorial, Key Vault publishes a "near expiry" event ahead of the secret's expiry date. A function triggered by Event Grid then creates the new secret version and updates the service that uses it.
Ready to remove stored secrets from your Foundry pipelines? Book a discovery call. A senior partner runs the call and tells you whether Foundry is the right platform for the job before anything is scoped.