This repository was archived by the owner on Sep 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 340
Add Azure Function App support with list command #863
Merged
Merged
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
295823e
Add custom words for function app to cspell configuration
colbytimm a60d467
Scaffold and setup Function app with list command
colbytimm d7c2329
Add test setup bicep
colbytimm 5175ce1
Add unit tests for list command
colbytimm d79871d
Add live tests
colbytimm f190073
Add Azure Function App operations and test prompts
colbytimm 1bb7753
Add "azurewebsites" to cspell dictionary and update README with Funct…
colbytimm 46ef11f
Fix formatting
colbytimm e11e809
Remove unnecessary comments
colbytimm 66c07bb
Update FunctionAppListCommandTests to include ResourceGroupName in ex…
colbytimm 3fd3c12
Update codeowners
colbytimm 5ddf883
Add additional test prompt for azmcp-aks-functionapp-list in e2eTestP…
colbytimm 62d780d
Fix typo for function app e2e tests
colbytimm 0a2a2a1
Add additional words to cspell configuration for content connection s…
colbytimm ff21840
Merge branch 'main' into feat/function-app-list
colbytimm a21429b
Update FunctionAppListCommand to inherit BaseFunctionAppCommand. Over…
colbytimm dc9c17f
Update subscription parameter name. Update cacheKey to remove unneces…
colbytimm 8e67d70
Merge branch 'main' into feat/function-app-list
colbytimm 8f00c34
Update changelog to include function app list command
colbytimm fc2ad62
Merge branch 'main' into feat/function-app-list
colbytimm 214a26e
Rename areas directory to `functionapp`
colbytimm bf5d253
Remove duplicate
colbytimm 7048bdd
Fix casing in function app directory paths in solution file
colbytimm 1f1228d
Update .github/CODEOWNERS
jongio f9e51c5
Update .github/CODEOWNERS
jongio 2ac753b
Update .github/CODEOWNERS
jongio 0d5c94d
Update .github/CODEOWNERS
jongio bcc1032
Remove base function app options since they are not necessary and ext…
colbytimm 17c4eb7
Remove option definition as it's not necessary for the list command.
colbytimm 3efb30a
Update command group description to align with other areas.
colbytimm facc849
Refactor BaseFunctionAppCommand to use SubscriptionOptions and update…
colbytimm fd1493d
Update FunctionApp to be record and update references and unit tests.
colbytimm 09d6a8a
Remove SubscriptionId from FunctionAppInfo and update related tests
colbytimm 6295ae7
Refactor FunctionAppInfo to include JsonPropertyName attributes for s…
colbytimm 3efe5f1
Update Azure.ResourceManager.AppService package version to 1.4.1
colbytimm 1565b61
Merge branch 'main' into feat/function-app-list
colbytimm c0f9d76
Remove telemetry tag based on consolidation change in #935
colbytimm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("AzureMcp.FunctionApp.UnitTests")] | ||
[assembly: InternalsVisibleTo("AzureMcp.FunctionApp.LiveTests")] |
19 changes: 19 additions & 0 deletions
19
areas/functionapp/src/AzureMcp.FunctionApp/AzureMcp.FunctionApp.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<IsAotCompatible>true</IsAotCompatible> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="**\Resources\*.txt" /> | ||
<EmbeddedResource Include="**\Resources\*.json" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\core\src\AzureMcp.Core\AzureMcp.Core.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Azure.ResourceManager" /> | ||
<PackageReference Include="Azure.ResourceManager.AppService" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" /> | ||
<PackageReference Include="ModelContextProtocol" /> | ||
<PackageReference Include="System.CommandLine" /> | ||
</ItemGroup> | ||
</Project> |
13 changes: 13 additions & 0 deletions
13
areas/functionapp/src/AzureMcp.FunctionApp/Commands/BaseFunctionAppCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using AzureMcp.Core.Commands; | ||
using AzureMcp.Core.Commands.Subscription; | ||
using AzureMcp.Core.Options; | ||
|
||
namespace AzureMcp.FunctionApp.Commands; | ||
|
||
public abstract class BaseFunctionAppCommand< | ||
[DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] TOptions> | ||
: SubscriptionCommand<TOptions> where TOptions : SubscriptionOptions, new(); |
82 changes: 82 additions & 0 deletions
82
areas/functionapp/src/AzureMcp.FunctionApp/Commands/FunctionApp/FunctionAppListCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Azure; | ||
using AzureMcp.Core.Commands; | ||
using AzureMcp.Core.Services.Telemetry; | ||
using AzureMcp.FunctionApp.Models; | ||
using AzureMcp.FunctionApp.Options; | ||
using AzureMcp.FunctionApp.Services; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace AzureMcp.FunctionApp.Commands.FunctionApp; | ||
|
||
public sealed class FunctionAppListCommand(ILogger<FunctionAppListCommand> logger) | ||
: BaseFunctionAppCommand<FunctionAppListOptions>() | ||
{ | ||
private const string CommandTitle = "List Azure Function Apps"; | ||
private readonly ILogger<FunctionAppListCommand> _logger = logger; | ||
|
||
public override string Name => "list"; | ||
|
||
public override string Description => | ||
""" | ||
Lists all Azure Function Apps in a subscription. | ||
Returns a list of function app details including name, location, status, and app service plan name. | ||
"""; | ||
|
||
public override string Title => CommandTitle; | ||
|
||
public override ToolMetadata Metadata => new() { Destructive = false, ReadOnly = true }; | ||
|
||
public override async Task<CommandResponse> ExecuteAsync(CommandContext context, ParseResult parseResult) | ||
{ | ||
var options = BindOptions(parseResult); | ||
|
||
try | ||
{ | ||
if (!Validate(parseResult.CommandResult, context.Response).IsValid) | ||
return context.Response; | ||
|
||
context.Activity?.WithSubscriptionTag(options); | ||
|
||
var functionAppService = context.GetService<IFunctionAppService>(); | ||
var functionApps = await functionAppService.ListFunctionApps( | ||
options.Subscription!, | ||
options.Tenant, | ||
options.RetryPolicy); | ||
|
||
context.Response.Results = functionApps?.Count > 0 | ||
? ResponseResult.Create( | ||
new FunctionAppListCommandResult(functionApps), | ||
FunctionAppJsonContext.Default.FunctionAppListCommandResult) | ||
: null; | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, "Error listing function apps. Subscription: {Subscription}, Options: {@Options}", | ||
options.Subscription, options); | ||
HandleException(context, ex); | ||
} | ||
|
||
return context.Response; | ||
} | ||
|
||
protected override string GetErrorMessage(Exception ex) => ex switch | ||
{ | ||
RequestFailedException reqEx when reqEx.Status == 404 => | ||
"Subscription not found. Verify the subscription ID and you have access.", | ||
RequestFailedException reqEx when reqEx.Status == 403 => | ||
$"Authorization failed accessing the function app resources. Details: {reqEx.Message}", | ||
RequestFailedException reqEx => reqEx.Message, | ||
_ => base.GetErrorMessage(ex) | ||
}; | ||
|
||
protected override int GetStatusCode(Exception ex) => ex switch | ||
{ | ||
RequestFailedException reqEx => reqEx.Status, | ||
_ => base.GetStatusCode(ex) | ||
}; | ||
|
||
internal record FunctionAppListCommandResult(List<FunctionAppInfo> Results); | ||
} |
13 changes: 13 additions & 0 deletions
13
areas/functionapp/src/AzureMcp.FunctionApp/Commands/FunctionAppJsonContext.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Text.Json.Serialization; | ||
using AzureMcp.FunctionApp.Commands.FunctionApp; | ||
using AzureMcp.FunctionApp.Models; | ||
|
||
namespace AzureMcp.FunctionApp.Commands; | ||
|
||
[JsonSerializable(typeof(FunctionAppListCommand.FunctionAppListCommandResult))] | ||
[JsonSerializable(typeof(FunctionAppInfo))] | ||
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] | ||
internal partial class FunctionAppJsonContext : JsonSerializerContext; |
28 changes: 28 additions & 0 deletions
28
areas/functionapp/src/AzureMcp.FunctionApp/FunctionAppSetup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using AzureMcp.Core.Areas; | ||
using AzureMcp.Core.Commands; | ||
using AzureMcp.FunctionApp.Commands.FunctionApp; | ||
using AzureMcp.FunctionApp.Services; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace AzureMcp.FunctionApp; | ||
|
||
public class FunctionAppSetup : IAreaSetup | ||
{ | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddSingleton<IFunctionAppService, FunctionAppService>(); | ||
} | ||
|
||
public void RegisterCommands(CommandGroup rootGroup, ILoggerFactory loggerFactory) | ||
{ | ||
var functionApp = new CommandGroup("functionapp", "Function App operations - Commands for managing and accessing Azure Function App resources."); | ||
rootGroup.AddSubGroup(functionApp); | ||
|
||
functionApp.AddCommand("list", new FunctionAppListCommand( | ||
loggerFactory.CreateLogger<FunctionAppListCommand>())); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
global using System.CommandLine.Parsing; | ||
global using AzureMcp.Core.Models.Command; |
16 changes: 16 additions & 0 deletions
16
areas/functionapp/src/AzureMcp.FunctionApp/Models/FunctionAppInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace AzureMcp.FunctionApp.Models; | ||
|
||
public record FunctionAppInfo( | ||
[property: JsonPropertyName("name")] string? Name, | ||
[property: JsonPropertyName("resourceGroupName")] string? ResourceGroupName, | ||
[property: JsonPropertyName("location")] string? Location, | ||
[property: JsonPropertyName("appServicePlanName")] string? AppServicePlanName, | ||
[property: JsonPropertyName("status")] string? Status, | ||
[property: JsonPropertyName("defaultHostName")] string? DefaultHostName, | ||
[property: JsonPropertyName("tags")] IDictionary<string, string>? Tags | ||
); |
8 changes: 8 additions & 0 deletions
8
areas/functionapp/src/AzureMcp.FunctionApp/Options/FunctionAppListOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using AzureMcp.Core.Options; | ||
|
||
namespace AzureMcp.FunctionApp.Options; | ||
|
||
public class FunctionAppListOptions : SubscriptionOptions; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.