立即使用 GitHub Copilot for Azure,簡化您的開發流程並提升 Azure 平台的生產力。 本指南將引導你了解 Visual Studio 中 GitHub Copilot for Azure 的安裝與前置條件,讓你能撰寫第一個提示詞。
必要條件
若要完成本文中的步驟,請確定您有:
一個 Azure 帳號和 Azure 訂閱的存取權。 關於如何設定,請參閱Azure帳戶的 定價頁面。
一個 GitHub 帳號和一個 GitHub Copilot 訂閱。 關於如何設定,請參考在GitHub建立帳號和快速入門GitHub Copilot。
Visual Studio Code。 關於如何下載與安裝,請參見 設定 Visual Studio Code。
GitHub Copilot 擴充功能和 GitHub Copilot 聊天擴充功能。 關於如何安裝這些擴充功能的說明,請分別參考 在 VS Code 中設定 GitHub Copilot 及 在 VS Code 中開始使用 GitHub Copilot Chat。
重要
GitHub Copilot 是由 GitHub 管理的獨立訂閱。 有關GitHub Copilot訂閱與支援的問題,請參見 Getting Start with a GitHub Copilot Plan。
預設情況下,Azure 中的 Copilot 對租戶中的所有使用者開放。 不過,全域管理員可以在 Azure 中管理其組織對 Copilot 的存取權限。 存取權限也可選擇性授予特定的 Microsoft Entra 使用者或群組。 欲了解更多資訊,請參閱管理Azure中的Microsoft Copilot存取。
安裝 GitHub Copilot for Azure
- 在Visual Studio Code中,選擇Extensions圖示。
- 在擴充功能市場中,搜尋 GitHub Copilot for Azure。 當 GitHub Copilot for Azure 插件出現時,選擇 Install。
- 如果系統提示你,請登入你的 Azure 帳號。
撰寫您的第一個提示
請確定已安裝擴充功能、您已正確驗證,且延伸模組正常運作。
如果 [聊天] 視窗尚未開啟,請確定它已開啟,方法是選取功能表欄中的 [切換聊天] 按鈕,或選取 [切換聊天] 按鈕旁的下拉式清單,然後選取 [開啟聊天] [Ctrl+Alt+I]。
在聊天窗格底部的聊天文字區域中,輸入下列提示:
Do I have any Azure resources currently running?你的問題答案取決於你訂閱中目前在 Azure 上執行的是什麼。
接下來,使用下列提示:
What are your tools?完成回應會顯示一份 GitHub Copilot for Azure 專用工具清單,這些工具可供 GitHub Copilot 使用。 回應提供目前可供您使用之功能種類的良好概觀:
I'll ask the Azure development helper to recommend custom modes relevant to listing and explaining the GitHub Copilot for Azure tools in VS Code; expected outcome: a short set of recommended modes or tips to tailor the tools explanation. Progress update: I queried the Azure development helper to get recommended custom modes for this topic. Next, I'll list and briefly explain the tools I have available (grouped and with example prompts and common uses) so you can copy/paste or use them directly in VS Code. Tools I can use (concise overview) 1. Search & navigation - Capabilities: semantic code/documentation search, file search with globs, text search (grep), list directory contents, read file contents, find usages/references. - Example prompts: - "Find all usages of MyService in this workspace." - "Search for connectionString in **/*.config files." - When to use: locating code, docs, or examples quickly inside your repo. 2. Code editing & analysis - Capabilities: insert edits into files, create or modify files, suggest refactors, report code errors, find test files. - Example prompts: - "Add a function to validate input in src/utils.js." - "Refactor this function to use async/await and update its tests." - When to use: implementing features, fixing bugs, generating or updating code. 3. Terminal & Git operations - Capabilities: run shell commands, read terminal output, show git diffs and changed files. - Example prompts: - "Run npm test and show me failing tests." - "Stage and commit the changes with message 'fix: update README'." - When to use: run builds/tests, inspect outputs, perform git workflows (if enabled). 4. Project creation & workspace setup - Capabilities: create new workspaces, scaffold projects (templates), install VS Code extensions, create notebooks. - Example prompts: - "Generate a Node.js express app scaffold in a new folder." - "Add recommended extensions for Python development." - When to use: bootstrapping projects or adding project-level config. 5. Web & API tools - Capabilities: fetch web pages, retrieve API docs (for example VS Code API references), gather remote content for research. - Example prompts: - "Fetch the Azure CLI docs for az storage account list." - "Get the VS Code extension API docs for commands." - When to use: look up official docs or examples during work. 6. Azure-specific tools - Capabilities: Azure development best practices guidance, Microsoft Learn documentation lookup, query Azure Resource Graph (when authenticated), manage Azure auth context (change tenant, sign out), generate Azure CLI / Bicep / ARM snippets, Bicep schemas, and guidance for deploying models and services. - Example prompts: - "What are Azure best practices for deploying this function app?" - "@azure /changeTenant — set my default tenant to <tenant-id>" - "Generate a Bicep template for an App Service and a Storage Account." - When to use: any task that touches Azure resources, deployment, or configuration. 7. Documentation & learning - Capabilities: search and extract Microsoft Learn articles, provide code samples from official docs, show relevant how-to steps. - Example prompts: - "Show official docs for configuring Key Vault access policies." - "Give me a short tutorial on using Azure App Configuration." - When to use: learn or reference official Microsoft guidance. How I present results - Short answers or step-by-step instructions. - Full edits (I can create or modify files if you allow the extension to act). - Commands and code snippets you can paste into your terminal. - Checks (like running tests or linters) when terminal access is allowed. Example: Quick copy-paste prompts you can use in the VS Code chat - "What are your tools?" — lists the tools (this reply). - "Find all TODO comments in this repo and open a summary." - "Generate an az CLI command to list storage accounts sorted by region." - "@azure /changeTenant" — opens tenant selection (if you need to set a default). Notes and privacy/permissions - Some capabilities (like querying your Azure resources or running commands) require you to be signed in and to enable those tools in the extension (you can enable/disable specific tools in the chat pane tool list). - I won't perform actions that need elevated permissions without verifying your explicit consent. If you'd like, I can: - Expand any tool section with more example prompts and exact commands. - Show a short step-by-step for enabling/disabling tools in the chat pane. - Generate a one-page cheatsheet you can paste into an internal docs file. Which would you like next?回覆的內容可能會有所不同,並且可能會隨著新功能和工具的加入而隨著時間的推移而改變。
要測試關於 Azure 專用工具的提示,請嘗試以下提示:
What is the az command to list all my storage accounts ordered by location?該提示的完成可能會產生:
I'll show the exact az CLI commands (sorted ascending/descending) plus a few useful output variants and a quick note about prerequisites. Commands - Sorted by location (ascending), full JSON: az storage account list --query "sort_by(@, &location)" -o json - Sorted by location, show only name and location in a readable table: az storage account list --query "sort_by(@, &location)[].[name,location]" -o table - Sorted by location (descending): az storage account list --query "reverse(sort_by(@, &location))" -o json - Sorted by location and include resource group and SKU in table: az storage account list --query "sort_by(@, &location)[].[name,resourceGroup,sku.name,location]" -o table Notes - Run az login first and ensure the correct subscription is selected (e.g., az account set -s "<subscription-id-or-name>"). - You need permission to list storage accounts in the chosen subscription. - The query uses JMESPath (sort_by/reverse) to order results client-side. Would you like a version that groups counts by region or that queries across all subscriptions?
在代理程式模式中啟用和停用工具
你可能想停用或重新啟用 GitHub Copilot for Azure 提供的某些工具。
選取聊天窗格中的工具圖示。
使用工具清單旁的複選框來啟用/停用工具(或工具群組)。
設定您的預設租用戶
如果你有多個 Microsoft Entra ID 租戶,你可以使用以下提示設定預設租戶:
@azure /changeTenant
從頂端中央的下拉式清單中選取您的可用租戶。
您也可以在擴充功能設定中設定預設租使用者:
在Visual Studio Code中,在活動欄選擇Extensions。 然後往下滑到 GitHub Copilot for Azure。
選取延伸模組條目角落的齒輪圖示,然後從快顯功能表選取 設定。
在 Settings 標籤中,將Azure Resource Graph租戶設為你的 Microsoft Entra 租戶 ID。 你可以在 Azure 入口網站找到你的 Microsoft Entra 租戶 ID。
截圖顯示「設定」頁籤,其中有一個設定 Azure Resource Graph 租戶的選項。
查看 GitHub Copilot for Azure 指令檔
instructions 檔案(亦稱為「Azure Copilot 指引」)包含 GitHub Copilot 的高階指引,會在向 GitHub Copilot 發送 Azure 工具及 Azure MCP 伺服器工具的提示時納入到上下文視窗中。 本檔案中的指引旨在全球性,意即適用於 GitHub Copilot for Azure 所有專案間的所有互動。 此檔案位於隱藏資料夾位置,不打算修改。 你不應該修改這個檔案,因為它可能會降低或停用 GitHub Copilot for Azure,而且你的更改可能會被 GitHub Copilot for Azure 的新更新覆蓋。
查看「Azure Copilot 指引」,你可以了解 GitHub Copilot 的 Azure 工具和 Azure MCP 伺服器工具是如何被介紹到 GitHub Copilot 的,幫助你更深入理解其運作方式。
重要
您不應修改此檔案。
選取
ctrl+shift+p以開啟命令面板。輸入
Chat: Configure Instructions並選取項目。在 Visual Studio Code 指令面板中輸入的截圖。 在下一個步驟中,選取
AzureCopilotGuidelines。
開啟一個包含說明文件的新分頁。
重要
您不應修改此檔案。
必要條件
若要完成本文中的步驟,請確定您有:
一個 GitHub 帳號和一個 GitHub Copilot 訂閱。 關於如何設定,請參考在GitHub建立帳號和快速入門GitHub Copilot。
Visual Studio 2022 版本 17.14.30 或更新版本(任何版本)。 關於如何下載與安裝,請參見 Install Visual Studio。
重要
GitHub Copilot 是由 GitHub 管理的獨立訂閱。 有關GitHub Copilot訂閱與支援的問題,請參見 Getting Start with a GitHub Copilot Plan。
預設情況下,Azure 中的 Copilot 對租戶中的所有使用者開放。 不過,全域管理員可以在 Azure 中管理其組織對 Copilot 的存取權限。 存取權限也可選擇性授予特定的 Microsoft Entra 使用者或群組。 欲了解更多資訊,請參閱管理Azure中的Microsoft Copilot存取。
安裝 GitHub Copilot for Azure
Azure MCP 內建於 Visual Studio 2022。 不需要另外的 GitHub Copilot for Azure 擴充套件;Azure MCP 工具已隨 Azure 開發工作負載一併提供。
如果你已經安裝了 2022 Visual Studio,且想在初次安裝後新增GitHub Copilot Azure,請開啟安裝程式,Visual Studio選擇 Modify 按鈕,該按鈕會顯示可用的工作負載。
如果你是第一次安裝 Visual Studio 2022,Visual Studio 安裝程式會自動顯示可用的工作負載。
在工作負載標籤中,確保選取了 Azure開發工作負載。
選取 [安裝] 按鈕以完成安裝。
備註
Azure MCP 工具會透過定期的 Visual Studio 更新來維護。 要取得更新,請使用 Visual Studio 安裝程式(Modify或 Update),並確保你使用的是 2022 Visual Studio 最新版本。
啟動 Visual Studio 2022 並建立或載入專案。
開啟 GitHub Copilot Chat。
如果被要求,請登入你的 GitHub 帳號。
如果被要求,請登入你的 Azure 帳號。
在聊天區,選擇「選擇工具」按鈕(兩把扳手圖示),可顯示可用工具清單。 啟用所有 Azure 工具,方法是檢查頂端節點以確認 Azure MCP Server v.x.x.x 的狀態。
備註
Azure MCP 工具在 Visual Studio 2022 中預設是停用的,使用前必須手動啟用。 一旦從選擇工具對話框啟用,你的 Azure MCP 工具選擇會跨越多個會話持續存在。 Visual Studio 2026 專用的工具在 Visual Studio 2022 中無法使用。
撰寫您的第一個提示
如果聊天視窗還沒開啟,請選擇 View>GitHub Copilot Chat選單選項確認它已開啟。 默認情況下,您應該會看到聊天窗口停靠在右側。
在聊天窗格底部的聊天文字區域中,輸入下列提示:
Do I have any resources currently running?
預設情況下,GitHub Copilot 使用 ask 模式。 詢問模式會在聊天窗格中提供對您提問的回答。 Agent 模式讓GitHub Copilot能在工作區中採取行動。
你的問題答案取決於你訂閱中目前在 Azure 上執行的是什麼。
代理模式
在代理模式下,GitHub Copilot 可以執行整個 Visual Studio 工作空間的任務,包括編輯、執行終端機指令等等。
GitHub Copilot for Azure 提供「工具」,透過與 Azure 的深度整合來提升 GitHub Copilot 的主動性體驗。
若要在詢問和客服專員模式之間切換,請在聊天區域中選擇「詢問」選項旁邊的向下 V 形符號,然後選擇所需的模式。
在代理程式模式中啟用和停用工具
你可能想停用或重新啟用 GitHub Copilot for Azure 提供的某些工具。
選擇聊天窗格中的「選擇工具」圖示。
使用工具清單旁的複選框來啟用/停用工具(或工具群組)。
必要條件
若要完成本文中的步驟,請確定您有:
一個 Azure 帳號和 Azure 訂閱的存取權。 關於如何設定,請參閱Azure帳戶的 定價頁面。
一個 GitHub 帳號和一個 GitHub Copilot 訂閱。 關於如何設定,請參考在GitHub建立帳號和快速入門GitHub Copilot。
Visual Studio 2026(任何版本)。 關於如何下載與安裝,請參見 Install Visual Studio。
重要
GitHub Copilot 是由 GitHub 管理的獨立訂閱。 有關GitHub Copilot訂閱與支援的問題,請參見 Getting Start with a GitHub Copilot Plan。
預設情況下,Azure 中的 Copilot 對租戶中的所有使用者開放。 不過,全域管理員可以在 Azure 中管理其組織對 Copilot 的存取權限。 存取權限也可選擇性授予特定的 Microsoft Entra 使用者或群組。 欲了解更多資訊,請參閱管理Azure中的Microsoft Copilot存取。
安裝 GitHub Copilot for Azure
如果你已經安裝了 2026 Visual Studio,且想在初次安裝後新增Azure的GitHub Copilot,請開啟安裝程式,Visual Studio選擇 Modify 按鈕,該按鈕會顯示可用的工作負載。
如果你是第一次安裝 Visual Studio 2026,Visual Studio 安裝程式會自動顯示可用的工作負載。
在工作負載標籤中,確保選擇「Azure AI 開發」。
選取 [安裝] 按鈕以完成安裝。
啟動 Visual Studio 2026 並建立或載入專案。
開啟 GitHub Copilot Chat。
如果被要求,請登入你的 GitHub 帳號。
如果被要求,請登入你的 Azure 帳號。
在聊天區域中,選取 [選取工具 ] 按鈕 (兩個扳手圖示) 以顯示可用工具的清單。 藉由檢查頂端的 Azure 節點來啟用所有 Azure 工具。
同時選擇 Azure MCP Server 的頂端節點。
撰寫您的第一個提示
如果聊天視窗還沒開啟,請選擇 View>GitHub Copilot Chat選單選項確認它已開啟。 默認情況下,您應該會看到聊天窗口停靠在右側。
在聊天窗格底部的聊天文字區域中,輸入下列提示:
Do I have any resources currently running?
預設情況下,GitHub Copilot 使用 ask 模式。 詢問模式會在聊天窗格中提供對您提問的回答。 Agent 模式讓GitHub Copilot能在工作區中採取行動。
你的問題答案取決於你訂閱中目前在 Azure 上執行的是什麼。
代理模式
在代理模式下,GitHub Copilot 可以執行整個 Visual Studio 工作空間的任務,包括編輯、執行終端機指令等等。
GitHub Copilot for Azure 提供「工具」,透過與 Azure 的深度整合來提升 GitHub Copilot 的主動性體驗。
若要在詢問和客服專員模式之間切換,請在聊天區域中選擇「詢問」選項旁邊的向下 V 形符號,然後選擇所需的模式。
在代理程式模式中啟用和停用工具
你可能想停用或重新啟用 GitHub Copilot for Azure 提供的某些工具。
選擇聊天窗格中的「選擇工具」圖示。
使用工具清單旁的複選框來啟用/停用工具(或工具群組)。
相關內容
- 了解Azure的GitHub Copilot是什麼以及它是怎麼運作的。
- 請遵循quickstart,了解如何在軟體開發流程中加入GitHub Copilot for Azure。 快速入門說明如何將服務部署到 Azure、監控其狀態並排除問題。
- 請參閱學習更多關於Azure及了解您的Azure帳號、訂閱與資源範例提示。
- 請參閱設計與開發應用程式的範例提示,適用於Azure。
- 請參閱部署應用程式到 Azure 的範例提示。
- 請參閱疑難排解您的 Azure 資源的範例提示。