Skip to content

Commit 222a460

Browse files
Merge pull request #6977 from microsoft/endgame-202209
Merge endgame 202209 -> endgame next
2 parents 17af46c + 15566dc commit 222a460

File tree

15 files changed

+174
-104
lines changed

15 files changed

+174
-104
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceStreamingLogManager.java

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import com.microsoft.azure.toolkit.lib.Azure;
1414
import com.microsoft.azure.toolkit.lib.applicationinsights.ApplicationInsight;
1515
import com.microsoft.azure.toolkit.lib.applicationinsights.AzureApplicationInsights;
16-
import com.microsoft.azure.toolkit.lib.appservice.function.AzureFunctions;
17-
import com.microsoft.azure.toolkit.lib.appservice.function.FunctionApp;
16+
import com.microsoft.azure.toolkit.lib.appservice.function.FunctionAppBase;
17+
import com.microsoft.azure.toolkit.lib.appservice.function.FunctionAppDeploymentSlotDraft;
1818
import com.microsoft.azure.toolkit.lib.appservice.function.FunctionAppDraft;
1919
import com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig;
2020
import com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem;
@@ -33,6 +33,7 @@
3333
import com.microsoft.azure.toolkit.lib.common.operation.OperationBundle;
3434
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
3535
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
36+
import lombok.Getter;
3637
import org.apache.commons.lang3.StringUtils;
3738
import reactor.core.publisher.Flux;
3839

@@ -70,8 +71,12 @@ public void showWebAppStreamingLog(Project project, String webAppId) {
7071
showAppServiceStreamingLog(project, webAppId, new WebAppLogStreaming(webAppId));
7172
}
7273

73-
public void showFunctionStreamingLog(Project project, String functionId) {
74-
showAppServiceStreamingLog(project, functionId, new FunctionLogStreaming(functionId));
74+
public void showFunctionStreamingLog(Project project, FunctionAppBase<?,?,?> app) {
75+
showAppServiceStreamingLog(project, app.getId(), new FunctionLogStreaming(app));
76+
}
77+
78+
public void showFunctionDeploymentSlotStreamingLog(Project project, FunctionAppBase<?,?,?> app) {
79+
showAppServiceStreamingLog(project, app.getId(), new FunctionDeploymentSlotLogStreaming(app));
7580
}
7681

7782
@AzureOperation(name = "appservice.close_log_stream.app", params = {"nameFromResourceId(appId)"}, type = AzureOperation.Type.SERVICE)
@@ -95,11 +100,6 @@ private void showAppServiceStreamingLog(Project project, String resourceId, ILog
95100
final String name = logStreaming.getTitle();
96101
final AppServiceStreamingLogConsoleView consoleView = getOrCreateConsoleView(project, resourceId);
97102
if (!consoleView.isActive()) {
98-
if (!logStreaming.isLogStreamingSupported()) {
99-
AzureTaskManager.getInstance().runLater(() -> AzureMessager.getMessager()
100-
.error(message("appService.logStreaming.hint.notSupport", name), NOT_SUPPORTED));
101-
return;
102-
}
103103
if (!logStreaming.isLogStreamingEnabled()) {
104104
// Enable Log Streaming if log streaming of target is not enabled
105105
final boolean userInput = AzureMessager.getMessager()
@@ -130,10 +130,6 @@ private AppServiceStreamingLogConsoleView getOrCreateConsoleView(Project project
130130
}
131131

132132
interface ILogStreaming {
133-
default boolean isLogStreamingSupported() {
134-
return true;
135-
}
136-
137133
boolean isLogStreamingEnabled();
138134

139135
void enableLogStreaming();
@@ -144,16 +140,17 @@ default boolean isLogStreamingSupported() {
144140
Flux<String> getStreamingLogContent();
145141
}
146142

147-
static class FunctionLogStreaming implements ILogStreaming {
143+
static abstract class AbstractFunctionLogStreaming implements ILogStreaming {
148144

149145
private static final String APPINSIGHTS_INSTRUMENTATIONKEY = "APPINSIGHTS_INSTRUMENTATIONKEY";
150146
private static final String APPLICATION_INSIGHT_PATTERN = "%s/#blade/AppInsightsExtension/QuickPulseBladeV2/ComponentId/%s/ResourceId/%s";
151147
private static final String MUST_CONFIGURE_APPLICATION_INSIGHTS = message("appService.logStreaming.error.noApplicationInsights");
152148

153-
private final FunctionApp functionApp;
149+
@Getter
150+
protected final FunctionAppBase<?, ?, ?> functionApp;
154151

155-
FunctionLogStreaming(final String resourceId) {
156-
this.functionApp = Azure.az(AzureFunctions.class).functionApp(resourceId);
152+
AbstractFunctionLogStreaming(final FunctionAppBase<?,?,?> functionApp) {
153+
this.functionApp = functionApp;
157154
}
158155

159156
@Override
@@ -164,15 +161,6 @@ public boolean isLogStreamingEnabled() {
164161
return operatingSystem == OperatingSystem.LINUX || isEnableApplicationLog;
165162
}
166163

167-
@Override
168-
public void enableLogStreaming() {
169-
final DiagnosticConfig diagnosticConfig = Optional.ofNullable(functionApp.getDiagnosticConfig()).orElseGet(DiagnosticConfig::new);
170-
diagnosticConfig.setEnableApplicationLog(true);
171-
final FunctionAppDraft draft = (FunctionAppDraft) functionApp.update();
172-
draft.setDiagnosticConfig(diagnosticConfig);
173-
draft.commit();
174-
}
175-
176164
@Override
177165
public String getTitle() {
178166
return functionApp.getName();
@@ -218,6 +206,38 @@ private String getApplicationInsightLiveMetricsUrl(ApplicationInsight target, St
218206
}
219207
}
220208

209+
static class FunctionLogStreaming extends AbstractFunctionLogStreaming {
210+
211+
FunctionLogStreaming(FunctionAppBase<?, ?, ?> functionApp) {
212+
super(functionApp);
213+
}
214+
215+
@Override
216+
public void enableLogStreaming() {
217+
final DiagnosticConfig diagnosticConfig = Optional.ofNullable(getFunctionApp().getDiagnosticConfig()).orElseGet(DiagnosticConfig::new);
218+
diagnosticConfig.setEnableApplicationLog(true);
219+
final FunctionAppDraft draft = (FunctionAppDraft) getFunctionApp().update();
220+
draft.setDiagnosticConfig(diagnosticConfig);
221+
draft.commit();
222+
}
223+
}
224+
225+
static class FunctionDeploymentSlotLogStreaming extends AbstractFunctionLogStreaming {
226+
227+
FunctionDeploymentSlotLogStreaming(FunctionAppBase<?,?,?> functionApp) {
228+
super(functionApp);
229+
}
230+
231+
@Override
232+
public void enableLogStreaming() {
233+
final DiagnosticConfig diagnosticConfig = Optional.ofNullable(getFunctionApp().getDiagnosticConfig()).orElseGet(DiagnosticConfig::new);
234+
diagnosticConfig.setEnableApplicationLog(true);
235+
final FunctionAppDeploymentSlotDraft draft = (FunctionAppDeploymentSlotDraft) getFunctionApp().update();
236+
draft.setDiagnosticConfig(diagnosticConfig);
237+
draft.commit();
238+
}
239+
}
240+
221241
static class WebAppLogStreaming implements ILogStreaming {
222242
private final WebApp webApp;
223243

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/appservice/action/StartStreamingLogsAction.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.microsoft.azure.toolkit.intellij.legacy.appservice.AppServiceStreamingLogManager;
1010
import com.microsoft.azure.toolkit.lib.appservice.AppServiceAppBase;
1111
import com.microsoft.azure.toolkit.lib.appservice.function.FunctionApp;
12+
import com.microsoft.azure.toolkit.lib.appservice.function.FunctionAppDeploymentSlot;
1213
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebApp;
1314
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebAppDeploymentSlot;
1415
import com.microsoft.azure.toolkit.lib.common.bundle.AzureString;
@@ -40,7 +41,9 @@ public void execute() {
4041
} else if (appService instanceof WebAppDeploymentSlot) {
4142
AppServiceStreamingLogManager.INSTANCE.showWebAppDeploymentSlotStreamingLog(project, resourceId);
4243
} else if (appService instanceof FunctionApp) {
43-
AppServiceStreamingLogManager.INSTANCE.showFunctionStreamingLog(project, resourceId);
44+
AppServiceStreamingLogManager.INSTANCE.showFunctionStreamingLog(project, (FunctionApp) appService);
45+
} else if (appService instanceof FunctionAppDeploymentSlot) {
46+
AppServiceStreamingLogManager.INSTANCE.showFunctionDeploymentSlotStreamingLog(project, (FunctionAppDeploymentSlot) appService);
4447
} else {
4548
AzureMessager.getMessager().error("Unsupported operation", "Unsupported operation");
4649
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingEditor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@
1111
import com.microsoft.azure.toolkit.intellij.legacy.common.AzureSettingsEditor;
1212
import com.microsoft.azure.toolkit.intellij.legacy.function.runner.deploy.ui.FunctionDeploymentPanel;
1313
import com.microsoft.azure.toolkit.lib.common.form.AzureValidationInfo;
14+
import com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer;
1415
import org.jetbrains.annotations.NotNull;
16+
import reactor.core.scheduler.Schedulers;
1517

1618
import java.util.Objects;
19+
import java.util.Optional;
1720

1821
public class FunctionDeploymentSettingEditor extends AzureSettingsEditor<FunctionDeployConfiguration> {
1922

2023
private final FunctionDeploymentPanel mainPanel;
2124
private final FunctionDeployConfiguration functionDeployConfiguration;
2225

26+
private final TailingDebouncer debouncer = new TailingDebouncer(this::updateValidationInfo, 1000);
27+
2328
public FunctionDeploymentSettingEditor(Project project, @NotNull FunctionDeployConfiguration functionDeployConfiguration) {
2429
super(project);
2530
this.mainPanel = new FunctionDeploymentPanel(project, functionDeployConfiguration);
@@ -33,11 +38,22 @@ protected void applyEditorTo(@NotNull FunctionDeployConfiguration conf) throws C
3338
.filter(i -> !i.isValid())
3439
.findAny().orElse(null);
3540
if (Objects.nonNull(error)) {
41+
this.debouncer.debounce();
3642
final String message = error.getType() == AzureValidationInfo.Type.PENDING ? "Validating..." : error.getMessage();
3743
throw new ConfigurationException(message);
3844
}
3945
}
4046

47+
private void updateValidationInfo() {
48+
this.mainPanel.validateAllInputsAsync()
49+
.subscribeOn(Schedulers.boundedElastic())
50+
.subscribe(info -> {
51+
if (info.isValid()) {
52+
this.fireEditorStateChanged();
53+
}
54+
});
55+
}
56+
4157
@Override
4258
@NotNull
4359
protected AzureSettingPanel<FunctionDeployConfiguration> getPanel() {

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/ui/FunctionDeploymentPanel.form

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="27dc6" binding="pnlRoot" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="0" left="0" bottom="0" right="0"/>
55
<constraints>
6-
<xy x="20" y="20" width="604" height="220"/>
6+
<xy x="20" y="20" width="604" height="133"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
@@ -53,18 +53,6 @@
5353
<text value="Module: "/>
5454
</properties>
5555
</component>
56-
<component id="56e9e" class="javax.swing.JLabel" binding="lblDeploymentSlot">
57-
<constraints>
58-
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
59-
<minimum-size width="-1" height="24"/>
60-
<preferred-size width="-1" height="24"/>
61-
<maximum-size width="-1" height="24"/>
62-
</grid>
63-
</constraints>
64-
<properties>
65-
<text value="Deployment Slot:"/>
66-
</properties>
67-
</component>
6856
<component id="760ca" class="com.microsoft.azure.toolkit.intellij.legacy.function.FunctionAppComboBox" binding="functionAppComboBox" custom-create="true">
6957
<constraints>
7058
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
@@ -73,29 +61,29 @@
7361
</component>
7462
<component id="35551" class="com.microsoft.azure.toolkit.intellij.legacy.function.runner.deploy.ui.components.DeploymentSlotComboBox" binding="cbDeploymentSlot" custom-create="true">
7563
<constraints>
76-
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
64+
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
7765
</constraints>
7866
<properties>
7967
<visible value="true"/>
8068
</properties>
8169
</component>
70+
<component id="2bbdf" class="javax.swing.JComboBox" binding="cbFunctionModule">
71+
<constraints>
72+
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
73+
</constraints>
74+
<properties/>
75+
</component>
8276
<component id="60952" class="javax.swing.JCheckBox" binding="chkSlot">
8377
<constraints>
84-
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
78+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
8579
</constraints>
8680
<properties>
8781
<contentAreaFilled value="true"/>
8882
<hideActionText value="false"/>
8983
<horizontalTextPosition value="4"/>
90-
<text value="Deploy To Slot"/>
84+
<text value="Deploy to Slot:"/>
9185
</properties>
9286
</component>
93-
<component id="2bbdf" class="javax.swing.JComboBox" binding="cbFunctionModule">
94-
<constraints>
95-
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
96-
</constraints>
97-
<properties/>
98-
</component>
9987
</children>
10088
</grid>
10189
</form>

0 commit comments

Comments
 (0)