Why Entra ID authentication for PyRIT Azure targets matters
Entra ID authentication lets PyRIT reach Azure resources using an identity that a team already manages, instead of a static API key or a database password stored in a file. Teams need it when several people or CI runners share PyRIT against Azure, when security reviewers ask where credentials live, or when a key would otherwise sit in a .env file on a shared workstation. The key point is that the credential becomes a sign-in to Entra ID, which you can grant, review and revoke centrally.
The PyRIT documentation confirms the scope for two Azure services. Azure SQL memory supports only Entra ID authentication, so user ID and password login is not available, which means the database connection must be planned around an Entra identity from the start. The Azure Content Safety scorer authenticates with Entra ID through az login, so the machine running the scorer needs an active Azure CLI session under an identity that has been granted access to the Content Safety resource. Azure OpenAI and other targets follow their own configuration, so this page treats each target type separately and asks you to confirm its authentication method in the PyRIT documentation before rollout.
Before you change any configuration, list every Azure resource PyRIT will touch and record how each one authenticates today. For each target, confirm with the PyRIT documentation and the Azure resource settings whether Entra ID is supported, which role the identity needs, and whether the sign-in happens interactively or through a managed identity. Those answers decide the sequence of the rest of this page: which identity to create, which roles to assign and which keys to remove from files once the new path works.
How Entra ID applies to each Azure target
Azure OpenAI targets are the model endpoints PyRIT sends attack prompts to, and they are the component most often configured with a key in the environment file. Keyless access means PyRIT requests a token from Entra ID for the signed-in identity and presents that token to the endpoint instead of a key. The PyRIT documentation for the Azure target you use describes which authentication option is supported and how it is selected, so read that page for your target class before changing configuration. Check that the identity running PyRIT has been granted the Azure role that allows inference calls on the deployment, and confirm the exact role name in the Azure documentation for your resource, not from memory.
- Token source: Confirm whether your target reads a token from the developer's Azure CLI session, a managed identity, or another credential chain.
- Deployment access: Grant the identity access to the specific Azure OpenAI resource and deployment, not the whole subscription.
- Key fallback: Remove the key from the environment file once keyless access works, so a stale key cannot quietly take over.
- Target naming: Keep the endpoint and deployment names identical across machines so the same registered target resolves everywhere.
- Version drift: Re-test after upgrading PyRIT, since the target classes and their options can change between releases.
Before you rely on this path, confirm the required role and the token scope in the linked PyRIT documentation for your version.
Azure AI Content Safety scorers judge whether a target response is harmful, and they call an Azure resource the same way a target does. The PyRIT documentation states that the Azure Content Safety scorer authenticates with Entra ID through az login, so the scorer does not need an API key when the developer or runner is signed in to Azure. This is the simplest keyless path in PyRIT, but it depends on the machine's Azure CLI session, which is a different trust boundary from the one used by a shared CI runner or a hosted CoPyRIT instance. Plan how scorer calls will authenticate in those environments before you move beyond a single workstation.
- Interactive sign-in: Developers sign in with
az loginunder the account that holds access to the Content Safety resource. - Automated runs: Confirm how the CI runner or service identity obtains an Azure CLI session, because a stored login may expire or be shared.
- Resource role: Grant the signing identity the role on the Content Safety resource that the documentation requires for analysis calls, and verify the role name there.
- Scorer configuration: Check which endpoint the scorer uses and that it points to the resource your organization approved.
- Audit trail: Record which identity made each scoring call so results can be traced in your evidence.
Before relying on this path, confirm the sign-in method and resource role in the linked Float-Scale Scorers documentation for your PyRIT version.
Azure SQL memory stores PyRIT conversations, scores and results, so its authentication path determines who can read and write red teaming records. The PyRIT documentation for Azure SQL memory states that AzureSQLMemory supports only Entra ID authentication, and user ID and password login is not available. A team moving from a SQL login therefore has to change the database access model as well as the PyRIT configuration. Because memory holds sensitive attack content, the database permissions should be reviewed as part of the same change.
- No SQL logins: Plan for Entra ID authentication only, and do not keep a SQL username and password in configuration as a fallback.
- Database principal: Create or map a database user for the Entra ID identity or group that runs PyRIT, following the documentation for your database.
- Least privilege: Grant only the database rights PyRIT needs for memory reads and writes, and review them against the documentation.
- Shared access: Decide whether individuals or a service identity connect, since this affects audit logs and offboarding.
- Network path: Confirm firewall and private networking rules for the runner that connects.
Before you migrate memory, confirm the supported Entra ID login options and required database rights in the linked Azure SQL Memory documentation for your version.
Authentication options compared for PyRIT Azure targets
This table compares four ways to give PyRIT access to Azure services, showing where each credential lives and where each option fits. Read each row against the Azure service you are connecting, because Azure SQL memory and the Content Safety scorer do not accept the same login methods. The main takeaway is that Entra ID removes stored keys for Azure SQL memory and Content Safety, but the team still has to decide how the Entra ID identity reaches each machine.
| Option | Where the credential lives | Best fit | Main trade-off |
|---|---|---|---|
| Key-based access in .env | Plaintext key in ~/.pyrit/.env or a local env file | Single-user trials against Azure OpenAI or other key-based targets | Keys sit on disk and must be rotated by hand. Confirm which targets in your setup accept keys at all. |
| Entra ID through az login for Content Safety | Your signed-in Azure CLI session on the machine running PyRIT | An individual analyst running the Azure AI Content Safety scorer from a workstation | Works only where someone is signed in. Confirm the Azure role the identity needs on the Content Safety resource. |
| Entra ID for Azure SQL memory | No password stored. PyRIT authenticates with an Entra ID identity to Azure SQL | Teams that want shared conversation and result memory without SQL passwords | PyRIT's Azure SQL memory supports only Entra ID, so every user needs a database role. Confirm the exact roles with your DBA. |
| Shared Key Vault pattern | Secrets in Azure Key Vault, retrieved at run time under a managed or Entra ID identity | Shared workstations, CI runners and CoPyRIT deployments | Adds a Key Vault to set up, access policies to maintain and a bootstrap document to protect. Confirm how your Key Vault integration is configured before rollout. |
Setting up Entra ID login for PyRIT step by step
This sequence takes a workstation or CI runner from a clean Python environment to PyRIT connecting to Azure targets and Azure SQL memory through Entra ID, with a check at each stage. It produces a setup where no endpoint keys or SQL passwords are stored in PyRIT configuration.
Confirm the Python version and identity
Before installing anything, the engineer doing the setup confirms that the machine runs Python 3.10 or later and below 3.15, with 3.13 recommended in the PyRIT documentation. They also decide which Entra ID identity will run PyRIT, either a named user for a workstation or a service identity for a runner, and confirm that identity has access to each Azure resource. Done when the Python version check passes and the identity and its role assignments are written down for the target resources.
Install PyRIT with pip
The engineer creates a virtual environment on the chosen Python version and installs PyRIT from PyPI with pip. PyRIT is published as the pyrit package on PyPI, and the install should be pinned to the release your team has approved. Done when importing the package in Python runs without error and the installed version matches the pinned release.
Sign in with az login
On the workstation or runner, the engineer signs in with the Azure CLI using az login, selecting the tenant and subscription that hold the target resources. PyRIT's Azure Content Safety scorer authenticates through this Entra ID login, so no key is written to a file. Done when az account show returns the expected tenant, subscription and signed-in identity.
Point target and scorer settings at Entra ID
The engineer edits the PyRIT configuration so Azure OpenAI targets and the Azure Content Safety scorer are set to use Entra ID rather than API keys, and removes any key values from ~/.pyrit/.env. Endpoint URLs and deployment names stay in configuration, while credentials are not stored. Confirm the exact configuration keys against the PyRIT documentation for your version. Done when the configuration file contains endpoints and no key values, and a grep for key-like strings in the config directory returns nothing.
Configure AzureSQLMemory with Entra ID
The engineer points PyRIT memory at Azure SQL and sets the connection to Entra ID authentication. PyRIT's AzureSQLMemory supports only Entra ID authentication, so a SQL username and password login is not an option. The database must grant the chosen identity permission to create or read its tables, which the database administrator confirms. Done when PyRIT opens the memory connection without a password prompt.
Test the target connection
The engineer runs a single, low-volume prompt against one Azure OpenAI deployment using the Entra ID login. The test should send a harmless objective and check that a response returns and that the request is recorded in memory. If the call fails with an authorization error, the identity is missing the data-plane role on the resource, which the subscription owner must grant. Done when the response returns and the conversation appears in the Azure SQL memory tables.
Test the Content Safety scorer and record the identity
The engineer runs one scoring call through the Azure Content Safety scorer on a benign sample, confirming that the scorer uses the Entra ID login and returns a score. The team then records which identity, tenant and roles were used, and confirms with the security team that a service identity or named user is the approved owner. Done when the scorer returns a result, and the setup record names the identity, roles and resources for review.
How PyRIT requests tokens for Azure targets
The diagram starts with the operator or runner identity, which signs in with az login or a managed identity and receives an Entra ID token. PyRIT then presents that token to Azure SQL memory, Azure Content Safety and Azure OpenAI, all of which accept Entra ID for authentication. The key-based path through .env sits outside the team boundary as the alternative. Check which identity the runner uses and whether the Azure resources have key-based access turned off.
Entra ID token path from operator sign-in to PyRIT calls, with the key-based alternative.
Security and operational risks of Entra ID login in PyRIT
Entra ID removes stored passwords from PyRIT, but it moves the risk to the identity PyRIT runs under, the token and login state on each machine, and the configuration files that still hold endpoints and leftover keys. The cards below set out what to check before a team relies on this login for Azure targets.
Identity PyRIT runs under
Azure calls made by PyRIT carry the identity of whoever ran az login or whichever managed identity the runner uses. A shared service account or a personal account with broad rights means every scan inherits those rights. Confirm which identity each team member, CI runner and CoPyRIT instance uses, and whether each one is a named, owned identity that can be reviewed and disabled.
Token lifetime on shared workstations
A signed-in session stays usable on the machine until it expires or is cleared, so anyone who later uses that workstation may be able to run PyRIT against Azure targets as the original user. Ask your identity team for the token and session lifetimes that apply to your tenant, and set a procedure to run az logout on shared machines once a session ends.
Least-privilege role assignment
PyRIT needs roles on each Azure resource it calls, such as Azure OpenAI, Content Safety and the Azure SQL memory database. The exact built-in roles and data-plane permissions required should be confirmed against the current PyRIT documentation and Azure role definitions before assignment. Grant each role at the narrowest resource scope the test program allows, and record who approved it.
Audit logging of Azure calls
Requests made by PyRIT appear in Azure logs under the signed-in identity, which lets security teams separate red team traffic from production use. Confirm that diagnostic logs are enabled on each target resource, that they reach the workspace your SOC reviews, and that test runs are tagged or time-stamped so they can be matched to a campaign.
Leftover keys in .env files
Moving to Entra ID does not remove old API keys from ~/.pyrit/.env or from .env.local files on machines where they were used before. An unused key that still works is an unnecessary credential. Search workstations and runners for AZURE_OPENAI key entries, rotate or revoke any key still in use, and delete the lines once the Entra ID path is verified.
Configuration kept out of source control
Files such as ~/.pyrit/.pyrit_conf can hold endpoint URLs, database server names and labels that describe internal systems. Keep these files out of Git repositories, add them to ignore rules where a project directory is used, and review any commit that adds a PyRIT configuration file. Confirm with the team which values are sensitive enough to move into a secret store.
Questions teams ask before enabling Entra ID for PyRIT
How much effort does switching PyRIT to Entra ID take, and what drives it?
The change is mostly configuration and access work, not code. The main drivers are how many Azure targets you use (Azure OpenAI, Content Safety, Azure SQL memory), whether each team member already has the right Azure role assignments, and how your identity and admin processes approve new access. Teams with one subscription and a small set of targets usually finish faster than teams spanning several tenants or resource groups. The effort you should expect is a written list of targets, roles and users, reviewed by your Azure administrators. Ask any partner for a fixed-scope quote built from that list, and confirm the exact role names and login steps against the PyRIT documentation for your version.
Can an internal team set up Entra ID for PyRIT without a partner?
Yes, if the team has someone comfortable with Azure role assignments and the Azure CLI. The PyRIT documentation describes the Azure Content Safety scorer authenticating with Entra ID through az login, and the Azure SQL memory only supports Entra ID sign-in. A small internal team can test this in a non-production subscription first. A partner becomes useful when you need the setup reviewed against your access policies, rolled out to several workstations or CI runners, or documented as evidence for a security review. Confirm the steps against the version you run before you rely on any written procedure.
Which Azure roles and login scopes does PyRIT need for Entra ID?
The exact roles and scopes depend on which targets you use and how your PyRIT version requests tokens, so confirm them in the PyRIT documentation and with your Azure administrators before assigning anything. In general, you will need to identify the principal each user or service signs in as, then grant that principal only the data-plane access each target requires. Check the Azure SQL memory page for the sign-in method it expects, and the Content Safety scorer page for how az login is used. Document each role assignment with its target so reviewers can trace it.
What happens to existing key-based PyRIT configurations?
Existing key-based settings keep working until you change them, so you can move one target at a time. Where a target supports Entra ID, you switch its configuration to token-based sign-in and remove the stored key once the change is tested. Keys left in ~/.pyrit/.env or in source control remain a risk after the switch, so plan to rotate and delete them. Confirm for each target whether it still accepts keys in your PyRIT version, because Azure SQL memory does not accept user ID and password sign-in at all.
How does Azure SQL memory differ from SQLite memory in PyRIT?
Azure SQL memory uses Entra ID only, while SQLite stores memory in a local file and needs no identity provider. With Azure SQL, each user or service account needs database access granted through Entra ID, and the database becomes a shared record that your access reviews must cover. With SQLite, memory sits on the machine that runs PyRIT, so backup, access control and sharing are your responsibility on that host. Choose Azure SQL when several people or runners must read the same results, and SQLite for single-user or fully local work.
What should a partner need from our team before starting?
A partner needs a clear picture of your Azure environment and how people will use PyRIT. Prepare a list of the targets to be authenticated, the subscriptions and tenants involved, the groups or users who will run scans, and any CI runners or shared workstations. Also provide your access policies, the approval path for Azure role assignments, and the PyRIT version you plan to run. Your security team should name who signs off on role assignments and evidence. With that information, a partner can write a fixed-scope proposal that states what is included and what you must provide.
Limits to confirm in your Azure environment
Entra ID removes stored keys from PyRIT, but it moves the risk into your Azure role assignments, tenant policies and network paths. The cards below list the points to confirm with your Azure administrators and security team before a production-like scan runs.
Login scopes and roles per target
Each Azure target needs its own sign-in and role grant. Azure SQL memory needs Entra ID login and a database role that allows PyRIT to write its tables, while the Content Safety scorer relies on the identity from az login. Ask your Azure administrator to list the exact scope and role for each target in your subscription, and test each one with a read or a single prompt before a full run.
Version differences from earlier releases
Authentication behavior can differ between PyRIT 1.1.0 and earlier releases, and the Azure/PyRIT repository was archived on 27 March 2026. Confirm which package version your team pins, check the release notes for changes to credential handling, and ask the engineering owner whether any target class in your pipeline changed its auth path. Keep the pinned version the same across every workstation and CI runner.
PyRIT releasesToken refresh during long scans
Scans that run for hours can outlast a token issued at sign-in. Ask your platform team how long access tokens last under your tenant policy, whether refresh happens automatically in your PyRIT version, and what error a target returns when a token expires. Run a long test in your non-production tenant and watch for failed attempts that the retry settings may hide.
Network access to Azure SQL
Azure SQL memory is reached over the network, so the machine running PyRIT must be allowed through the server firewall or a private endpoint. Confirm with your network team which subnets, VPN or private DNS entries apply to scan hosts and CoPyRIT instances. A blocked connection often looks like a login failure, so test connectivity separately from authentication.
Tenant conditional access policies
Conditional access can require a compliant device, a managed location or multifactor sign-in, and a non-interactive CI identity may fail those rules. Ask your identity team which policies apply to the accounts and managed identities PyRIT will use, and whether a workload identity exception is approved and documented. Unattended runners often need a separate identity with narrower roles.
Testing in a non-production tenant first
Role assignments, firewall rules and policies can behave differently between tenants, so validate the whole chain in a non-production tenant before you use production endpoints. Agree with your Azure owner which subscription, resource group and test database will hold PyRIT memory, and who approves moving the configuration to production. Record the tested role, scope and policy set so the approval can be repeated.
How DeployOpen scopes and delivers PyRIT Entra ID setup
DeployOpen handles Entra ID authentication for PyRIT as a written, fixed-scope piece of work. We confirm which Azure targets, memory store and scorers your team uses, then configure and test sign-in for each one and hand over a working, documented setup.
How we scope
- We list every Azure target, scorer and memory store PyRIT must reach, with the Entra ID method planned for each.
- The written scope names the tenant, subscriptions, identity type and login roles your team will use for each service.
- Engagements are fixed-scope, and the scope, deliverables and timeline are agreed in writing before any work starts.
How we build
- We configure PyRIT to sign in through az login or your chosen Entra ID method, without storing keys in plaintext files.
- We set up Azure SQL memory with Entra ID only, since user ID and password login is not available for that store.
- We test each target, the Azure Content Safety scorer and memory writes from the workstations and runners your team will use.
How we hand over
- You receive the configuration files, role assignments and a step-by-step record of how each service was connected.
- The handover includes a verification checklist your team can rerun after changes to tenants, roles or Azure resources.
- We document which login scopes and Azure roles each team member needs, so access reviews can follow the same record.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- A retainer can cover re-verifying Entra ID sign-in when PyRIT versions, Azure roles or tenant policies change.
- Confirm the support terms, response expectations and included upgrades in the written quote before you commit.

