3333import com .microsoft .intellij .RunProcessHandler ;
3434import lombok .RequiredArgsConstructor ;
3535import org .apache .commons .collections4 .CollectionUtils ;
36+ import org .apache .commons .collections4 .MapUtils ;
3637import org .apache .commons .lang .StringUtils ;
3738import org .jetbrains .annotations .NotNull ;
3839import org .jetbrains .annotations .Nullable ;
4849import java .time .Duration ;
4950import java .util .List ;
5051import java .util .Map ;
52+ import java .util .Optional ;
5153import java .util .stream .Collectors ;
5254
5355import static com .microsoft .intellij .ui .messages .AzureBundle .message ;
@@ -64,6 +66,7 @@ public class FunctionDeploymentState extends AzureRunProfileState<IFunctionApp>
6466 "because they are non-anonymous. To access the non-anonymous triggers, please refer https://aka.ms/azure-functions-key." ;
6567 private static final String FAILED_TO_LIST_TRIGGERS = "Deployment succeeded, but failed to list http trigger urls." ;
6668 private static final String SYNCING_TRIGGERS_AND_FETCH_FUNCTION_INFORMATION = "Syncing triggers and fetching function information..." ;
69+ private static final String NO_TRIGGERS_FOUNDED = "No triggers found in deployed function app" ;
6770
6871 private final FunctionDeployConfiguration functionDeployConfiguration ;
6972 private final FunctionDeployModel deployModel ;
@@ -90,6 +93,7 @@ public IFunctionApp executeSteps(@NotNull RunProcessHandler processHandler, @Not
9093 } else {
9194 functionApp = Azure .az (AzureAppService .class ).subscription (functionDeployConfiguration .getSubscriptionId ())
9295 .functionApp (functionDeployConfiguration .getFunctionId ());
96+ updateApplicationSettings (functionApp );
9397 }
9498 stagingFolder = FunctionUtils .getTempStagingFolder ();
9599 prepareStagingFolder (stagingFolder , processHandler , operation );
@@ -122,6 +126,16 @@ private IFunctionApp createFunctionApp(@NotNull RunProcessHandler processHandler
122126 return functionApp ;
123127 }
124128
129+ private void updateApplicationSettings (IFunctionApp deployTarget ) {
130+ final Map <String , String > applicationSettings = FunctionUtils .loadAppSettingsFromSecurityStorage (functionDeployConfiguration .getAppSettingsKey ());
131+ if (MapUtils .isEmpty (applicationSettings )) {
132+ return ;
133+ }
134+ AzureMessager .getMessager ().info ("Updating application settings..." );
135+ deployTarget .update ().withAppSettings (applicationSettings ).commit ();
136+ AzureMessager .getMessager ().info ("Update application settings successfully." );
137+ }
138+
125139 @ AzureOperation (
126140 name = "function.prepare_staging_folder_detail" ,
127141 params = {"stagingFolder.getName()" , "this.deployModel.getAppName()" },
@@ -229,7 +243,9 @@ private List<FunctionEntity> listFunctions(final IFunctionApp functionApp) {
229243 AzureMessager .getMessager ().info (SYNCING_TRIGGERS_AND_FETCH_FUNCTION_INFORMATION );
230244 return Mono .fromCallable (() -> {
231245 functionApp .syncTriggers ();
232- return functionApp .listFunctions (true );
246+ return Optional .ofNullable (functionApp .listFunctions (true ))
247+ .filter (CollectionUtils ::isNotEmpty )
248+ .orElseThrow (() -> new AzureToolkitRuntimeException (NO_TRIGGERS_FOUNDED ));
233249 }).retryWhen (Retry .withThrowable (flux ->
234250 flux .zipWith (Flux .range (1 , LIST_TRIGGERS_MAX_RETRY + 1 ), (throwable , count ) -> {
235251 if (count < LIST_TRIGGERS_MAX_RETRY ) {
0 commit comments