Skip to content

Commit 653c46c

Browse files
authored
support custom agent for .net appmod (#50282)
* support custom agent in cli
1 parent 61534d4 commit 653c46c

File tree

5 files changed

+237
-30
lines changed

5 files changed

+237
-30
lines changed

docs/azure/migration/appmod/coding-agent-support.md

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This article shows you how to migrate .NET apps using **GitHub Copilot app moder
3434
dotnet --info
3535
```
3636
37-
## Get started
37+
## Add the MCP Server
3838
3939
1. Go to **Settings** for the target repository you want to modernize (admin access required).
4040
1. Select **Copilot**, then select **Coding Agent**.
@@ -65,21 +65,118 @@ This article shows you how to migrate .NET apps using **GitHub Copilot app moder
6565
1. (Optional) If environment variables are required, set them under **Environment → Copilot** in the settings. These variables initialize automatically the first time an agentic task is invoked in this repository.
6666
1. Save the MCP configuration.
6767

68-
### Migrate your .NET application to Azure
68+
### Create a custom agent
6969

70-
To migrate your .NET application to Azure, describe your migration scenario in the agent prompt. For example:
70+
1. Go to the agents tab at <https://github.com/copilot/agents>.
71+
1. In the prompt box, open the dropdown, and select the repository where you want to create the custom agent profile.
72+
1. (Optional) Select the branch where you want to create the agent profile. The default is the main branch.
73+
1. Select the **Copilot** icon, then select **+ Create an agent**. This action opens a template agent profile named `my-agent.agent.md` in the `.github/agents` directory of your target repository.
74+
1. Paste the content below into the template, and rename the file to `appmod-dotnet.agent.md`.
7175

72-
```text
73-
Migrate this project from local file I/O to Azure Blob Storage
74-
Migrate this project from local SQL Server to Azure SQL Database with managed identity
75-
Migrate this project from file-based logging to OpenTelemetry
76-
```
76+
```
77+
---
78+
# .NET Modernization Assistant - Custom GitHub Copilot Agent
79+
# This agent helps modernize .NET applications with modern technologies and prepare them for Azure
80+
# For format details, see: https://gh.io/customagents/config
81+
82+
name: dotnet-modernization
83+
description: Expert assistant for modernizing .NET applications with modern technologies (logging, authentication, configuration) and preparing them for Azure migration, with specialized tools for assessment, code analysis, and step-by-step migration guidance.
84+
---
85+
86+
# .NET Modernization Assistant
87+
88+
I am a specialized AI assistant for modernizing .NET applications with modern technologies and preparing them for Azure.
89+
90+
## What I Can Do
91+
92+
- **Migration**: Execute structured migrations to modern technologies (logging, authentication, configuration, data access)
93+
- **Validation**: Run builds, tests, CVE checks, and consistency/completeness verification
94+
- **Tracking**: Maintain migration plans and progress in `.appmod/.migration/` directory
95+
- **Azure Preparation**: Modernize code patterns for cloud-native Azure deployment
96+
97+
## ⚠️ CRITICAL: Migration Workflow
98+
99+
### 1. Planning Phase (REQUIRED FIRST STEP)
100+
**Before any migration work, I MUST call `dotnet_migration_plan_tool` first.**
101+
102+
This tool will provide instructions for generating `plan.md` and `progress.md` files in `.appmod/.migration/`.
103+
104+
### 2. Execution Phase
105+
**I MUST strictly follow the plan and progress files.**
106+
107+
Migration phases in order:
108+
1. **Analysis**: Analyze the solution structure and dependencies
109+
2. **Dependencies**: Update NuGet packages and project references
110+
3. **Configuration**: Migrate config files (app.config/web.config → appsettings.json)
111+
4. **Code**: Transform code to modern .NET patterns
112+
5. **Verification** (MANDATORY - NO SKIPPING):
113+
- ✅ Build verification (use bash command `dotnet msbuild`)
114+
- ✅ CVE vulnerability check (`check_cve_vulnerability`)
115+
- ✅ Consistency check (`migration_consistency`)
116+
- ✅ Completeness check (`migration_completeness`)
117+
- ✅ Unit test verification (use bash command `dotnet test`)
118+
119+
### 3. Completion Phase
120+
**Write a brief summary of the migration process**, including:
121+
- What was migrated
122+
- Key changes made
123+
- Verification results
124+
- Any issues encountered and resolved
125+
126+
## Core Principles
127+
128+
1. **Always call tools in real-time** - Never reuse previous results
129+
2. **Follow the plan strictly** - Update `progress.md` after each task
130+
3. **Never skip verification steps** - All checks are mandatory
131+
4. **Use tools, not instructions** - Execute actions directly via tools
132+
5. **Track progress** - Create Git branches and commits for each task
133+
134+
## Important Rules
135+
136+
✅ **DO:**
137+
- Call `dotnet_migration_plan_tool` before any migration
138+
- Follow plan.md and progress.md strictly
139+
- Complete ALL verification steps
140+
- Write migration summary at completion
141+
- Read files before editing them
142+
- Track all changes in Git
143+
144+
❌ **DON'T:**
145+
- Skip the planning tool
146+
- Skip any verification steps
147+
- Reuse previous tool results
148+
- Stop mid-migration for confirmation
149+
- Skip progress tracking
150+
151+
---
152+
153+
**Ready to modernize your .NET applications?** Ask me to start a migration!
154+
155+
```
77156

78-
For details on predefined migration tasks, see [migration tasks](predefined-tasks.md).
157+
1. Commit the file, and merge it into the default branch.
158+
1. Return to the agents tab, and refresh the page if needed. Your custom agent appears in the dropdown when you open the agent selector in the prompt box.
79159

80-
1. Open the Agents panel and enter your prompt. After you submit it, Copilot starts a new session and opens a new pull request. It appears in the list below the prompt box. Copilot works on the task and adds you as a reviewer when it finishes, triggering a notification.
160+
Visit [Create a custom agent profile in a repository on GitHub](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/create-custom-agents#creating-a-custom-agent-profile-in-a-repository-on-github) for more information.
161+
162+
### Migrate the .NET application to Azure
163+
164+
1. Open the [Agents panel](https://github.com/copilot/agents).
165+
1. Select your `target repository`, select the `custom agent` and enter your `prompt`.
166+
167+
After you submit it, Copilot starts a new session and opens a new pull request. It appears in the list below the prompt box. Copilot works on the task and adds you as a reviewer when it finishes, triggering a notification.
168+
169+
:::image type="content" source="./media/coding-agent/select-custom-agent.png" lightbox="./media/coding-agent/select-custom-agent.png" alt-text="Screenshot of .NET migrate task input in Coding Agent.":::
170+
171+
Here are some prompt examples for your reference:
172+
173+
```text
174+
Migrate this project from local file I/O to Azure Blob Storage
175+
Migrate this project from local SQL Server to Azure SQL Database with managed identity
176+
Migrate this project from file-based logging to OpenTelemetry
177+
```
81178

82-
:::image type="content" source="./media/coding-agent/migrate-input.png" lightbox="./media/coding-agent/migrate-input.png" alt-text="Screenshot of .NET migrate task input in Coding Agent.":::
179+
For details on predefined migration tasks, see [migration tasks](predefined-tasks.md).
83180

84181
1. After the migration starts, monitor the progress:
85182

@@ -89,7 +186,7 @@ For details on predefined migration tasks, see [migration tasks](predefined-task
89186

90187
:::image type="content" source="./media/coding-agent/migrate-completion.png" lightbox="./media/coding-agent/migrate-completion.png" alt-text="Screenshot of .NET migrate completion in Coding Agent.":::
91188

92-
### Deploy your .NET application to Azure
189+
### Deploy the .NET application to Azure
93190

94191
After migration, deploy directly from Coding Agent using a prompt such as:
95192

docs/azure/migration/appmod/copilot-cli-support.md

Lines changed: 128 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Learn how to migrate .NET applications to Azure with **GitHub Copilot app modern
3030
- A GitHub Copilot subscription. See [Copilot plans](https://github.com/features/copilot/plans?ref_product=copilot).
3131
- [Install the .NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0).
3232

33-
## Getting started
33+
## Get started
3434

3535
1. In a terminal, navigate to the .NET project folder containing the code you want to work on.
3636
1. Run `copilot` to start Copilot CLI.
@@ -49,13 +49,15 @@ Learn how to migrate .NET applications to Azure with **GitHub Copilot app modern
4949
- **Yes, and remember this folder for future sessions**: Trust the files in this folder for this and future sessions. You won't be asked again when you start Copilot CLI here. Only choose this option if you are sure it will always be safe for Copilot to work with files in this location.
5050
- **No, exit (Esc)**: End the Copilot CLI session.
5151

52-
1. Add MCP servers. Run `/mcp add` in Copilot CLI using the configuration below. For example, to add the .NET migration MCP server:
52+
### Add the MCP Server
5353

54-
```bash
54+
1. Run `/mcp add` in Copilot CLI using the configuration below. For example, here are two ways to add the .NET migration MCP server:
55+
56+
```text
5557
/mcp add DotNetAppModMcpServer-migrate
5658
```
5759

58-
Fill the fields as follows:
60+
1. Fill the fields as follows:
5961

6062
- Server Type: Local
6163
- Command: `dnx Microsoft.AppModernization.McpServer.DotNet.Migration --yes --source https://api.nuget.org/v3/index.json`
@@ -84,33 +86,141 @@ Learn how to migrate .NET applications to Azure with **GitHub Copilot app modern
8486
}
8587
```
8688

87-
Run `/mcp show` to confirm the MCP server configuration.
89+
1. Run `/mcp show` to confirm the MCP server configuration.
8890

89-
```bash
91+
```text
9092
/mcp show
9193
```
9294

93-
1. Run the migration task in Copilot CLI.
95+
### Configure a custom agent
9496

95-
Describe your migration scenario in Copilot CLI to migrate your .NET app to Azure.
96-
Use a prompt like *migrate from X to Y* for any migration task.
97-
Copilot CLI supports predefined migration scenarios that follow Microsoft best practices. For details, see [migration tasks](predefined-tasks.md).
97+
1. Create a file in the local `~/.copilot/agents` directory named `appmod-dotnet.agent.md`.
98+
1. Add the following content to define a User-level custom agent.
9899

99-
Example prompts:
100+
For more information, visit [Use custom agents in Copilot CLI](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli#use-custom-agents).
100101

101102
```text
102-
Migrate this app from local file I/O to Azure Blob Storage
103-
Migrate this app from local SQL Server to Azure SQL Database with managed identity
104-
Migrate this app from file-based logging to OpenTelemetry
103+
---
104+
# .NET Modernization Assistant - Custom GitHub Copilot Agent
105+
# This agent helps modernize .NET applications with modern technologies and prepare them for Azure
106+
# For format details, see: https://gh.io/customagents/config
107+
108+
name: dotnet-modernization
109+
description: Expert assistant for modernizing .NET applications with modern technologies (logging, authentication, configuration) and preparing them for Azure migration, with specialized tools for assessment, code analysis, and step-by-step migration guidance.
110+
---
111+
112+
# .NET Modernization Assistant
113+
114+
I am a specialized AI assistant for modernizing .NET applications with modern technologies and preparing them for Azure.
115+
116+
## What I Can Do
117+
118+
- **Migration**: Execute structured migrations to modern technologies (logging, authentication, configuration, data access)
119+
- **Validation**: Run builds, tests, CVE checks, and consistency/completeness verification
120+
- **Tracking**: Maintain migration plans and progress in `.appmod/.migration/` directory
121+
- **Azure Preparation**: Modernize code patterns for cloud-native Azure deployment
122+
123+
## ⚠️ CRITICAL: Migration Workflow
124+
125+
### 1. Planning Phase (REQUIRED FIRST STEP)
126+
**Before any migration work, I MUST call `dotnet_migration_plan_tool` first.**
127+
128+
This tool will provide instructions for generating `plan.md` and `progress.md` files in `.appmod/.migration/`.
129+
130+
### 2. Execution Phase
131+
**I MUST strictly follow the plan and progress files.**
132+
133+
Migration phases in order:
134+
1. **Analysis**: Analyze the solution structure and dependencies
135+
2. **Dependencies**: Update NuGet packages and project references
136+
3. **Configuration**: Migrate config files (app.config/web.config → appsettings.json)
137+
4. **Code**: Transform code to modern .NET patterns
138+
5. **Verification** (MANDATORY - NO SKIPPING):
139+
- ✅ Build verification (use bash command `dotnet msbuild`)
140+
- ✅ CVE vulnerability check (`check_cve_vulnerability`)
141+
- ✅ Consistency check (`migration_consistency`)
142+
- ✅ Completeness check (`migration_completeness`)
143+
- ✅ Unit test verification (use bash command `dotnet test`)
144+
145+
### 3. Completion Phase
146+
**Write a brief summary of the migration process**, including:
147+
- What was migrated
148+
- Key changes made
149+
- Verification results
150+
- Any issues encountered and resolved
151+
152+
## Core Principles
153+
154+
1. **Always call tools in real-time** - Never reuse previous results
155+
2. **Follow the plan strictly** - Update `progress.md` after each task
156+
3. **Never skip verification steps** - All checks are mandatory
157+
4. **Use tools, not instructions** - Execute actions directly via tools
158+
5. **Track progress** - Create Git branches and commits for each task
159+
160+
## Important Rules
161+
162+
**DO:**
163+
- Call `dotnet_migration_plan_tool` before any migration
164+
- Follow plan.md and progress.md strictly
165+
- Complete ALL verification steps
166+
- Write migration summary at completion
167+
- Read files before editing them
168+
- Track all changes in Git
169+
170+
**DON'T:**
171+
- Skip the planning tool
172+
- Skip any verification steps
173+
- Reuse previous tool results
174+
- Stop mid-migration for confirmation
175+
- Skip progress tracking
176+
177+
---
178+
179+
**Ready to modernize your .NET applications?** Ask me to start a migration!
180+
105181
```
106182
107-
The migration task runs and shows progress in Copilot CLI.
183+
Use the custom agent in one of the following ways:
184+
185+
- Use the slash command in interactive mode to select from the list of available custom agents:
186+
187+
```text
188+
/agent
189+
```
190+
191+
:::image type="content" source="./media/select-custom-agent.png" lightbox="./media/select-custom-agent.png" alt-text="Screenshot of selecting .NET migration custom agent in Copilot CLI.":::
192+
193+
- Call the custom agent directly in a prompt:
194+
195+
```text
196+
Use the dotnet modernization agent to migrate this application from local File IO to use Azure Blob Storage.
197+
```
198+
199+
### Run the migration task in Copilot CLI
200+
201+
Describe your migration scenario in Copilot CLI to migrate your .NET app to Azure. Use a prompt like:
202+
203+
```text
204+
*migrate from X to Y* for any migration task
205+
```
206+
207+
Copilot CLI supports predefined migration scenarios that follow Microsoft best practices. For details, see [migration tasks](predefined-tasks.md).
208+
209+
Example prompts:
210+
211+
```text
212+
Use the dotnet modernization agent to migrate this app from local file I/O to Azure Blob Storage
213+
Use the dotnet modernization agent to migrate this app from local SQL Server to Azure SQL Database with managed identity
214+
Use the dotnet modernization agent to migrate this app from file-based logging to OpenTelemetry
215+
```
216+
217+
The migration task runs and shows progress in Copilot CLI.
108218
109-
:::image type="content" source="./media/migrate-details.png" lightbox="./media/migrate-details.png" alt-text="Screenshot of a .NET migration task progress details in Copilot CLI.":::
219+
:::image type="content" source="./media/migrate-details.png" lightbox="./media/migrate-details.png" alt-text="Screenshot of a .NET migration task progress details in Copilot CLI.":::
110220
111-
After migration, view the summary:
221+
After migration, view the summary:
112222
113-
:::image type="content" source="./media/migrate-summary.png" lightbox="./media/migrate-summary.png" alt-text="Screenshot of the .NET migration summary in Copilot CLI.":::
223+
:::image type="content" source="./media/migrate-summary.png" lightbox="./media/migrate-summary.png" alt-text="Screenshot of the .NET migration summary in Copilot CLI.":::
114224
115225
## Provide feedback
116226
-53.3 KB
Binary file not shown.
50.1 KB
Loading
30 KB
Loading

0 commit comments

Comments
 (0)