-
Notifications
You must be signed in to change notification settings - Fork 333
Add functionapp create command #1327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ba44039
8881b89
8467f71
494d6cf
9ee3b79
e049070
5158569
89c98f3
aca8641
767ccf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,203 @@ | ||||||
| // Copyright (c) Microsoft Corporation. | ||||||
| // Licensed under the MIT License. | ||||||
|
|
||||||
| using System.Net; | ||||||
| using Azure.Mcp.Core.Commands; | ||||||
| using Azure.Mcp.Core.Extensions; | ||||||
| using Azure.Mcp.Core.Models.Option; | ||||||
| using Azure.Mcp.Tools.FunctionApp.Models; | ||||||
| using Azure.Mcp.Tools.FunctionApp.Options; | ||||||
| using Azure.Mcp.Tools.FunctionApp.Options.FunctionApp; | ||||||
| using Azure.Mcp.Tools.FunctionApp.Services; | ||||||
| using Microsoft.Extensions.Logging; | ||||||
| using Microsoft.Mcp.Core.Models.Option; | ||||||
|
|
||||||
| namespace Azure.Mcp.Tools.FunctionApp.Commands.FunctionApp; | ||||||
|
|
||||||
| public sealed class FunctionAppCreateCommand(ILogger<FunctionAppCreateCommand> logger) | ||||||
| : BaseFunctionAppCommand<FunctionAppCreateOptions> | ||||||
| { | ||||||
| private const string CommandTitle = "Create Azure Function App"; | ||||||
| private readonly ILogger<FunctionAppCreateCommand> _logger = logger; | ||||||
|
|
||||||
| private readonly Option<string> _functionAppNameOption = FunctionAppOptionDefinitions.FunctionApp; | ||||||
| private readonly Option<string> _locationOption = FunctionAppOptionDefinitions.Location; | ||||||
| private readonly Option<string> _appServicePlanOption = FunctionAppOptionDefinitions.AppServicePlan; | ||||||
| private readonly Option<string> _planTypeOption = FunctionAppOptionDefinitions.PlanType; | ||||||
| private readonly Option<string> _planSkuOption = FunctionAppOptionDefinitions.PlanSku; | ||||||
| private readonly Option<string> _runtimeOption = FunctionAppOptionDefinitions.Runtime; | ||||||
| private readonly Option<string> _runtimeVersionOption = FunctionAppOptionDefinitions.RuntimeVersion; | ||||||
| private readonly Option<string> _osOption = FunctionAppOptionDefinitions.OperatingSystem; | ||||||
| private readonly Option<string> _storageAccountOption = FunctionAppOptionDefinitions.StorageAccount; | ||||||
| private readonly Option<string> _containerAppsEnvironmentOption = FunctionAppOptionDefinitions.ContainerAppsEnvironment; | ||||||
|
|
||||||
| public override string Id => "a19eaab4-4822-41cb-a6ec-ffdc56405400"; | ||||||
|
|
||||||
| public override string Name => "create"; | ||||||
|
|
||||||
| public override string Description => | ||||||
| """ | ||||||
| Create a new Azure Function App in the specified resource group and region. | ||||||
| Automatically provisions dependencies when omitted (App Service plan OR Container App managed environment + Container App, and a Storage account) and applies sensible runtime & SKU defaults. | ||||||
| Required options: | ||||||
| - subscription: Target Azure subscription (ID or name) | ||||||
| - resource-group: Resource group (created if missing) | ||||||
| - function-app: Globally unique Function App name | ||||||
| - location: Azure region (e.g. eastus) | ||||||
| Optional options: | ||||||
| - app-service-plan: Use an existing App Service plan; if omitted one is created when hosting on App Service (non-container). | ||||||
| - plan-type: Hosting kind to create when a plan is needed (consumption|flex|premium|appservice|containerapp). Default: consumption. | ||||||
| * consumption -> Y1 (Dynamic) | ||||||
| * flex / flexconsumption -> FC1 (FlexConsumption, Linux only) | ||||||
| * premium / functionspremium -> EP1 (Elastic Premium) | ||||||
| * appservice -> B1 (Basic) unless overridden by --plan-sku | ||||||
| * containerapp -> Creates a Container App instead of an App Service plan/site (no plan created). Container App will reuse the function-app name. | ||||||
|
||||||
| * containerapp -> Creates a Container App instead of an App Service plan/site (no plan created). Container App will reuse the function-app name. | |
| * containerapp -> Creates a Container App instead of an App Service plan/site (no plan created). Container App will reuse the function-app name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azure Function supports using managed identity to connect to storage account. If it is not too hard we should recommend users to use that instead of the connection string since connection strings use storage account keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I was following what Azure Portal does by default. That's been my pattern. I don't disagree that using managed identities are best practices.
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation inconsistency: The command description states the default Java version is "21.0" (line 72), but the code implementation in GetDefaultRuntimeVersion returns "17" for Java runtime (line 55 in FunctionAppService.cs). These should match.
| * java -> 21.0 | |
| * java -> 17.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description should describe what the tool/tools will do to support this metadata value. Given that readOnly is false, it shouldn't say this tool only performs read operations. You can look at other tools with readOnly=false.
Same comment for other metadata descriptions.