這很重要
Azure Data Studio 於 2026 年 2 月 28 日正式退休。 您應該移轉至 Visual Studio Code。 欲了解更多資訊,請參閱 「Azure Data Studio 發生了什麼事」。
Azure Data Studio 包含內建的命令列介面,可讓您控制啟動應用程式的方式。 您可以開啟檔案、安裝延伸模組、變更顯示語言,以及透過命令列選項 (切換) 輸出診斷。
如需如何在 Azure Data Studio 內執行命令列工具的範例,請參閱 整合式終端機。
備註
雖然 Microsoft Entra ID 是 Azure Active Directory(Azure AD)的新名稱,但為了防止破壞現有的環境,Azure AD 仍會保留在某些硬式編碼元素中,例如 UI 字段、連線提供者、錯誤碼和 Cmdlet。 在本文中,這兩個名稱是可互換的。
命令列說明
若要檢視 Azure Data Studio 命令列介面的概觀,請在 Azure Data Studio 中開啟終端機 (檢視 > 終端機) 或開啟命令提示字元並輸入 azuredatastudio --help。 輸出包含命令列選項的版本、使用範例和清單,如節錄範例中所示:
Azure Data Studio 1.48.1
Usage: azuredatastudio.exe [options][paths...]
To read output from another program, append '-' (e.g. 'echo Hello World | azuredatastudio.exe -')
Options
<vscode options>
-h --help Print usage.
--aad Use Azure Active Directory authentication, this option is
deprecated - use 'authenticationType' instead.
-A --applicationName Supports providing applicationName
that will be used for connection profile app name.
-T --authenticationType Provide authentication mode to be
used. Accepted values: AzureMFA, SqlLogin, Integrated, etc.
-c --command <command-name> Name of command to run, accepted
values: connect, openConnectionDialog
-Z --connectionProperties Supports providing advanced connection properties that
providers support. Value must be a json object containing
key-value pairs in format: '{"key1":"value1"}'
-D --database <database> Name of database
-E --integrated Use Integrated authentication,
this option is deprecated - use 'authenticationType' instead.
-P --provider Connection provider to use, e.g. MSSQL, PGSQL, etc.
-S --server <server> Name of target server or host name.
--showDashboard Whether or not to show dashboard on connection, false by default.
-U --user <user-name> User name/email address
從命令列啟動
可以從命令列啟動 Azure Data Studio,以快速開啟檔案、資料夾或專案。 通常,可在資料夾的內容中開啟 Azure Data Studio。 從開啟的終端機或命令提示字元,瀏覽至您的專案資料夾並輸入 azuredatastudio。
使用查詢編輯器啟動
有時,當您開啟 Azure Data Studio 時,可能會想要在查詢編輯器中開啟指令碼。 可以提供檔案路徑,使用現有指令碼來啟動 Azure Data Studio:
azuredatastudio .\samplescript.sql
使用 URI 啟動
可以使用 URL 格式從瀏覽器啟動 Azure Data Studio,在啟動時快速建立連接,或開啟連接對話框,選擇性地在查詢編輯器中開啟指令碼。 使用 URI 進行啟動的支援格式為:
azuredatastudio://{command}?{option1}={value1}&{option2}={value2}...
支援的命令
從命令列啟動 Azure Data Studio 時,支援下列命令:
-
connect:使用提供的選項,連接目標伺服器 -
openConnectionDialog:使用提供的選項開啟連線對話方塊
支援的選項
下列選項可以在 URL 中提供。
| 選項 | Description |
|---|---|
provider |
要使用的連線提供者,例如 MSSQL、PGSQL 等等。 |
server |
目標伺服器的名稱或主機名稱。 |
database |
資料庫名稱。 |
user |
使用者名稱。 |
authenticationType |
要使用的驗證模式,接受的值:AzureMFA、SqlLogin、Integrated 等等。 |
applicationName |
提供連接設定檔中使用的應用程式名稱。 |
connectionProperties |
提供程式支援的進階連接屬性。 值必須是 json 物件,格式包含索引鍵/值組:{"key1":"value1"}。 |
範例
命令提示字元:整合式驗證
azuredatastudio --server localhost --authenticationType Integrated
您可能會收到「信任伺服器憑證」的警告訊息。
備註
對於連接到內部部署 SQL Server 或虛擬機中的 SQL Server 的使用者,資料庫引擎必須被設定為支持加密連線。 如需完整說明,請參閱針對加密連線設定 SQL Server 資料庫引擎。
命令提示字元:使用已儲存的指令碼啟動 Azure Data Studio
azuredatastudio --server localhost --provider mssql --user sa .\samplescript.sql
瀏覽器
azuredatastudio://connect?server=*****&user=*****&authenticationType=*****&connectionProperties={"key1":"value1"}