GitHub Copilot 除了自己本身模型內含的知識之外,還可以透過安裝 Extension 來加強本身的能力,微軟就有針對 Azure 推出了官方的 GitHub Copilot for Azure 這一個 Extension,我們就可以在 GitHub Copilot 詢問關於 Azure 的問題,後面就來介紹如何安裝跟使用。

說明
什麼是 GitHub Copilot for Azure
GitHub Copilot for Azure 是由微軟開發的 GitHub Copilot Extension,可以讓我們透過 @azure 聊天來取得關於 Azure 服務、Azure 開發、Azure DevOps Task 等的協助。
如何安裝和設定 GitHub Copilot for Azure
安裝上也如同其他套件一樣,透過 Marketplace 就可以安裝了,搜尋 GitHub Copilot for Azure 就可以找到了,點選安裝就可以了。

接下來就是相關的設定,第一次使用會需要登入 Azure 帳號,點選允許之後就會跳出網頁,登入 Azure 帳號之後就可以了。

登入成功的話就會出現這畫面,就可以回到 VS Code 了。

後面也會要授權 Extension 可以使用 GitHub Copilot 的語言模型,就按照提示授權即可。

都設定成功的話就會出現提示訊息了,我們就可以開始使用 @azure 來取得協助了。

如果出現下面的訊息代表目前登入的 Tenant 的管理員沒有打開相關的設定,所以登入的帳號會無法使用 Copilot。

我們可以到 Azure Copilot 系統管理中心來打開設定,可以如下打開設定讓所有使用者可以使用,或是挑選特定使用者可以使用。

關閉所有使用者皆可使用的話,就可以點選管理存取去選擇要授權的帳號。

針對需要授權的帳號給予 Copilot in Azure User
這一個角色就可以了。

如果登入的帳號可以管理多個目錄,可以輸入 @azure /changeTenant
來切換使用的 Tenant。

如果 Tenant 底下有很多訂閱,也可以選取要回答的範圍,這在我們要處理特定訂閱底下服務的時候會很方便。

GitHub Copilot for Azure 可以做到什麼
瞭解 Azure
可以詢問 Azure 相關的問題,會從官方的 Learn 文件裡面整理出相關的答案給我們,並可以看到有相關的連結,讓我們可以快速連到文件來查看更多內容。

管理資源
因為我們有登入 Azure 帳號,也可以選擇 Tenant 和目錄,就可以針對選取的範圍的 Azure 服務來做對應的管理操作。比如說列出選擇的範圍的 App Service,Extension 就會在背後呼叫 Api 來做查詢或操作。

或是查詢 App Service 的狀態

但是如果要他直接幫我們關閉 App Service 的話,是沒有辦法的,但是會產生對應的 Azure Cli 語法給我們,我們就可以直接插入到命令提示字元來執行,整個操作是可以留在 VS Code 裡面的。

診斷和故障排除
如果有安裝 Azure Extension 的話,就可以直接選擇資源來詢問問題,就可以詢問目前服務遇到的問題或是運行狀況分析等。

成本管理
可以詢問跟成本有關的問題,@azure 就會透過 Cost Management Api 來取得相關的資訊並整理結果給我們,比如說我請他列出服務的金額給我。

Azure 開發人員 Cli (azd) 協助
可以詢問相關的 Azure Cli 指令,給的資訊越多就可以幫我們直接組出更完整的 Cli 指令,比如說要建立一個資源群組和一台 VM,就會根據有提供的資訊給我們指令,其他指令則是提示要填入哪些值。

加強 GitHub Copilot for Azure 回答 Azure Kubernetes Service (AKS) 能力
當我們問到關於 Azure Kubernetes Service (AKS) 服務的時候,會提示我們安裝另一個 Extension,安裝之後就可以強化透過 @azure 來詢問或管理 AKS 的能力。

安裝完之後就可以透過 @azure 協助我們有更方便的方式來操作或是管理 AKS。

結論
GitHub Copilot for Azure 提供了開發人員在 VS Code 中更直觀、便利的 Azure 服務協助,讓日常的雲端管理與開發工作更加高效。透過 @azure 指令,我們能快速取得 Azure 文件的資訊、執行資源管理、進行診斷與故障排除,甚至是查詢成本與生成 Azure Cli 指令。
安裝與設定過程簡單直觀,並且支援多租戶切換及特定使用者權限管理,進一步提升了使用的彈性與安全性。隨著額外的擴充功能,如 AKS 管理能力的加強,GitHub Copilot for Azure 成為 Azure 開發與管理不可或缺的智慧助手。