Skip to content

Commit b5a0f21

Browse files
authored
Merge pull request #4988 from microsoft/release-3.50.0
prepare releasing v3.50.0 [release-3.50.0 -> release]
2 parents 797e03a + 56778e5 commit b5a0f21

File tree

10 files changed

+65
-22
lines changed

10 files changed

+65
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ All notable changes to "Azure Toolkit for IntelliJ IDEA" will be documented in t
6868
## 3.50.0
6969

7070
### Added
71-
- Azure MySQL resource connector feature
71+
- Development workflow for Azure Database for MySQL
72+
- Connect Azure Database for MySQL Server to local project from Azure Explorer or application.properties file
73+
- Automatically inject datasource connection properties into runtime environment for local run
74+
- Publish Azure Web App with datasource connection properties in application settings
7275

7376
## 3.49.0
7477

PluginsAndFeatures/azure-toolkit-for-intellij/resources/META-INF/plugin.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
<h3>3.50.0</h3>
2828
<h4>Added</h4>
2929
<ul>
30-
<li>Add Azure MySQL resource connector</li>
30+
<li>Development workflow for Azure Database for MySQL
31+
<ul>
32+
<li>Connect Azure Database for MySQL Server to local project from Azure Explorer or application.properties file</li>
33+
<li>Automatically inject datasource connection properties into runtime environment for local run</li>
34+
<li>Publish Azure Web App with datasource connection properties in application settings</li>
35+
</ul>
36+
</li>
3137
</ul>
3238
<p>You may get the full change log <a
3339
href="https://github.com/Microsoft/azure-tools-for-java/blob/develop/CHANGELOG.md">here</a></p>

PluginsAndFeatures/azure-toolkit-for-intellij/resources/whatsnew/whatsnew.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
## 3.50.0
55

66
### Added
7-
- Azure MySQL resource connector
7+
<img src="https://user-images.githubusercontent.com/19339116/109937625-11666400-7d0a-11eb-9850-82a62d65f3fa.gif" width="840" height="525" />
8+
9+
- Development workflow for Azure Database for MySQL
10+
- Connect Azure Database for MySQL Server to local project from Azure Explorer or application.properties file
11+
- Automatically inject datasource connection properties into runtime environment for local run
12+
- Publish Azure Web App with datasource connection properties in application settings
813

914
## 3.49.0
1015

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void setWebServerLogVisible(boolean visible) {
9292
public MonitorConfig getData() {
9393
MonitorConfig config = MonitorConfig.builder().build();
9494
final ApplicationInsightsConfig insightsConfig =
95-
(rdoEnableApplicationInsights.isSelected() && titleAppServiceLog.isVisible()) ? applicationInsightsComboBox.getValue() : null;
95+
(rdoEnableApplicationInsights.isSelected() && titleApplicationInsights.isVisible()) ? applicationInsightsComboBox.getValue() : null;
9696
config.setApplicationInsightsConfig(insightsConfig);
9797
config.setEnableWebServerLogging(rdoEnableWebServerLog.isSelected() && lblWebServerLog.isVisible());
9898
config.setWebServerLogQuota(txtQuota.getValue());

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/link/LinkMySQLToModuleDialog.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,27 @@
1111
import com.intellij.openapi.project.Project;
1212
import com.microsoft.azure.toolkit.intellij.common.AzureDialog;
1313
import com.microsoft.azure.toolkit.intellij.link.mysql.BasicLinkMySQLPanel;
14+
import com.microsoft.azure.toolkit.intellij.link.mysql.JdbcUrl;
1415
import com.microsoft.azure.toolkit.intellij.link.mysql.MySQLResourceConfig;
16+
import com.microsoft.azure.toolkit.intellij.link.po.MySQLResourcePO;
1517
import com.microsoft.azure.toolkit.lib.common.form.AzureForm;
1618
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
1719
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1820
import com.microsoft.azure.toolkit.lib.link.AzureLinkService;
21+
import com.microsoft.intellij.AzureMySQLStorage;
1922
import com.microsoft.tooling.msservices.components.DefaultLoader;
2023
import com.microsoft.tooling.msservices.serviceexplorer.azure.mysql.MySQLNode;
2124
import org.apache.commons.lang3.StringUtils;
2225
import org.jetbrains.annotations.Nullable;
2326

2427
import javax.swing.*;
28+
import java.util.Objects;
2529

2630
public class LinkMySQLToModuleDialog extends AzureDialog<LinkConfig<MySQLResourceConfig, ModuleResourceConfig>> {
31+
32+
private static final String PROMPT_TITLE = "Azure Explorer";
33+
private static final String[] PROMPT_OPTIONS = new String[] {"Yes", "No"};
34+
private static final String PROMPT_MESSAGE = "This resource already existed in your local environment. Do you want to override it?";
2735
private JPanel rootPanel;
2836
private BasicLinkMySQLPanel basicPanel;
2937

@@ -71,12 +79,27 @@ private void createUIComponents() {
7179

7280
private void doLink(LinkConfig<MySQLResourceConfig, ModuleResourceConfig> linkConfig, Project project, LinkMySQLToModuleDialog dialog) {
7381
dialog.close(0);
82+
// check to prompt override existing resource or not
83+
MySQLResourceConfig resourceConfig = linkConfig.getResource();
84+
JdbcUrl jdbcUrl = JdbcUrl.from(resourceConfig.getUrl());
85+
String businessUniqueKey = MySQLResourcePO.getBusinessUniqueKey(resourceConfig.getServer().id(), jdbcUrl.getDatabase());
86+
MySQLResourcePO existedResourcePO = AzureMySQLStorage.getStorage().getResourceByBusinessUniqueKey(businessUniqueKey);
87+
boolean storageResource = true;
88+
if (Objects.nonNull(existedResourcePO)) {
89+
if (!StringUtils.equals(resourceConfig.getUrl(), existedResourcePO.getUrl()) ||
90+
!StringUtils.equals(resourceConfig.getUsername(), existedResourcePO.getUsername()) ||
91+
resourceConfig.getPasswordConfig().getPasswordSaveType() != existedResourcePO.getPasswordSave()) {
92+
storageResource = DefaultLoader.getUIHelper().showConfirmation(PROMPT_MESSAGE, PROMPT_TITLE, PROMPT_OPTIONS, null);
93+
}
94+
}
95+
// link in background
96+
boolean finalStorageResource = storageResource;
7497
final Runnable runnable = () -> {
7598
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
7699
indicator.setIndeterminate(true);
77-
AzureLinkService.getInstance().link(project, linkConfig);
100+
AzureLinkService.getInstance().link(project, linkConfig, finalStorageResource);
78101
};
79-
String progressMessage = "Linking Azure Database for MySQL with Module...";
102+
String progressMessage = "Connecting Azure Database for MySQL with Module...";
80103
final AzureTask task = new AzureTask(null, progressMessage, false, runnable);
81104
AzureTaskManager.getInstance().runInBackground(task);
82105
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/streaminglog/SpringCloudStreamingLogConsoleView.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.intellij.execution.ui.ConsoleViewContentType;
1010
import com.intellij.openapi.project.Project;
1111
import com.microsoft.applicationinsights.internal.util.ThreadPoolUtils;
12-
import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils;
1312
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle;
1413
import com.microsoft.azure.toolkit.lib.common.operation.IAzureOperationTitle;
1514
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
@@ -31,13 +30,13 @@ public class SpringCloudStreamingLogConsoleView extends ConsoleViewImpl {
3130
private ConsoleViewStatus status;
3231
private ExecutorService executorService;
3332

34-
private String resourceId;
33+
private final String resourceName;
3534
private InputStream logInputStream;
3635

37-
public SpringCloudStreamingLogConsoleView(@NotNull Project project, String resourceId) {
36+
public SpringCloudStreamingLogConsoleView(@NotNull Project project, String resourceName) {
3837
super(project, true);
3938
this.status = ConsoleViewStatus.STOPPED;
40-
this.resourceId = resourceId;
39+
this.resourceName = resourceName;
4140
}
4241

4342
public ConsoleViewStatus getStatus() {
@@ -95,7 +94,7 @@ public void shutdown() {
9594
}
9695
setStatus(ConsoleViewStatus.STOPPING);
9796
}
98-
final IAzureOperationTitle title = AzureOperationBundle.title("springcloud|log_stream.close", ResourceUtils.nameFromResourceId(resourceId));
97+
final IAzureOperationTitle title = AzureOperationBundle.title("springcloud|log_stream.close", resourceName);
9998
AzureTaskManager.getInstance().runInBackground(new AzureTask(getProject(), title, false, () -> {
10099
try {
101100
if (logInputStream != null) {
@@ -118,6 +117,6 @@ public void shutdown() {
118117
public void dispose() {
119118
super.dispose();
120119
shutdown();
121-
SpringCloudStreamingLogManager.getInstance().removeConsoleView(resourceId);
120+
SpringCloudStreamingLogManager.getInstance().removeConsoleView(resourceName);
122121
}
123122
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/link/AzureLinkService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.microsoft.azure.toolkit.intellij.link.po.MySQLResourcePO;
1919
import com.microsoft.intellij.AzureLinkStorage;
2020
import com.microsoft.intellij.AzureMySQLStorage;
21+
import org.apache.commons.codec.digest.DigestUtils;
2122
import org.apache.commons.collections4.CollectionUtils;
2223
import org.apache.commons.lang3.ArrayUtils;
2324
import org.apache.commons.lang3.StringUtils;
@@ -37,14 +38,16 @@ private AzureLinkService() {
3738

3839
}
3940

40-
public void link(Project project, LinkConfig<MySQLResourceConfig, ModuleResourceConfig> linkComposite) {
41+
public void link(Project project, LinkConfig<MySQLResourceConfig, ModuleResourceConfig> linkComposite, boolean storageResource) {
4142
ModulePO modulePO = createModulePO(linkComposite.getModule());
4243
// create resource
4344
MySQLResourcePO resource = createResourcePO(linkComposite.getResource());
4445
// create link
4546
LinkPO linkPO = new LinkPO(resource.getId(), modulePO.getResourceId(), LinkType.SERVICE_WITH_MODULE, linkComposite.getEnvPrefix());
4647
// storage mysql
47-
AzureMySQLStorage.getStorage().addResource(resource);
48+
if (storageResource) {
49+
AzureMySQLStorage.getStorage().addResource(resource);
50+
}
4851
// storage password
4952
if (ArrayUtils.isNotEmpty(linkComposite.getResource().getPasswordConfig().getPassword())) {
5053
String inputPassword = String.valueOf(linkComposite.getResource().getPasswordConfig().getPassword());
@@ -62,7 +65,7 @@ private MySQLResourcePO createResourcePO(MySQLResourceConfig config) {
6265
JdbcUrl jdbcUrl = JdbcUrl.from(config.getUrl());
6366
String businessUniqueKey = MySQLResourcePO.getBusinessUniqueKey(config.getServer().id(), jdbcUrl.getDatabase());
6467
MySQLResourcePO existedResourcePO = AzureMySQLStorage.getStorage().getResourceByBusinessUniqueKey(businessUniqueKey);
65-
String id = Objects.nonNull(existedResourcePO) ? existedResourcePO.getId() : UUID.randomUUID().toString().replace("-", StringUtils.EMPTY);
68+
String id = Objects.nonNull(existedResourcePO) ? existedResourcePO.getId() : DigestUtils.md5Hex(businessUniqueKey);
6669
MySQLResourcePO resourcePO = MySQLResourcePO.builder()
6770
.id(id)
6871
.resourceId(config.getServer().id())

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/SpringDatasourceCompletionContributor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@
2828
import com.microsoft.intellij.AzureLinkStorage;
2929
import com.microsoft.intellij.helpers.AzureIconLoader;
3030
import com.microsoft.tooling.msservices.serviceexplorer.AzureIconSymbol;
31-
import org.apache.commons.collections4.CollectionUtils;
3231
import org.apache.commons.lang3.StringUtils;
3332
import org.jetbrains.annotations.NotNull;
3433

35-
import java.util.List;
3634
import java.util.Objects;
37-
import java.util.stream.Collectors;
3835

3936
public class SpringDatasourceCompletionContributor extends CompletionContributor {
4037

@@ -51,7 +48,7 @@ public void addCompletions(@NotNull CompletionParameters parameters,
5148
.withInsertHandler(new MyInsertHandler())
5249
.withBoldness(true)
5350
.withTypeText("String")
54-
.withTailText(" (Link Azure Datasource for MySQL Service)")
51+
.withTailText(" (Connect to Azure Datasource for MySQL)")
5552
.withAutoCompletionPolicy(AutoCompletionPolicy.SETTINGS_DEPENDENT)
5653
);
5754
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/SpringDatasourceLineMarkerProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
5959
JdbcUrl url = JdbcUrl.from(service.getUrl());
6060
LineMarkerInfo lineMarkerInfo = new LineMarkerInfo<>(element, element.getTextRange(),
6161
AzureIconLoader.loadIcon(AzureIconSymbol.MySQL.BIND_INTO),
62-
element2 -> String.format("Link to Azure Database for MySQL (%s)", url.getHostname()),
62+
element2 -> String.format("Connect to Azure Database for MySQL (%s)", url.getHostname()),
6363
new SpringDatasourceNavigationHandler(service.getResourceId()),
6464
GutterIconRenderer.Alignment.LEFT);
6565
return lineMarkerInfo;

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/util/BeforeRunTaskUtils.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.microsoft.azure.toolkit.intellij.common.AzureArtifact;
2020
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
2121
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
22+
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
2223
import lombok.SneakyThrows;
2324
import org.apache.commons.collections.CollectionUtils;
2425
import org.apache.commons.lang3.StringUtils;
@@ -43,7 +44,9 @@ public class BeforeRunTaskUtils {
4344
public static void addBeforeRunTask(@Nonnull ConfigurationSettingsEditorWrapper editor, @Nonnull AzureArtifact artifact, @Nonnull RunConfiguration config) {
4445
final List<? extends BeforeRunTask<?>> tasks = getBuildTasks(editor, artifact);
4546
final BeforeRunTask<?> task = createBuildTask(artifact, config);
46-
addTask(editor, tasks, task, config);
47+
if(Objects.nonNull(task)){ // task is null if artifact is File type.
48+
addTask(editor, tasks, task, config);
49+
}
4750
}
4851

4952
public static void removeBeforeRunTask(@Nonnull ConfigurationSettingsEditorWrapper editor, @Nonnull AzureArtifact artifact) {
@@ -59,18 +62,22 @@ public static List<? extends BeforeRunTask<?>> getBuildTasks(@Nonnull Configurat
5962
return getGradleAssembleTasks(editor, (ExternalProjectPojo) artifact.getReferencedObject());
6063
case Artifact:
6164
return getIntellijBuildTasks(editor, (Artifact) artifact.getReferencedObject());
65+
case File:
66+
return Collections.emptyList();
6267
}
6368
throw new AzureToolkitRuntimeException("unsupported project/artifact type");
6469
}
6570

66-
public static BeforeRunTask<?> createBuildTask(@Nonnull AzureArtifact artifact, @Nonnull RunConfiguration config) {
71+
public static @Nullable BeforeRunTask<?> createBuildTask(@Nonnull AzureArtifact artifact, @Nonnull RunConfiguration config) {
6772
switch (artifact.getType()) {
6873
case Maven:
6974
return createMavenPackageTask((MavenProject) artifact.getReferencedObject(), config);
7075
case Gradle:
7176
return createGradleAssembleTask((ExternalProjectPojo) artifact.getReferencedObject(), config);
7277
case Artifact:
7378
return createIntellijBuildTask((Artifact) artifact.getReferencedObject(), config);
79+
case File:
80+
return null;
7481
}
7582
throw new AzureToolkitRuntimeException("unsupported project/artifact type");
7683
}

0 commit comments

Comments
 (0)