66package com .microsoft .azure .toolkit .intellij .function .runner .library .function ;
77
88import com .google .common .base .Preconditions ;
9+ import com .microsoft .azure .management .applicationinsights .v2015_05_01 .ApplicationInsightsComponent ;
10+ import com .microsoft .azure .management .appservice .FunctionApp ;
11+ import com .microsoft .azure .management .appservice .FunctionApp .DefinitionStages .WithCreate ;
12+ import com .microsoft .azure .management .appservice .PricingTier ;
913import com .microsoft .azure .management .resources .fluentcore .arm .Region ;
14+ import com .microsoft .azure .toolkit .intellij .function .runner .deploy .FunctionDeployModel ;
15+ import com .microsoft .azure .toolkit .lib .common .exception .AzureExecutionException ;
16+ import com .microsoft .azure .toolkit .lib .common .exception .AzureToolkitRuntimeException ;
1017import com .microsoft .azure .toolkit .lib .common .messager .AzureMessager ;
18+ import com .microsoft .azure .toolkit .lib .common .messager .IAzureMessager ;
19+ import com .microsoft .azure .toolkit .lib .common .operation .AzureOperation ;
20+ import com .microsoft .azure .toolkit .lib .legacy .appservice .AppServiceUtils ;
1121import com .microsoft .azure .toolkit .lib .legacy .appservice .OperatingSystemEnum ;
12- import com .microsoft .azure .toolkit .lib .common .exception .AzureExecutionException ;
1322import com .microsoft .azure .toolkit .lib .legacy .function .configurations .ElasticPremiumPricingTier ;
1423import com .microsoft .azure .toolkit .lib .legacy .function .configurations .FunctionExtensionVersion ;
1524import com .microsoft .azure .toolkit .lib .legacy .function .configurations .RuntimeConfiguration ;
1625import com .microsoft .azure .toolkit .lib .legacy .function .handlers .runtime .FunctionRuntimeHandler ;
1726import com .microsoft .azure .toolkit .lib .legacy .function .handlers .runtime .LinuxFunctionRuntimeHandler ;
1827import com .microsoft .azure .toolkit .lib .legacy .function .handlers .runtime .WindowsFunctionRuntimeHandler ;
1928import com .microsoft .azure .toolkit .lib .legacy .function .utils .FunctionUtils ;
20- import com .microsoft .azure .toolkit .lib .legacy .appservice .AppServiceUtils ;
21- import com .microsoft .azure .management .applicationinsights .v2015_05_01 .ApplicationInsightsComponent ;
22- import com .microsoft .azure .management .appservice .FunctionApp ;
23- import com .microsoft .azure .management .appservice .FunctionApp .DefinitionStages .WithCreate ;
24- import com .microsoft .azure .management .appservice .PricingTier ;
25- import com .microsoft .azure .toolkit .lib .common .exception .AzureToolkitRuntimeException ;
26- import com .microsoft .azure .toolkit .lib .common .operation .AzureOperation ;
27- import com .microsoft .azure .toolkit .intellij .function .runner .deploy .FunctionDeployModel ;
2829import com .microsoft .azuretools .telemetrywrapper .Operation ;
2930import com .microsoft .tooling .msservices .helpers .azure .sdk .AzureSDKManager ;
3031import org .apache .commons .lang3 .StringUtils ;
@@ -50,11 +51,13 @@ public class CreateFunctionHandler {
5051
5152 private final FunctionDeployModel ctx ;
5253 private final Operation operation ;
54+ private final IAzureMessager messenger ;
5355
5456 public CreateFunctionHandler (FunctionDeployModel ctx , Operation operation ) {
5557 Preconditions .checkNotNull (ctx );
5658 this .ctx = ctx ;
5759 this .operation = operation ;
60+ this .messenger = AzureMessager .getMessager ();
5861 }
5962
6063 public FunctionApp execute () {
@@ -77,7 +80,7 @@ public FunctionApp execute() {
7780 type = AzureOperation .Type .SERVICE
7881 )
7982 private FunctionApp createFunctionApp () {
80- AzureMessager . getMessager () .info (message ("function.create.hint.startCreateFunction" ));
83+ messenger .info (message ("function.create.hint.startCreateFunction" ));
8184 final WithCreate withCreate ;
8285 try {
8386 final FunctionRuntimeHandler runtimeHandler = getFunctionRuntimeHandler ();
@@ -95,7 +98,7 @@ private FunctionApp createFunctionApp() {
9598
9699 final FunctionApp result = withCreate .create ();
97100 operation .trackProperty ("pricingTier" , ctx .getPricingTier ());
98- AzureMessager . getMessager () .info (message ("function.create.hint.functionCreated" , ctx .getAppName ()));
101+ messenger .info (message ("function.create.hint.functionCreated" , ctx .getAppName ()));
99102 return result ;
100103 }
101104
@@ -129,7 +132,7 @@ private Map<String, String> bindingApplicationInsights() {
129132 instrumentationKey = insights .instrumentationKey ();
130133 } catch (final IOException | RuntimeException e ) {
131134 // swallow exception for application insights, which should not block function creation
132- AzureMessager . getMessager () .warning (message ("function.create.error.createApplicationInsightsFailed" , ctx .getAppName ()));
135+ messenger .warning (message ("function.create.error.createApplicationInsightsFailed" , ctx .getAppName ()));
133136 }
134137 }
135138 return Collections .singletonMap (APP_INSIGHTS_INSTRUMENTATION_KEY , instrumentationKey );
@@ -175,7 +178,7 @@ private void setDefaultAppSetting(Map result, String settingName, String setting
175178
176179 final String setting = (String ) result .get (settingName );
177180 if (StringUtils .isEmpty (setting )) {
178- AzureMessager . getMessager () .info (settingIsEmptyMessage );
181+ messenger .info (settingIsEmptyMessage );
179182 result .put (settingName , settingValue );
180183 }
181184 }
@@ -185,9 +188,9 @@ private void overrideDefaultAppSetting(Map result, String settingName, String se
185188
186189 final String setting = (String ) result .get (settingName );
187190 if (StringUtils .isEmpty (setting )) {
188- AzureMessager . getMessager () .info (settingIsEmptyMessage );
191+ messenger .info (settingIsEmptyMessage );
189192 } else if (!setting .equals (settingValue )) {
190- AzureMessager . getMessager () .warning (String .format (changeSettingMessage , setting ));
193+ messenger .warning (String .format (changeSettingMessage , setting ));
191194 }
192195 result .put (settingName , settingValue );
193196 }
0 commit comments