開始使用適用於 Azure 的 GitHub Copilot 來簡化您的開發工作流程,並提升您在 Azure 平臺上的生產力。 本指南會逐步引導您完成 Visual Studio 中適用於 Azure 的 GitHub Copilot 的必要條件和安裝,以便您可以撰寫第一個提示。
必要條件
若要完成本文中的步驟,請確定您有:
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 聊天。
重要
GitHub Copilot 是由 GitHub 管理的個別訂用帳戶。 如需 GitHub Copilot 訂用帳戶和支援的相關問題,請參閱 開始使用 GitHub Copilot 方案。
根據預設,Azure Copilot 可供租用戶中的所有使用者使用。 不過,全域管理員可以管理其組織對 Azure 中 Copilot 的存取權。 您也可以選擇性地將存取權授與特定的 Microsoft Entra 使用者或群組。 如需詳細資訊,請參閱 管理 Microsoft Azure Copilot 的存取權。
安裝 GitHub Copilot for Azure
- 在 Visual Studio Code 中,選取 [ 延伸模組 ] 圖示。
- 在擴充功能市集中,搜尋 GitHub Copilot for Azure。 當 Azure 延伸模組的 GitHub Copilot 出現時,請選取 [ 安裝]。
- 如果系統提示您,請登入您的 Azure 帳戶。
撰寫您的第一個提示
請確定已安裝擴充功能、您已正確驗證,且延伸模組正常運作。
如果 [聊天] 視窗尚未開啟,請確定它已開啟,方法是選取功能表欄中的 [切換聊天] 按鈕,或選取 [切換聊天] 按鈕旁的下拉式清單,然後選取 [開啟聊天] [Ctrl+Alt+I]。
在聊天窗格底部的聊天文字區域中,輸入下列提示:
Do I have any Azure resources currently running?您問題的答案取決於您訂用帳戶中目前在 Azure 中執行的內容。
接下來,使用下列提示:
What are your tools?完成回應會顯示 GitHub Copilot 可供 GitHub Copilot 使用之 Azure 特定工具的清單。 回應提供目前可供您使用之功能種類的良好概觀:
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 的 [活動列] 上,選取 [ 擴充功能]。 然後向下卷動至 適用於 Azure 的 GitHub Copilot。
選取延伸模組條目角落的齒輪圖示,然後從快顯功能表選取 設定。
在 [ 設定] 索引標籤上,將 Azure Resource Graph 租使用者設定為Microsoft Entra 租使用者識別碼。 您可以在 Azure 入口網站 中找到Microsoft Entra 租使用者標識碼。
檢視適用於 Azure 的 GitHub Copilot 指示檔案
指示檔案 (也稱為「Azure Copilot 指導方針」) 包含 GitHub Copilot 的高階指引,當將提示傳送至 GitHub Copilot for Azure 工具和 Azure MCP 伺服器工具時,會新增至內容視窗。 此檔案中的指導方針本質上是全球性的,意指適用於所有與 Azure 的 GitHub Copilot 相關的專案互動。 此檔案位於隱藏資料夾位置,不打算修改。 您不應該修改此檔案,因為您的變更可能會影響 GitHub Copilot 的效能或導致停用,並可能被覆寫。
檢視「Azure Copilot 指導方針」可讓您深入瞭解如何將 GitHub Copilot for Azure 工具和 Azure MCP 伺服器工具引入 GitHub Copilot,協助您更深入地瞭解其運作方式。
重要
您不應修改此檔案。
選取
ctrl+shift+p以開啟命令面板。輸入
Chat: Configure Instructions並選取項目。
在下一個步驟中,選取
AzureCopilotGuidelines。
開啟一個包含說明文件的新分頁。
重要
您不應修改此檔案。
必要條件
Azure 帳戶和 Azure 訂用帳戶的存取權。 如需如何設定它們的詳細資訊,請參閱 Azure 帳戶的定價頁面。
GitHub 帳戶和 GitHub Copilot 訂用帳戶。 如需如何設定帳戶的詳細資訊,請參閱 分別在 GitHub 上建立帳戶和 GitHub Copilot 快速入門。
Visual Studio 2022 (任何版本)。 如需如何下載和安裝的詳細資訊,請參閱 安裝 Visual Studio。
重要
GitHub Copilot 是由 GitHub 管理的個別訂用帳戶。 如需 GitHub Copilot 訂用帳戶和支援的相關問題,請參閱 開始使用 GitHub Copilot 方案。
安裝 GitHub Copilot for Azure
- 在 Visual Studio 2022 的 [延伸模組] 功能表中,選取 [管理延伸模組]。
- 在 [擴充功能管理員] 中,搜尋並選取 [適用於 Azure 的 GitHub Copilot (VS 2022)]。 選取 [安裝] 按鈕。
- 片刻之後,您會看到一個橫幅:「您的變更已排定。 修改將在 Microsoft Visual Studio 關閉時開始。關閉 Visual Studio。
- VSIX 安裝程式對話方塊隨即開啟,確認安裝。 選取 修改 按鈕。
- 片刻之後,您應該會看到「修改完成」。 選取 [關閉] 按鈕。
- 重新開啟 Visual Studio 2022。
- 選取工具列上視窗右上角的「GitHub Copilot」按鈕。 選取 [開啟聊天視窗]。
- 當 GitHub Copilot 聊天視窗出現時,在底部的聊天區域中,選取 Agent 模式,然後選取帶有兩個扳手的 選擇工具 按鈕。
- 在 [選取工具 ] 對話方塊中,您應該會看到 [Azure MCP 伺服器]。 如果未選擇任何工具(目前是預設值),您會在右側看到「0/153」。 選取父節點以選擇所有工具。
重要
如果您在工具清單中沒有看到「Azure MCP 伺服器」,您可能需要解除安裝並重新安裝延伸模組。
撰寫您的第一個提示
如果聊天視窗尚未開啟,請 選取檢視>GitHub Copilot 聊天 功能表選項,以確保它已開啟。 默認情況下,您應該會看到聊天窗口停靠在右側。
在聊天窗格底部的聊天文字區域中,輸入下列提示:
Do I have any resources currently running?
根據預設,GitHub Copilot 會使用 詢問 模式。 詢問模式會在聊天窗格中提供對您提問的回答。 代理程式 模式可讓 GitHub Copilot 在您的工作區中採取動作。
您問題的答案取決於您訂用帳戶中目前在 Azure 中執行的內容。
代理模式
在代理程式模式中,GitHub Copilot 可以在整個 Visual Studio 工作區中執行工作、進行編輯、執行終端機命令等。
適用於 Azure 的 GitHub Copilot 提供 GitHub Copilot 的「工具」,以透過與 Azure 的深度整合來增強代理程式體驗。
若要在詢問和客服專員模式之間切換,請在聊天區域中選擇「詢問」選項旁邊的向下 V 形符號,然後選擇所需的模式。
在代理程式模式中啟用和停用工具
您可能想要停用或重新啟用 GitHub Copilot for Azure 所提供的特定工具。
選擇聊天窗格中的「選擇工具」圖示。
使用工具清單旁的複選框來啟用/停用工具(或工具群組)。
必要條件
Azure 帳戶和 Azure 訂用帳戶的存取權。 如需如何設定它們的詳細資訊,請參閱 Azure 帳戶的定價頁面。
GitHub 帳戶和 GitHub Copilot 訂用帳戶。 如需如何設定帳戶的詳細資訊,請參閱 分別在 GitHub 上建立帳戶和 GitHub Copilot 快速入門。
Visual Studio 2026 (任何版本)。 如需如何下載和安裝的詳細資訊,請參閱 安裝 Visual Studio。
重要
GitHub Copilot 是由 GitHub 管理的個別訂用帳戶。 如需 GitHub Copilot 訂用帳戶和支援的相關問題,請參閱 開始使用 GitHub Copilot 方案。
安裝 GitHub Copilot for Azure
如果您已安裝 Visual Studio 2026,並想要在初始安裝之後新增 GitHub Copilot for Azure,請開啟 Visual Studio 安裝程式,然後選取 [修改] 按鈕,以顯示可用的工作負載。
如果您是第一次安裝 Visual Studio 2026,Visual Studio 安裝程式會自動顯示可用的工作負載。
在 [工作負載] 索引標籤上,確定已選取 [Azure AI 開發]。
選取 [安裝] 按鈕以完成安裝。
啟動 Visual Studio 2026 並建立或載入專案。
開啟 GitHub Copilot 聊天。
如果出現提示,請登入您的 GitHub 帳戶。
如果出現提示,登入您的 Azure 帳戶。
在聊天區域中,選取 [選取工具 ] 按鈕 (兩個扳手圖示) 以顯示可用工具的清單。 檢查 Azure 的頂端節點,以啟用所有 Azure 工具。
此外,請選取 Azure MCP 伺服器的最上層節點。
撰寫您的第一個提示
如果聊天視窗尚未開啟,請 選取檢視>GitHub Copilot 聊天 功能表選項,以確保它已開啟。 默認情況下,您應該會看到聊天窗口停靠在右側。
在聊天窗格底部的聊天文字區域中,輸入下列提示:
Do I have any resources currently running?
根據預設,GitHub Copilot 會使用 詢問 模式。 詢問模式會在聊天窗格中提供對您提問的回答。 代理程式 模式可讓 GitHub Copilot 在您的工作區中採取動作。
您問題的答案取決於您訂用帳戶中目前在 Azure 中執行的內容。
代理模式
在代理程式模式中,GitHub Copilot 可以在整個 Visual Studio 工作區中執行工作、進行編輯、執行終端機命令等。
適用於 Azure 的 GitHub Copilot 提供 GitHub Copilot 的「工具」,以透過與 Azure 的深度整合來增強代理程式體驗。
若要在詢問和客服專員模式之間切換,請在聊天區域中選擇「詢問」選項旁邊的向下 V 形符號,然後選擇所需的模式。
在代理程式模式中啟用和停用工具
您可能想要停用或重新啟用 GitHub Copilot for Azure 所提供的特定工具。
選擇聊天窗格中的「選擇工具」圖示。
使用工具清單旁的複選框來啟用/停用工具(或工具群組)。
相關內容
- 了解什麼是適用於 Azure 的 GitHub Copilot 及其運作方式。
- 按照快速入門指南,瞭解如何在軟體開發工作流程中包含 GitHub Copilot for Azure。 本快速入門說明如何將服務部署至 Azure、監視其狀態,以及疑難解答問題。
- 請參閱範例提示以 深入瞭解 Azure 並瞭解您的 Azure 帳戶、訂用帳戶和資源。
- 請參閱設計 及開發 Azure 應用程式的範例提示。
- 請參閱將應用程式部署至 Azure 的範例提示。
- 請參閱針對 Azure 資源進行疑難解答的範例提示。