Skip to content

Commit eb2d8a5

Browse files
khkh-msGavin Aguiar
and
Gavin Aguiar
authored
Python file name is defaulted to the main file + templates for more triggers. (#3373)
* Python filed name is defaulted to the main file. * Updated templates * Minor updated in templates * Setting the default for only python new programming model. * Revert "Setting the default for only python new programming model." This reverts commit 4154df3. --------- Co-authored-by: Gavin Aguiar <gavin@GavinPC>
1 parent 693c06a commit eb2d8a5

File tree

5 files changed

+1332
-48
lines changed

5 files changed

+1332
-48
lines changed

src/Azure.Functions.Cli/Actions/LocalActions/CreateFunctionAction.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,20 @@ public async override Task RunAsync()
140140
TemplateName = TemplateName ?? SelectionMenuHelper.DisplaySelectionWizard(GetTriggerNamesFromNewTemplates(Language));
141141
}
142142

143-
if (string.IsNullOrEmpty(FileName))
143+
// Defaulting the filename to "function_app.py" if the file name is not provided.
144+
if (string.IsNullOrWhiteSpace(FileName))
144145
{
145-
var userPrompt = _userPrompts.Value.First(x => string.Equals(x.Id, "app-selectedFileName", StringComparison.OrdinalIgnoreCase));
146-
while (!_userInputHandler.ValidateResponse(userPrompt, FileName))
146+
FileName = "function_app.py";
147+
}
148+
149+
var userPrompt = _userPrompts.Value.First(x => string.Equals(x.Id, "app-selectedFileName", StringComparison.OrdinalIgnoreCase));
150+
while (!_userInputHandler.ValidateResponse(userPrompt, FileName))
151+
{
152+
_userInputHandler.PrintInputLabel(userPrompt, PySteinFunctionAppPy);
153+
FileName = Console.ReadLine();
154+
if (string.IsNullOrEmpty(FileName))
147155
{
148-
_userInputHandler.PrintInputLabel(userPrompt, PySteinFunctionAppPy);
149-
FileName = Console.ReadLine();
150-
if (string.IsNullOrEmpty(FileName))
151-
{
152-
FileName = PySteinFunctionAppPy;
153-
}
156+
FileName = PySteinFunctionAppPy;
154157
}
155158
}
156159

@@ -179,6 +182,7 @@ public async override Task RunAsync()
179182
FunctionName = providedInputs[GetFunctionNameParamId];
180183
}
181184

185+
182186
await _templatesManager.Deploy(templateJob, template, variables);
183187
}
184188
else

src/Azure.Functions.Cli/Actions/UserInputHandler.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ private static IDictionary<string, string> CreateLabelMap()
142142
{ "$httpTrigger_authLevel_label", "Auth Level" },
143143
{ "$queueTrigger_queueName_label", "Queue Name" },
144144
{ "$variables_storageConnStringLabel", "Storage Connection String" },
145-
{ "cosmosDBTrigger-connectionStringSetting", "CosmosDB Connectiong Stirng" },
146-
{ "$cosmosDBIn_databaseName_label", "CosmosDB Database Name" },
147-
{ "$cosmosDBIn_collectionName_label", "CosmosDB Collection Name" },
148-
{ "$cosmosDBIn_leaseCollectionName_label", "CosmosDB Lease Collection Name" },
149-
{ "$cosmosDBIn_createIfNotExists_label", "Create If Not Exists" },
145+
{ "$cosmosDB_connection_label", "CosmosDB Connection String" },
146+
{ "$cosmosDB_databaseName_label", "CosmosDB Database Name" },
147+
{ "$cosmosDB_containerName_label", "CosmosDB Container Name" },
148+
{ "$cosmosDB_leaseContainerName_label", "CosmosDB Lease Container Name" },
149+
{ "$cosmosDB_createIfNotExists_label", "Create If Not Exists" },
150150
{ "$eventHubTrigger_connection_label", "EventHub Connection" },
151151
{ "$eventHubOut_path_label", "EventHub Out Path" },
152152
{ "$eventHubTrigger_consumerGroup_label", "EventHub Consumer Group" },
@@ -155,7 +155,10 @@ private static IDictionary<string, string> CreateLabelMap()
155155
{ "$serviceBusTrigger_queueName_label", "Service Bus Queue Name" },
156156
{ "$serviceBusTrigger_topicName_label", "Service Bus Topic Name" },
157157
{ "$serviceBusTrigger_subscriptionName_label", "Service Bus Subscripton Name" },
158-
{"$timerTrigger_schedule_label", "Schedule" },
158+
{ "$timerTrigger_schedule_label", "Schedule" },
159+
{ "$blobTrigger_path_label", "Container Path" },
160+
{ "$blobTrigger_connection_label", "Storage Account Connection String" },
161+
{ "$eventGrid_name_label", "EventGrid Name" },
159162
};
160163
}
161164
}

src/Azure.Functions.Cli/StaticResources/NewTemplate-userPrompts.json

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,52 +90,55 @@
9090
}
9191
]
9292
},
93+
9394
{
9495
"id": "blobTrigger-connection",
9596
"name": "blobTrigger-connection",
9697
"value": "string",
97-
"label": "$blobTrigger_path_label",
98-
"help": "$blobTrigger_path_help"
98+
"resource": "Blob",
99+
"label": "$blobTrigger_connection_label",
100+
"help": "$blobTrigger_connection_help",
101+
"placeholder": "$variables_selectConnection"
99102
},
100103
{
101-
"id": "cosmosDBTrigger-connectionStringSetting",
102-
"name": "cosmosDBTrigger-connectionStringSetting",
104+
"id": "cosmosDBTrigger-connection",
105+
"name": "cosmosDBTrigger-connection",
103106
"value": "string",
104107
"resource": "DocumentDB",
105-
"label": "$cosmosDBIn_connection_label",
106-
"help": "$cosmosDBIn_connection_help",
108+
"label": "$cosmosDB_connection_label",
109+
"help": "$cosmosDB_connection_help",
107110
"placeholder": "$variables_selectConnection"
108111
},
109112
{
110113
"id": "cosmosDBTrigger-databaseName",
111114
"name": "cosmosDBTrigger-databaseName",
112115
"value": "string",
113116
"defaultValue": "",
114-
"label": "$cosmosDBIn_databaseName_label",
115-
"help": "$cosmosDBIn_databaseName_help"
117+
"label": "$cosmosDB_databaseName_label",
118+
"help": "$cosmosDB_databaseName_help"
116119
},
117120
{
118-
"id": "cosmosDBTrigger-collectionName",
119-
"name": "cosmosDBTrigger-collectionName",
121+
"id": "cosmosDBTrigger-containerName",
122+
"name": "cosmosDBTrigger-containerName",
120123
"value": "string",
121124
"defaultValue": "",
122-
"label": "$cosmosDBIn_collectionName_label",
123-
"help": "$cosmosDBIn_collectionName_help"
125+
"label": "$cosmosDB_containerName_label",
126+
"help": "$cosmosDB_containerName_help"
124127
},
125128
{
126-
"id": "cosmosDBTrigger-leaseCollectionName",
127-
"name": "cosmosDBTrigger-leaseCollectionName",
129+
"id": "cosmosDBTrigger-leaseContainerName",
130+
"name": "cosmosDBTrigger-leaseContainerName",
128131
"value": "string",
129-
"label": "$cosmosDBIn_leaseCollectionName_label",
130-
"help": "$cosmosDBIn_leaseCollectionName_help"
132+
"label": "$cosmosDB_leaseContainerName_label",
133+
"help": "$cosmosDB_leaseContainer_help"
131134
},
132135
{
133-
"id": "cosmosDBTrigger-createLeaseCollectionIfNotExists",
134-
"name": "cosmosDBTrigger-createLeaseCollectionIfNotExists",
136+
"id": "cosmosDBTrigger-createLeaseContainerIfNotExists",
137+
"name": "cosmosDBTrigger-createLeaseContainerIfNotExists",
135138
"value": "boolean",
136139
"defaultValue": true,
137-
"label": "$cosmosDBIn_createIfNotExists_label",
138-
"help": "$cosmosDBIn_createIfNotExists_help"
140+
"label": "$cosmosDB_createIfNotExists_label",
141+
"help": "$cosmosDB_createIfNotExists_help"
139142
},
140143
{
141144
"id": "eventHubTrigger-connection",
@@ -214,6 +217,20 @@
214217
],
215218
"validators": []
216219
},
220+
{
221+
"id": "eventGridTrigger-eventGridName",
222+
"name": "eventGridTrigger-eventGridName",
223+
"value": "string",
224+
"defaultValue": "myeventgrid",
225+
"label": "$eventGrid_name_label",
226+
"help": "$eventGrid_name_label_help",
227+
"validators": [
228+
{
229+
"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}[%]$",
230+
"errorText": "$eventGrid_name_label_errorText"
231+
}
232+
]
233+
},
217234
{
218235
"id": "serviceBusTrigger-connection",
219236
"name": "serviceBusTrigger-connection",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"id": "Microsoft.Azure.Functions.ExtensionBundle",
3-
"version": "[3.15.0, 4.0.0)"
3+
"version": "[4.*, 5.0.0)"
44
}

0 commit comments

Comments
 (0)