Signing In to Oracle Database@Azure with Microsoft Entra ID Tokens Instead of Database Passwords
The databases moved to Azure, but the user management did not. Each database on Exadata still has its own list of named accounts, each with a password that must be rotated, and each leaver must be removed from every database by hand. Meanwhile the same people sign in to Azure every morning with Microsoft Entra ID, with multi-factor authentication and conditional access already in place.
Oracle Database can accept an Entra ID OAuth2 access token instead of a password. The user signs in to Entra ID, the client sends the token to the database, and the database checks the token and maps the user to a schema and roles according to the app roles assigned in Entra ID. Removing someone from a group in Entra ID removes their database access everywhere at once. This post sets it up for a PDB on Exadata Database Service in Oracle Database@Azure.
The Use Case
The DBA team and a group of analysts connect to SALESPDB with named database accounts. The security team wants the database to use the company's identity provider, so that multi-factor authentication applies, leavers lose access with their Entra ID account, and no personal database passwords remain. Application service accounts are out of scope for now.
Environment used in this runbook
Service: Exadata Database Service on Dedicated Infrastructure in Oracle Database@Azure
Database: Oracle Database 19c (19.24), PDB SALESPDB
Identity provider: Microsoft Entra ID tenant of the company
Groups: sg-sales-dba (DBA team) and sg-sales-analysts (read-only analysts)
Clients: Azure CLI and SQL*Plus from the Oracle Instant Client 19c on an admin VM in Azure
Licence: Entra ID token authentication is part of Oracle Database and needs no extra-cost option; the Entra ID features used here are available in standard Entra ID tenants
How Token Authentication Works
The database is an application in Entra ID. It gets an app registration with an Application ID URI, and app roles that describe database access.
Users get a token for that application. A client asks Entra ID for an access token whose audience is the database's Application ID URI.
The database validates the token. It checks the signature with Entra ID's public keys, the audience, the tenant and the expiry time.
App roles decide the schema and roles. A global user identified as AZURE_ROLE=... is a shared schema for everyone holding that app role, and a global role identified the same way grants database roles.
The token travels over TLS. Token authentication requires a TCPS connection, so the token is never sent in clear text.
Step 1: Check the Release and the TLS Listener
Token authentication with Entra ID is available in Oracle Database 19c from Release Update 19.16. Confirm the release, and confirm that the listener has a TCPS endpoint, because tokens are sent only over TLS.
Shell |
# On a database server, as the grid user lsnrctl status | grep -E "Version|PROTOCOL=tcps"
# As the oracle user sqlplus -s / as sysdba <<'EOF' SELECT version_full FROM v$instance; EOF |
Expected output |
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=10.20.4.15)(PORT=2484)))
VERSION_FULL
-----------------
19.24.0.0.0What to expect: A 19c release of 19.16 or later and a TCPS endpoint, here on port 2484. If there is no TCPS endpoint, configure TLS on the listener first; the connection in Step 7 cannot work without it.
Step 2: Register the Database in Entra ID
In the Microsoft Entra admin center, create an app registration for the database: Identity, Applications, App registrations, New registration, with the name salespdb-oracle and single-tenant access. Under Expose an API, set the Application ID URI and add a scope. Then read back the values the database needs.
Shell |
# On an admin host, signed in with az login as an Entra ID administrator az account show --query tenantId -o tsv
az ad app list --display-name salespdb-oracle \ --query "[].{name:displayName, appId:appId, uri:identifierUris[0]}" -o table |
Expected output |
3b9e7d10-5c2f-4a8b-b6e1-0f4d9a2c8e57
Name AppId Uri
--------------- ------------------------------------ ------------------------------------------
salespdb-oracle 6f1c2a9e-4b7d-4e1a-9c3f-2d8e5b0a7c41 api://6f1c2a9e-4b7d-4e1a-9c3f-2d8e5b0a7c41What to expect: The tenant ID, the application (client) ID and the Application ID URI. Keep all three; Step 4 puts them into the database configuration. Under Expose an API, also add the Azure CLI as an authorized client application (its well-known client ID is 04b07795-8ddb-461a-bbee-02f9e1bf7b46), so that users can request tokens for the database with az in Step 6.
Step 3: Create App Roles and Assign the Groups
In the app registration, open App roles and create two roles: SALES_DBA and SALES_READER, both for users and groups. Then, under Enterprise applications, salespdb-oracle, Users and groups, assign sg-sales-dba to SALES_DBA and sg-sales-analysts to SALES_READER. Check the roles from the command line.
Shell |
az ad app show --id 6f1c2a9e-4b7d-4e1a-9c3f-2d8e5b0a7c41 \ --query "appRoles[].{role:value, enabled:isEnabled, members:join(',', allowedMemberTypes)}" -o table |
Expected output |
Role Enabled Members
------------ ------- -------
SALES_DBA True User
SALES_READER True UserWhat to expect: Both roles enabled for users, which includes groups. The role values, SALES_DBA and SALES_READER, are what the database maps in Step 5, and they are case-sensitive. With Assignment required set to Yes on the enterprise application, only members of the two groups can get a token for the database at all.
Tip: Assigning groups rather than individual users to app roles keeps the Entra ID side to two assignments. Adding a new DBA is then only a group membership change, which most companies already handle in their joiner and leaver process.
Step 4: Point the Database at Entra ID
Set the identity provider parameters in the PDB. IDENTITY_PROVIDER_CONFIG takes a JSON document with the Application ID URI, the tenant ID and the application ID from Step 2.
SQL |
-- Connected to SALESPDB as a DBA ALTER SYSTEM SET identity_provider_type = 'AZURE_AD' SCOPE = BOTH;
ALTER SYSTEM SET identity_provider_config = '{ "application_id_uri" : "api://6f1c2a9e-4b7d-4e1a-9c3f-2d8e5b0a7c41", "tenant_id" : "3b9e7d10-5c2f-4a8b-b6e1-0f4d9a2c8e57", "app_id" : "6f1c2a9e-4b7d-4e1a-9c3f-2d8e5b0a7c41" }' SCOPE = BOTH;
COLUMN name FORMAT A24 COLUMN value FORMAT A20
SELECT name, SUBSTR(value, 1, 20) AS value FROM v$parameter WHERE name LIKE 'identity_provider%'; |
Expected output |
System altered.
System altered.
NAME VALUE
------------------------ --------------------
identity_provider_type AZURE_AD
identity_provider_config { "application_id_uWhat this does: It tells the PDB to accept Entra ID tokens issued for this application in this tenant. The value of IDENTITY_PROVIDER_CONFIG must be the same on all RAC instances. To validate tokens, the database servers need outbound HTTPS access to Entra ID's endpoints at login.microsoftonline.com to fetch the token signing keys, so check the network security group and any proxy on the Exadata VM cluster's client subnet.
Step 5: Map App Roles to a Shared Schema and Global Roles
Create one shared schema per app role, and a global role that carries the privileges. A user who holds the app role connects to the shared schema and receives the role automatically.
SQL |
-- Shared schemas: one database user per app role, no password CREATE USER sales_dba_users IDENTIFIED GLOBALLY AS 'AZURE_ROLE=SALES_DBA'; CREATE USER sales_readers IDENTIFIED GLOBALLY AS 'AZURE_ROLE=SALES_READER'; GRANT CREATE SESSION TO sales_dba_users, sales_readers;
-- Global roles: granted for the session when the token holds the app role CREATE ROLE sales_dba_role IDENTIFIED GLOBALLY AS 'AZURE_ROLE=SALES_DBA'; CREATE ROLE sales_read_role IDENTIFIED GLOBALLY AS 'AZURE_ROLE=SALES_READER'; GRANT DBA TO sales_dba_role; GRANT SELECT ON sales.orders TO sales_read_role; GRANT SELECT ON sales.customers TO sales_read_role;
COLUMN username FORMAT A16 COLUMN external_name FORMAT A24
SELECT username, authentication_type, external_name FROM dba_users WHERE authentication_type = 'GLOBAL'; |
Expected output |
User created.
User created.
Grant succeeded.
Role created.
Role created.
Grant succeeded.
Grant succeeded.
Grant succeeded.
USERNAME AUTHENTI EXTERNAL_NAME
---------------- -------- ------------------------
SALES_DBA_USERS GLOBAL AZURE_ROLE=SALES_DBA
SALES_READERS GLOBAL AZURE_ROLE=SALES_READERWhat this does: Members of sg-sales-dba connect as SALES_DBA_USERS with the DBA role, and analysts connect as SALES_READERS with read access to the ORDERS and CUSTOMERS tables. Add a SELECT grant to SALES_READ_ROLE for each further table the analysts need. Global roles cannot be mapped from a single Entra ID user, only from an app role.
Step 6: Get a Token on the Client
On the admin VM, the user signs in with their own Entra ID account and asks for an access token for the database's Application ID URI. The token is written to a file that only the user can read.
Shell |
# As the analyst, on the admin VM az login --tenant 3b9e7d10-5c2f-4a8b-b6e1-0f4d9a2c8e57
mkdir -p ~/.oracle/token && chmod 700 ~/.oracle/token az account get-access-token \ --resource api://6f1c2a9e-4b7d-4e1a-9c3f-2d8e5b0a7c41 \ --query accessToken -o tsv > ~/.oracle/token/token chmod 600 ~/.oracle/token/token
az account get-access-token --resource api://6f1c2a9e-4b7d-4e1a-9c3f-2d8e5b0a7c41 \ --query expiresOn -o tsv |
Expected output |
2026-11-09 16:12:45.000000What to expect: A token file and its expiry time, usually about an hour after it was issued. The sign-in goes through the tenant's normal policies, including multi-factor authentication and conditional access. When the token expires, run the same command again; existing sessions stay connected, but new connections need a valid token.
Step 7: Connect with the Token
Tell the Oracle client to send the token instead of a password, and connect over TCPS. The connect string has no user name and no password.
Shell |
# ~/.oracle/network/admin/sqlnet.ora on the admin VM cat >> ~/.oracle/network/admin/sqlnet.ora <<'EOF' SSL_SERVER_DN_MATCH = ON TOKEN_AUTH = OAUTH TOKEN_LOCATION = "/home/analyst1/.oracle/token" EOF
# tnsnames.ora entry salespdb_entra uses PROTOCOL=TCPS and PORT=2484 TNS_ADMIN=~/.oracle/network/admin sqlplus -s /@salespdb_entra <<'EOF' COLUMN who FORMAT A28 COLUMN schema FORMAT A14 SELECT SYS_CONTEXT('USERENV', 'AUTHENTICATED_IDENTITY') AS who, SYS_CONTEXT('USERENV', 'CURRENT_USER') AS schema FROM dual; EOF |
Expected output |
WHO SCHEMA
---------------------------- --------------
analyst1@example.com SALES_READERSWhat to expect: The session runs in the shared schema SALES_READERS, while AUTHENTICATED_IDENTITY shows the real person who signed in. This is what the audit trail records, so individual accountability is kept even though many analysts share one schema.
Step 8: Check the Roles in the Session
Confirm that the global role arrived with the token, and that the analyst cannot do more than intended.
SQL |
-- In the analyst's session from Step 7 COLUMN role FORMAT A20 SELECT role FROM session_roles;
SELECT COUNT(*) AS orders_today FROM sales.orders WHERE order_date >= TRUNC(SYSDATE);
DELETE FROM sales.orders WHERE ROWNUM = 1; |
Expected output |
ROLE
--------------------
SALES_READ_ROLE
ORDERS_TODAY
------------
18213
DELETE FROM sales.orders WHERE ROWNUM = 1
*
ERROR at line 1:
ORA-01031: insufficient privilegesWhat to expect: SALES_READ_ROLE is active, reading works and writing is refused. A member of sg-sales-dba would see SALES_DBA_ROLE instead. Removing a user from the Entra ID group stops them from getting a token with that app role, so their next connection fails, on every database configured the same way.
Step 9: Retire the Old Named Accounts
Once everyone has connected with a token at least once, lock the old named accounts, and drop them after an agreed period. Check the last logon first.
SQL |
COLUMN username FORMAT A12 COLUMN last_login FORMAT A16
SELECT username, account_status, TO_CHAR(last_login, 'YYYY-MM-DD HH24:MI') AS last_login FROM dba_users WHERE username IN ('JSMITH', 'AKOWALSKA', 'MBROWN') ORDER BY username;
ALTER USER jsmith ACCOUNT LOCK; ALTER USER akowalska ACCOUNT LOCK; ALTER USER mbrown ACCOUNT LOCK; |
Expected output |
USERNAME ACCOUNT_STATUS LAST_LOGIN
------------ -------------------------------- ----------------
AKOWALSKA OPEN 2026-10-28 09:41
JSMITH OPEN 2026-11-02 14:05
MBROWN OPEN 2026-10-19 11:30
User altered.
User altered.
User altered.What to expect: Three personal accounts that have not been used since the switch, now locked. Keep them locked for a few weeks in case someone's token setup fails, then drop them. From now on, a new DBA needs only a group membership in Entra ID, and nobody has a personal database password to rotate.
Summary
Entra ID token authentication lets people sign in to Oracle Database with the identity they already use for Azure. Check that the database is on 19.16 or later and has a TCPS listener, register the database as an application in Entra ID with an Application ID URI and app roles, and assign groups to the roles. Set IDENTITY_PROVIDER_TYPE and IDENTITY_PROVIDER_CONFIG in the PDB, map each app role to a shared schema and a global role, and let users fetch a token with the Azure CLI. Connect with TOKEN_AUTH = OAUTH over TLS, check the identity and roles in the session, and lock the old named accounts once everyone has switched.
Comments