Skip to content

Commit 02369e9

Browse files
Merge branch 'endgame-june' into endgame-june.next
2 parents ee8399e + 8d9145b commit 02369e9

File tree

14 files changed

+63
-14
lines changed

14 files changed

+63
-14
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/AppServiceComboBox.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import com.intellij.ui.SimpleListCellRenderer;
1111
import com.intellij.ui.components.fields.ExtendableTextComponent;
1212
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
13+
import com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion;
14+
import com.microsoft.azure.toolkit.lib.appservice.model.Runtime;
15+
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
1316
import com.microsoft.azure.toolkit.lib.webapp.WebAppService;
1417
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
1518
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
@@ -19,6 +22,7 @@
1922
import javax.swing.*;
2023
import java.util.List;
2124
import java.util.Objects;
25+
import java.util.Optional;
2226

2327
public abstract class AppServiceComboBox<T extends AppServiceComboBoxModel> extends AzureComboBox<T> {
2428

@@ -71,6 +75,17 @@ protected String getItemText(final Object item) {
7175
}
7276
}
7377

78+
protected boolean isJavaAppService(IAppService appService) {
79+
try {
80+
return Optional.ofNullable(appService.getRuntime()).map(Runtime::getJavaVersion)
81+
.map(javaVersion -> !Objects.equals(javaVersion, JavaVersion.OFF))
82+
.orElse(false);
83+
} catch (final RuntimeException e) {
84+
// app service may have been removed while parsing, return false in this case
85+
return false;
86+
}
87+
}
88+
7489
protected abstract void createResource();
7590

7691
public static class AppComboBoxRender extends SimpleListCellRenderer {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/serviceplan/ServicePlanComboBox.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public void setSubscription(Subscription subscription) {
5555
this.clear();
5656
return;
5757
}
58+
// force refresh service plan when switch subscription
59+
Azure.az(AzureAppService.class).subscription(subscription.getId()).appServicePlans(true);
5860
this.refreshItems();
5961
}
6062

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/FunctionAppComboBox.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.microsoft.azure.toolkit.intellij.appservice.AppServiceComboBox;
1010
import com.microsoft.azure.toolkit.lib.Azure;
1111
import com.microsoft.azure.toolkit.lib.appservice.AzureAppService;
12-
import com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion;
1312
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
1413
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
1514
import com.microsoft.tooling.msservices.components.DefaultLoader;
@@ -44,7 +43,7 @@ protected void createResource() {
4443
)
4544
protected List<FunctionAppComboBoxModel> loadAppServiceModels() {
4645
return Azure.az(AzureAppService.class).functionApps().parallelStream()
47-
.filter(functionApp -> functionApp.getRuntime().getJavaVersion() != JavaVersion.OFF)
46+
.filter(this::isJavaAppService)
4847
.map(FunctionAppComboBoxModel::new)
4948
.sorted((app1, app2) -> app1.getAppName().compareToIgnoreCase(app2.getAppName()))
5049
.collect(Collectors.toList());

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.microsoft.intellij.RunProcessHandler;
3434
import lombok.RequiredArgsConstructor;
3535
import org.apache.commons.collections4.CollectionUtils;
36+
import org.apache.commons.collections4.MapUtils;
3637
import org.apache.commons.lang.StringUtils;
3738
import org.jetbrains.annotations.NotNull;
3839
import org.jetbrains.annotations.Nullable;
@@ -48,6 +49,7 @@
4849
import java.time.Duration;
4950
import java.util.List;
5051
import java.util.Map;
52+
import java.util.Optional;
5153
import java.util.stream.Collectors;
5254

5355
import 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) {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/mysql/MySQLPropertyView.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
8181
</constraints>
8282
<properties>
83-
<text value="Choose a database for your conneciton strings:"/>
83+
<text value="Choose a database for your connection strings:"/>
8484
</properties>
8585
</component>
8686
<hspacer id="4b8df">

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/mysql/MySQLRegionValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class MySQLRegionValidator implements Function<RegionComboBox, AzureValid
2020
public AzureValidationInfo apply(RegionComboBox comboBox) {
2121

2222
try {
23-
if (Azure.az(AzureMySql.class).checkRegionAvailability(comboBox.getValue())) {
23+
if (Azure.az(AzureMySql.class).subscription(comboBox.getSubscription().getId()).checkRegionAvailability(comboBox.getValue())) {
2424
return AzureValidationInfo.OK;
2525
}
2626
final AzureValidationInfo.AzureValidationInfoBuilder builder = AzureValidationInfo.builder();

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/sqlserver/properties/SqlServerPropertyView.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
8181
</constraints>
8282
<properties>
83-
<text value="Choose a database for your conneciton strings:"/>
83+
<text value="Choose a database for your connection strings:"/>
8484
</properties>
8585
</component>
8686
<hspacer id="4b8df">

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/WebAppComboBox.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ protected void createResource() {
4949
)
5050
protected List<WebAppComboBoxModel> loadAppServiceModels() {
5151
final List<IWebApp> webApps = Azure.az(AzureAppService.class).webapps(false);
52-
return webApps.stream()
53-
.filter(webApp -> webApp.getRuntime().getJavaVersion() != null && webApp.getRuntime().getJavaVersion() != JavaVersion.OFF)
54-
.sorted((a, b) -> a.name().compareToIgnoreCase(b.name()))
55-
.map(WebAppComboBoxModel::new)
56-
.collect(Collectors.toList());
52+
return webApps.stream().parallel()
53+
.filter(this::isJavaAppService)
54+
.sorted((a, b) -> a.name().compareToIgnoreCase(b.name()))
55+
.map(WebAppComboBoxModel::new)
56+
.collect(Collectors.toList());
5757
}
5858
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/function/FunctionAppNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public FunctionAppNode(@Nonnull AzureRefreshableNode parent, @Nonnull IFunctionA
4444

4545
@Override
4646
protected void refreshItems() {
47+
super.refreshItems();
4748
this.renderSubModules();
4849
}
4950

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/function/FunctionModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void removeNode(String sid, String id, Node node) {
4545
@AzureOperation(name = "function.reload_all", type = AzureOperation.Type.ACTION)
4646
protected void refreshItems() {
4747
Azure.az(AzureAppService.class).functionApps(true)
48-
.stream().map(functionApp -> new FunctionAppNode(FunctionModule.this, functionApp))
48+
.stream().parallel().map(functionApp -> new FunctionAppNode(FunctionModule.this, functionApp))
4949
.forEach(this::addChildNode);
5050
}
5151

0 commit comments

Comments
 (0)