因為需要在一個 Browser-Only 的環境教大家 Azure Synapse Analytics,過程中需要一個可以管理 SQL Server 的工具,雖然 Azure Data Studio 或是 Visual Studio Code + SQL Server (mssql) Extension 很棒,可是畢竟都需要安裝。找了一下,沒找到適合的線上工具,結果今天突然想到,Azure Portal 的 Cloud Shell 有支援 Python,所以我就想到,可以安裝 dbcli/mssql-cli 這個用 Python 寫的 CLI 工具啊!
打開 Cloud Shell:
Requesting a Cloud Shell.Succeeded.
Connecting terminal...
Welcome to Azure Cloud Shell
Type "az" to use Azure CLI
Type "help" to learn about Cloud Shell
MOTD: Switch to PowerShell from Bash: pwsh
VERBOSE: Authenticating to Azure ...
VERBOSE: Building your Azure drive ...
PS /home/kc>
確認 Python 版本 (2.7/3.6 或以上就可以):
PS /home/kc> python -V
Python 3.7.3
安裝 mssql-cli 工具:
PS /home/kc> pip install mssql-cli
Defaulting to user installation because normal site-packages is not writeable
...
WARNING: You are using pip version 20.2.4; however, version 21.1.2 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
再來記得把 Cloud Shell 的 IP 加入 Firewall 的 IP White List:
因為需要在一個 Browser-Only 的環境教大家 Azure Synapse Analytics,過程中需要一個可以管理 SQL Server 的工具,雖然 Azure Data Studio 或是 Visual Studio Code + SQL Server (mssql) Extension 很棒,可是畢竟都需要安裝。找了一下,沒找到適合的線上工具,結果今天突然想到,Azure Portal 的 Cloud Shell 有支援 Python,所以我就想到,可以安裝 dbcli/mssql-cli 這個用 Python 寫的 CLI 工具啊!
打開 Cloud Shell:
確認 Python 版本 (2.7/3.6 或以上就可以):
安裝
mssql-cli
工具:再來記得把 Cloud Shell 的 IP 加入 Firewall 的 IP White List:
就可以開始連線了:
連線成功,下個 Query 看看:
結束也很簡單:
於是,在 Azure Portal 裡頭,就有一個 SQL Server 的 CLI 工具可以使用囉!