Skip to content

Commit 830e880

Browse files
committed
Retry when get empty result while list functions
1 parent 7fc7cd8 commit 830e880

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/FunctionDeploymentState.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.time.Duration;
5050
import java.util.List;
5151
import java.util.Map;
52+
import java.util.Optional;
5253
import java.util.stream.Collectors;
5354

5455
import static com.microsoft.intellij.ui.messages.AzureBundle.message;
@@ -65,6 +66,7 @@ public class FunctionDeploymentState extends AzureRunProfileState<IFunctionApp>
6566
"because they are non-anonymous. To access the non-anonymous triggers, please refer https://aka.ms/azure-functions-key.";
6667
private static final String FAILED_TO_LIST_TRIGGERS = "Deployment succeeded, but failed to list http trigger urls.";
6768
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";
6870

6971
private final FunctionDeployConfiguration functionDeployConfiguration;
7072
private final FunctionDeployModel deployModel;
@@ -125,7 +127,7 @@ private IFunctionApp createFunctionApp(@NotNull RunProcessHandler processHandler
125127
}
126128

127129
private void updateApplicationSettings(IFunctionApp deployTarget) {
128-
final Map<String, String> applicationSettings = functionDeployConfiguration.getAppSettings();
130+
final Map<String, String> applicationSettings = FunctionUtils.loadAppSettingsFromSecurityStorage(functionDeployConfiguration.getAppSettingsKey());
129131
if (MapUtils.isEmpty(applicationSettings)) {
130132
return;
131133
}
@@ -241,7 +243,10 @@ private List<FunctionEntity> listFunctions(final IFunctionApp functionApp) {
241243
AzureMessager.getMessager().info(SYNCING_TRIGGERS_AND_FETCH_FUNCTION_INFORMATION);
242244
return Mono.fromCallable(() -> {
243245
functionApp.syncTriggers();
244-
return functionApp.listFunctions(true);
246+
final List<FunctionEntity> entities = functionApp.listFunctions(true);
247+
return Optional.ofNullable(functionApp.listFunctions(true))
248+
.filter(CollectionUtils::isNotEmpty)
249+
.orElseThrow(() -> new AzureToolkitRuntimeException(NO_TRIGGERS_FOUNDED));
245250
}).retryWhen(Retry.withThrowable(flux ->
246251
flux.zipWith(Flux.range(1, LIST_TRIGGERS_MAX_RETRY + 1), (throwable, count) -> {
247252
if (count < LIST_TRIGGERS_MAX_RETRY) {

0 commit comments

Comments
 (0)