Microsoft Entra IDの設定
Azure AD (Entra ID) Tokens: 1. Entra ID App Registrations
Register Client in Entra ID
SQLclの構成
azure % sql -version
SQLcl: リリース25.2.2.0 Production ビルド: 25.2.2.199.0918
azure %
azure % sql /nolog
SQLcl: 月 8月 25 13:48:00 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
SQL>
SQL> sdk list
+------------+-----------+---------+----------------------------------------------------------------------+
| SDK | INSTALLED | VERSION | ドキュメント |
+------------+-----------+---------+----------------------------------------------------------------------+
| jdbc-oci | いいえ | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
| jdbc-azure | いいえ | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
+------------+-----------+---------+----------------------------------------------------------------------+
SQL>
sdk install jdbc-azure
SQL> sdk install jdbc-azure
ojdbc-provider-azure SDKおよびその依存性をダウンロードしています。
jdbc-azure SDKは正常にインストールされました。SQLclを再起動して変更を反映してください
SQL>
SQL> sdk list
+------------+-----------+---------+----------------------------------------------------------------------+
| SDK | INSTALLED | VERSION | ドキュメント |
+------------+-----------+---------+----------------------------------------------------------------------+
| jdbc-oci | いいえ | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
| jdbc-azure | はい | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
+------------+-----------+---------+----------------------------------------------------------------------+
SQL> exit
azure %
TOKEN_AUTH=AZURE_DEVICE_CODEでの接続
unzip -d tns_admin Wallet_SALESADB.zip
azure % unzip -d tns_admin Wallet_SALESADB.zip
Archive: Wallet_SALESADB.zip
inflating: tns_admin/ewallet.pem
inflating: tns_admin/README
inflating: tns_admin/cwallet.sso
inflating: tns_admin/tnsnames.ora
inflating: tns_admin/truststore.jks
inflating: tns_admin/ojdbc.properties
inflating: tns_admin/sqlnet.ora
inflating: tns_admin/ewallet.p12
inflating: tns_admin/keystore.jks
azure %
export TNS_ADMIN=$PWD/tns_admin
azure % export TNS_ADMIN=$PWD/tns_admin
%
今までの設定でデータベースに接続できるか確認するため、管理者ユーザーADMINでSALESADBに接続します。
azure % sql admin@salesadb_low
SQLcl: 金 8月 15 15:13:56 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
パスワード (**********?) **************
Last Successful login time: 金 8月 15 2025 15:14:02 +09:00
接続先:
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.9.0.25.08
SQL> exit
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.9.0.25.08から切断されました
azure %
データベースSALESADBに接続できました。
アプリケーションSALESADB-CLIの概要を開き、アプリケーション(クライアント)IDの値をコピーします。この値をCLIENT_IDとして設定します。次にディレクトリ(テナント)IDの値をコピーします。この値をTENANT_IDとして設定します。
tns_admin/tnsnames.oraにTOKEN_AUTH、TENANT_ID、CLIENT_ID、AZURE_DB_APP_ID_URIの指定を加えた、以下のようなエントリSALESADB_AZCODEを追加します。
salesadb_azcode = (
description = (retry_count=20)(retry_delay=3)
(address = (protocol=tcps)(port=1522)(host=adb.ca-toronto-1.oraclecloud.com))
(connect_data = (service_name=g____________f_salesadb_low.adb.oraclecloud.com))
(security = (ssl_server_dn_match=yes)(TOKEN_AUTH=AZURE_DEVICE_CODE)
(TENANT_ID=3940511e-****-****-****-01b080952758)
(CLIENT_ID=0133b47d-****-****-****-2a5dcacd41a0)
(AZURE_DB_APP_ID_URI=api://c276626e-****-****-****-a87ff322acb6))
)
azure % sql /@salesadb_azcode
SQLcl: 金 8月 15 15:35:50 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code NW2ALBJQ8 to authenticate.
azure % sql /@salesadb_azcode
SQLcl: 金 8月 15 15:35:50 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code NW2ALBJQ8 to authenticate.
接続先:
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.9.0.25.08
SQL>
select
sys_context('userenv','session_user') as session_user,
sys_context('userenv','current_user') as current_user,
sys_context('userenv','authenticated_identity') as azure_user
from dual;
SQL> select
2 sys_context('userenv','session_user') as session_user,
3 sys_context('userenv','current_user') as current_user,
4 sys_context('userenv','authenticated_identity') as azure_user
5* from dual;
SESSION_USER CURRENT_USER AZURE_USER
_______________ _______________ _____________________________________________________________
MCPUSER MCPUSER yu__._______outlook.com_EXT_@_______soutlook.onmicrosoft.com
SQL> exit
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.9.0.25.08から切断されました
azure %
TOKEN_AUTH=AZURE_INTERACTIVEでの接続
tns_admin/tnsnames.oraにエントリSALESADB_AZCODEのTOKEN_AUTHをAZURE_INTERACTIVEに変更したエントリSALESADB_AZINTを作成します。
salesadb_azint = (
description = (retry_count=20)(retry_delay=3)
(address = (protocol=tcps)(port=1522)(host=adb.ca-toronto-1.oraclecloud.com))
(connect_data = (service_name=g____________f_salesadb_low.adb.oraclecloud.com))
(security = (ssl_server_dn_match=yes)(TOKEN_AUTH=AZURE_INTERACTIVE)
(TENANT_ID=3940511e-****-****-****-01b080952758)
(CLIENT_ID=0133b47d-****-****-****-2a5dcacd41a0)
(AZURE_DB_APP_ID_URI=api://c276626e-****-****-****-a87ff322acb6))
)
azure % sql /@salesadb_azint
SQLcl: 金 8月 15 15:58:45 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
ブラウザが起動してユーザーのサインインを求められるところまでは進むのですが、そこから先に進めません。
このorganizationsの指定が曖昧なため、サインインに失敗する模様です。organizationsの部分を、URLを直接編集してテナントIDに置き換えます。
SQL> select
2 sys_context('userenv','session_user') as session_user,
3 sys_context('userenv','current_user') as current_user,
4 sys_context('userenv','authenticated_identity') as azure_user
5* from dual;
SESSION_USER CURRENT_USER AZURE_USER
_______________ _______________ _____________________________________________________________
MCPUSER MCPUSER yuji.________outlook.com_EXT_@_________kksoutlook.onmicrosoft.com
SQL>
MCPサーバーの確認
conn -save salesadb-az -savepwd /@salesadb_azint
azure % sql /nolog
SQLcl: 金 8月 15 17:38:11 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
SQL> conn -save salesadb-az -savepwd /@salesadb_azint
名前: salesadb-az
接続文字列: salesadb_azint
ユーザー:
パスワード: 未保存
接続しました.
SQL> exit
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.9.0.25.08から切断されました
azure %
azure % sql /nolog
SQLcl: 金 8月 15 17:42:44 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
SQL> connmgr list
.
├── adb-free-23ai-freepdb1-wksp_apexdev
├── local-23ai-freepdb1-sys
├── local-23ai-freepdb1-wskp_apexdev
├── mydb
└── salesadb-az
SQL> exit
azure %
環境変数TNS_ADMINが必ず設定されるように、以下のスクリプトを作成します。TNS_ADMINおよびSQLclのバイナリの指定はフルパスで指定します。
#!/bin/sh
WD=/Users/xxxxxxxxxx/Documents/azure
export TNS_ADMIN=$WD/tns_admin
~/sqlcl/bin/sql -mcp
azure % chmod 755 sql-mcp.sh
azure %
{
"mcpServers": {
"sqlcl": {
"command": "/Users/xxxxxxxxx/Documents/azure/sql-mcp.sh"
}
}
}