Skip to content
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

Python file name is defaulted to the main file + templates for more triggers. #3373

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,20 @@ public async override Task RunAsync()
TemplateName = TemplateName ?? SelectionMenuHelper.DisplaySelectionWizard(GetTriggerNamesFromNewTemplates(Language));
}

if (string.IsNullOrEmpty(FileName))
// Defaulting the filename to "function_app.py" if the file name is not provided.
if (string.IsNullOrWhiteSpace(FileName))
{
var userPrompt = _userPrompts.Value.First(x => string.Equals(x.Id, "app-selectedFileName", StringComparison.OrdinalIgnoreCase));
while (!_userInputHandler.ValidateResponse(userPrompt, FileName))
FileName = "function_app.py";
}

var userPrompt = _userPrompts.Value.First(x => string.Equals(x.Id, "app-selectedFileName", StringComparison.OrdinalIgnoreCase));
while (!_userInputHandler.ValidateResponse(userPrompt, FileName))
{
_userInputHandler.PrintInputLabel(userPrompt, PySteinFunctionAppPy);
FileName = Console.ReadLine();
if (string.IsNullOrEmpty(FileName))
{
_userInputHandler.PrintInputLabel(userPrompt, PySteinFunctionAppPy);
FileName = Console.ReadLine();
if (string.IsNullOrEmpty(FileName))
{
FileName = PySteinFunctionAppPy;
}
FileName = PySteinFunctionAppPy;
}
}

Expand Down Expand Up @@ -179,6 +182,7 @@ public async override Task RunAsync()
FunctionName = providedInputs[GetFunctionNameParamId];
}


await _templatesManager.Deploy(templateJob, template, variables);
}
else
Expand Down
15 changes: 9 additions & 6 deletions src/Azure.Functions.Cli/Actions/UserInputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ private static IDictionary<string, string> CreateLabelMap()
{ "$httpTrigger_authLevel_label", "Auth Level" },
{ "$queueTrigger_queueName_label", "Queue Name" },
{ "$variables_storageConnStringLabel", "Storage Connection String" },
{ "cosmosDBTrigger-connectionStringSetting", "CosmosDB Connectiong Stirng" },
{ "$cosmosDBIn_databaseName_label", "CosmosDB Database Name" },
{ "$cosmosDBIn_collectionName_label", "CosmosDB Collection Name" },
{ "$cosmosDBIn_leaseCollectionName_label", "CosmosDB Lease Collection Name" },
{ "$cosmosDBIn_createIfNotExists_label", "Create If Not Exists" },
{ "$cosmosDB_connection_label", "CosmosDB Connection String" },
{ "$cosmosDB_databaseName_label", "CosmosDB Database Name" },
{ "$cosmosDB_containerName_label", "CosmosDB Container Name" },
{ "$cosmosDB_leaseContainerName_label", "CosmosDB Lease Container Name" },
{ "$cosmosDB_createIfNotExists_label", "Create If Not Exists" },
{ "$eventHubTrigger_connection_label", "EventHub Connection" },
{ "$eventHubOut_path_label", "EventHub Out Path" },
{ "$eventHubTrigger_consumerGroup_label", "EventHub Consumer Group" },
Expand All @@ -155,7 +155,10 @@ private static IDictionary<string, string> CreateLabelMap()
{ "$serviceBusTrigger_queueName_label", "Service Bus Queue Name" },
{ "$serviceBusTrigger_topicName_label", "Service Bus Topic Name" },
{ "$serviceBusTrigger_subscriptionName_label", "Service Bus Subscripton Name" },
{"$timerTrigger_schedule_label", "Schedule" },
{ "$timerTrigger_schedule_label", "Schedule" },
{ "$blobTrigger_path_label", "Container Path" },
{ "$blobTrigger_connection_label", "Storage Account Connection String" },
{ "$eventGrid_name_label", "EventGrid Name" },
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,52 +90,55 @@
}
]
},

{
"id": "blobTrigger-connection",
"name": "blobTrigger-connection",
"value": "string",
"label": "$blobTrigger_path_label",
"help": "$blobTrigger_path_help"
"resource": "Blob",
"label": "$blobTrigger_connection_label",
"help": "$blobTrigger_connection_help",
"placeholder": "$variables_selectConnection"
},
{
"id": "cosmosDBTrigger-connectionStringSetting",
"name": "cosmosDBTrigger-connectionStringSetting",
"id": "cosmosDBTrigger-connection",
"name": "cosmosDBTrigger-connection",
"value": "string",
"resource": "DocumentDB",
"label": "$cosmosDBIn_connection_label",
"help": "$cosmosDBIn_connection_help",
"label": "$cosmosDB_connection_label",
"help": "$cosmosDB_connection_help",
"placeholder": "$variables_selectConnection"
},
{
"id": "cosmosDBTrigger-databaseName",
"name": "cosmosDBTrigger-databaseName",
"value": "string",
"defaultValue": "",
"label": "$cosmosDBIn_databaseName_label",
"help": "$cosmosDBIn_databaseName_help"
"label": "$cosmosDB_databaseName_label",
"help": "$cosmosDB_databaseName_help"
},
{
"id": "cosmosDBTrigger-collectionName",
"name": "cosmosDBTrigger-collectionName",
"id": "cosmosDBTrigger-containerName",
"name": "cosmosDBTrigger-containerName",
"value": "string",
"defaultValue": "",
"label": "$cosmosDBIn_collectionName_label",
"help": "$cosmosDBIn_collectionName_help"
"label": "$cosmosDB_containerName_label",
"help": "$cosmosDB_containerName_help"
},
{
"id": "cosmosDBTrigger-leaseCollectionName",
"name": "cosmosDBTrigger-leaseCollectionName",
"id": "cosmosDBTrigger-leaseContainerName",
"name": "cosmosDBTrigger-leaseContainerName",
"value": "string",
"label": "$cosmosDBIn_leaseCollectionName_label",
"help": "$cosmosDBIn_leaseCollectionName_help"
"label": "$cosmosDB_leaseContainerName_label",
"help": "$cosmosDB_leaseContainer_help"
},
{
"id": "cosmosDBTrigger-createLeaseCollectionIfNotExists",
"name": "cosmosDBTrigger-createLeaseCollectionIfNotExists",
"id": "cosmosDBTrigger-createLeaseContainerIfNotExists",
"name": "cosmosDBTrigger-createLeaseContainerIfNotExists",
"value": "boolean",
"defaultValue": true,
"label": "$cosmosDBIn_createIfNotExists_label",
"help": "$cosmosDBIn_createIfNotExists_help"
"label": "$cosmosDB_createIfNotExists_label",
"help": "$cosmosDB_createIfNotExists_help"
},
{
"id": "eventHubTrigger-connection",
Expand Down Expand Up @@ -214,6 +217,20 @@
],
"validators": []
},
{
"id": "eventGridTrigger-eventGridName",
"name": "eventGridTrigger-eventGridName",
"value": "string",
"defaultValue": "myeventgrid",
"label": "$eventGrid_name_label",
"help": "$eventGrid_name_label_help",
"validators": [
{
"expression": "^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9-_.]{0,48}[a-zA-Z0-9]$|^[{][a-zA-Z0-9]{1,126}[}]$|^[%][a-zA-Z0-9]{1,126}[%]$",
"errorText": "$eventGrid_name_label_errorText"
}
]
},
{
"id": "serviceBusTrigger-connection",
"name": "serviceBusTrigger-connection",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.15.0, 4.0.0)"
"version": "[4.*, 5.0.0)"
}
Loading