Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 8d10f54

Browse files
colbytimmCopilotazure-sdkvcolin7joshfree
authored
Add Azure Function App get command (#970)
* Add get command to readme and changelog * Add function app details command to documentation and test prompts * Move function app list tests into functionapp folder * Implement GetFunctionApp service method * Add global usings for System.CommandLine and AzureMcp.Core.Options * Move function app list options to function app folder * Update namespace * Removed unused reference * Create base function app options * Create get function app options * remove unused reference from base function app command * Add FunctionAppGetCommand to retrieve Azure Function App details * Add FunctionAppGetCommand and related options for retrieving Function App details * Add unit tests for FunctionAppGetCommand to validate input and response handling * Add live tests for retrieving specific Function App details and handling errors * Update function app prompt to remove resource group specification * Fix cross-platform artifact detection in Run-ToolDescriptionConfidenceScore.ps1 * Update option name from 'functionapp' to 'function-app' for consistency across code and documentation * Address formatting * Fix links in CHANGELOG for Azure Function App commands and cross-platform bug * Improve get command description * Formatting and update unit tests * Fix typo in CHANGELOG * Fix command-line argument naming in FunctionAppGetCommandTests * Fix command-line argument naming for function app in tests * Fix indentation in FunctionAppGetCommandTests * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update e2e prompts to be ordered alphabetically * Update azmcp-commands to be ordered alphabetically for function apps * Update description based on feedback * Fix copilot merge issue * Increment version after release (#984) * Updated scoring metrics and renamed utility for evaluating tool descriptions (#965) * Updated scoring metrics and results * Renamed the utility to ToolDescriptionEvaluator * Added licensing header to .cs files * Update README with SSE deprecation notice (#994) Update README with SSE deprecation notice * Move e2etestprompts.md to docs (#992) * Updated Bicep tool to depend on latest Azure.Bicep.Types (0.6.1) and Azure.Bicep.Types.Az (0.2.792) versions (#893) * update bicep version * update tests * update bicep * Updated versions of Azure.Bicep.Types and Azure.Bicep.Types.Az, updated test to correspond to new parameter * Updated format of changelog and included Bicep tools in Native (AOT) build * Onboarding the Azure Service Health & Adding the resourcehealth availability-status get & resourcehealth availability-status list tools (#998) * Onboarding the Azure Service Health & Adding the resourcehealth availability-status get & resourcehealth availability-status list tools * Fix ResourceHealth unit test validation and AOT compatibility * Remove ResourceHealth live tests and test infrastructure * Fix Extension.UnitTests: Correct mock method signatures for IExternalProcessService.ExecuteAsync * Add NOTICE.txt and include in build output (#996) * Fix changelog due to merging * Undo changes to .env.example * Re-ran evaluator tool --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Co-authored-by: vcolin7 <vicolina@microsoft.com> Co-authored-by: Josh Free <joshfree@users.noreply.github.com> Co-authored-by: Jon Gallant <2163001+jongio@users.noreply.github.com> Co-authored-by: msalaman <masalama@microsoft.com> Co-authored-by: pkaza-msft <pkaza@microsoft.com> Co-authored-by: Patrick Hallisey <hallipr@gmail.com>
1 parent 9303b25 commit 8d10f54

File tree

21 files changed

+455
-19
lines changed

21 files changed

+455
-19
lines changed

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The Azure MCP Server updates automatically by default whenever a new release com
66

77
### Features Added
88

9+
- Added support for getting an Azure Function App via the command `azmcp-functionapp-get`. [[#970](https://github.com/Azure/azure-mcp/pull/970)]
910
- Introduced `BaseAzureResourceService` class to perform Azure Resource read operations using Azure Resource Graph queries. [[#938](https://github.com/Azure/azure-mcp/pull/938)]
1011
- Added support for the following Azure MySQL operations: [[#855](https://github.com/Azure/azure-mcp/issues/855)]
1112
- `azmcp_mysql_database_list` - List all databases in a MySQL server.
@@ -582,4 +583,4 @@ The Azure MCP Server updates automatically by default whenever a new release com
582583
- See https://github.com/Azure/azure-mcp/releases/tag/0.0.10
583584

584585
### Other Changes
585-
- See Blog post for details https://devblogs.microsoft.com/azure-sdk/introducing-the-azure-mcp-server/
586+
- See Blog post for details https://devblogs.microsoft.com/azure-sdk/introducing-the-azure-mcp-server/

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,11 @@ The Azure MCP Server supercharges your agents with Azure context. Here are some
180180
* List Azure Foundry models
181181
* Deploy foundry models
182182
* List foundry model deployments
183-
183+
184184
### ☁️ Azure Function App
185185

186186
* List Azure Function Apps
187+
* Get details for a specific Function App
187188

188189
### 🚀 Azure Managed Grafana
189190

‎areas/functionapp/src/AzureMcp.FunctionApp/Commands/BaseFunctionAppCommand.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Diagnostics.CodeAnalysis;
55
using AzureMcp.Core.Commands;
66
using AzureMcp.Core.Commands.Subscription;
7-
using AzureMcp.Core.Options;
87

98
namespace AzureMcp.FunctionApp.Commands;
109

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using Azure;
5+
using AzureMcp.Core.Commands;
6+
using AzureMcp.FunctionApp.Models;
7+
using AzureMcp.FunctionApp.Options;
8+
using AzureMcp.FunctionApp.Options.FunctionApp;
9+
using AzureMcp.FunctionApp.Services;
10+
using Microsoft.Extensions.Logging;
11+
12+
namespace AzureMcp.FunctionApp.Commands.FunctionApp;
13+
14+
public sealed class FunctionAppGetCommand(ILogger<FunctionAppGetCommand> logger)
15+
: BaseFunctionAppCommand<FunctionAppGetOptions>()
16+
{
17+
private const string CommandTitle = "Get Azure Function App Details";
18+
private readonly ILogger<FunctionAppGetCommand> _logger = logger;
19+
20+
private readonly Option<string> _functionAppNameOption = FunctionAppOptionDefinitions.FunctionApp;
21+
22+
public override string Name => "get";
23+
24+
public override string Description =>
25+
"""
26+
Get the Azure Function App details for the specified function app name and resource group.
27+
This command retrieves the details of a specific Azure Function App, including its name, location, status, and app service plan name.
28+
""";
29+
30+
public override string Title => CommandTitle;
31+
32+
public override ToolMetadata Metadata => new() { Destructive = false, ReadOnly = true };
33+
34+
protected override void RegisterOptions(Command command)
35+
{
36+
base.RegisterOptions(command);
37+
RequireResourceGroup();
38+
command.AddOption(_functionAppNameOption);
39+
}
40+
41+
protected override FunctionAppGetOptions BindOptions(ParseResult parseResult)
42+
{
43+
var options = base.BindOptions(parseResult);
44+
options.FunctionAppName = parseResult.GetValueForOption(_functionAppNameOption);
45+
return options;
46+
}
47+
48+
public override async Task<CommandResponse> ExecuteAsync(CommandContext context, ParseResult parseResult)
49+
{
50+
var options = BindOptions(parseResult);
51+
52+
try
53+
{
54+
if (!Validate(parseResult.CommandResult, context.Response).IsValid)
55+
return context.Response;
56+
57+
var service = context.GetService<IFunctionAppService>();
58+
var functionApp = await service.GetFunctionApp(
59+
options.Subscription!,
60+
options.FunctionAppName!,
61+
options.ResourceGroup!,
62+
options.Tenant,
63+
options.RetryPolicy);
64+
65+
context.Response.Results = functionApp is null
66+
? null
67+
: ResponseResult.Create(
68+
new FunctionAppGetCommandResult(functionApp),
69+
FunctionAppJsonContext.Default.FunctionAppGetCommandResult);
70+
}
71+
catch (Exception ex)
72+
{
73+
_logger.LogError(ex,
74+
"Error getting function app. Subscription: {Subscription}, ResourceGroup: {ResourceGroup}, FunctionApp: {FunctionApp}, Options: {@Options}",
75+
options.Subscription, options.ResourceGroup, options.FunctionAppName, options);
76+
HandleException(context, ex);
77+
}
78+
79+
return context.Response;
80+
}
81+
82+
protected override string GetErrorMessage(Exception ex) => ex switch
83+
{
84+
RequestFailedException reqEx when reqEx.Status == 404 =>
85+
"Function App not found. Verify the app name, resource group, and subscription, and ensure you have access.",
86+
RequestFailedException reqEx when reqEx.Status == 403 =>
87+
$"Authorization failed accessing the Function App. Details: {reqEx.Message}",
88+
RequestFailedException reqEx => reqEx.Message,
89+
_ => base.GetErrorMessage(ex)
90+
};
91+
92+
protected override int GetStatusCode(Exception ex) => ex switch
93+
{
94+
RequestFailedException reqEx => reqEx.Status,
95+
_ => base.GetStatusCode(ex)
96+
};
97+
98+
internal record FunctionAppGetCommandResult(FunctionAppInfo FunctionApp);
99+
}

‎areas/functionapp/src/AzureMcp.FunctionApp/Commands/FunctionApp/FunctionAppListCommand.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
using Azure;
55
using AzureMcp.Core.Commands;
6-
using AzureMcp.Core.Services.Telemetry;
76
using AzureMcp.FunctionApp.Models;
8-
using AzureMcp.FunctionApp.Options;
7+
using AzureMcp.FunctionApp.Options.FunctionApp;
98
using AzureMcp.FunctionApp.Services;
109
using Microsoft.Extensions.Logging;
1110

‎areas/functionapp/src/AzureMcp.FunctionApp/Commands/FunctionAppJsonContext.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace AzureMcp.FunctionApp.Commands;
99

1010
[JsonSerializable(typeof(FunctionAppListCommand.FunctionAppListCommandResult))]
11+
[JsonSerializable(typeof(FunctionAppGetCommand.FunctionAppGetCommandResult))]
1112
[JsonSerializable(typeof(FunctionAppInfo))]
1213
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
1314
internal partial class FunctionAppJsonContext : JsonSerializerContext;

‎areas/functionapp/src/AzureMcp.FunctionApp/FunctionAppSetup.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ public void RegisterCommands(CommandGroup rootGroup, ILoggerFactory loggerFactor
2424

2525
functionApp.AddCommand("list", new FunctionAppListCommand(
2626
loggerFactory.CreateLogger<FunctionAppListCommand>()));
27+
28+
functionApp.AddCommand("get", new FunctionAppGetCommand(
29+
loggerFactory.CreateLogger<FunctionAppGetCommand>()));
2730
}
2831
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
global using System.CommandLine;
45
global using System.CommandLine.Parsing;
56
global using AzureMcp.Core.Models.Command;
7+
global using AzureMcp.Core.Options;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System.Text.Json.Serialization;
5+
6+
namespace AzureMcp.FunctionApp.Options;
7+
8+
public class BaseFunctionAppOptions : SubscriptionOptions
9+
{
10+
[JsonPropertyName(FunctionAppOptionDefinitions.FunctionAppName)]
11+
public string? FunctionAppName { get; set; }
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace AzureMcp.FunctionApp.Options.FunctionApp;
5+
6+
public class FunctionAppGetOptions : BaseFunctionAppOptions;

0 commit comments

Comments
 (0)