Skip to content

Commit f6f6c04

Browse files
authored
Merge pull request #5061 from microsoft/merge_release_develop
Merge release-3.50.1 to develop
2 parents 4e05cbf + 76335c1 commit f6f6c04

File tree

14 files changed

+165
-89
lines changed

14 files changed

+165
-89
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@
2525
<change-notes>
2626
<![CDATA[
2727
<html>
28-
<h3>3.50.0</h3>
29-
<h4>Added</h4>
28+
<h3>3.50.1</h3>
29+
<h4>Fixes</h4>
3030
<ul>
31-
<li>Development workflow for Azure Database for MySQL
32-
<ul>
33-
<li>Connect Azure Database for MySQL Server to local project from Azure Explorer or application.properties file</li>
34-
<li>Automatically inject datasource connection properties into runtime environment for local run</li>
35-
<li>Publish Azure Web App with datasource connection properties in application settings</li>
36-
</ul>
37-
</li>
31+
<li>Fixes: Can't deploy to Azure Web App when there is "Connect Azure Resource" in before launch</li>
32+
<li>Fixes: InvalidParameterException occurs when close a streaming log</li>
33+
<li>Fixes: Failed when select file to deploy to Azure Web App</li>
34+
<li>Fixes: Failed to create MySQL instance as resource provider is not registered</li>
3835
</ul>
3936
<p>You may get the full change log <a
4037
href="https://github.com/Microsoft/azure-tools-for-java/blob/develop/CHANGELOG.md">here</a></p>

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/common/AzureArtifactManager.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
package com.microsoft.azure.toolkit.intellij.common;
66

77
import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
8+
import com.intellij.openapi.module.Module;
89
import com.intellij.openapi.project.Project;
10+
import com.intellij.openapi.roots.ProjectFileIndex;
11+
import com.intellij.openapi.vfs.LocalFileSystem;
912
import com.intellij.openapi.vfs.VirtualFile;
1013
import com.intellij.packaging.artifacts.Artifact;
1114
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
@@ -15,16 +18,20 @@
1518
import org.apache.commons.compress.utils.FileNameUtils;
1619
import org.apache.commons.lang3.StringUtils;
1720
import org.jetbrains.annotations.NotNull;
21+
import org.jetbrains.annotations.Nullable;
1822
import org.jetbrains.idea.maven.model.MavenConstants;
1923
import org.jetbrains.idea.maven.project.MavenProject;
2024
import org.jetbrains.idea.maven.project.MavenProjectsManager;
2125
import org.jetbrains.plugins.gradle.model.ExternalProject;
2226
import org.jetbrains.plugins.gradle.service.project.data.ExternalProjectDataCache;
2327

28+
import java.io.File;
2429
import java.util.*;
2530
import java.util.function.Predicate;
2631
import java.util.stream.Collectors;
2732

33+
import static com.microsoft.azure.toolkit.intellij.common.AzureArtifactType.File;
34+
2835
public class AzureArtifactManager {
2936
private static Map<Project, AzureArtifactManager> projectAzureArtifactManagerMap = new HashMap<>();
3037
private final Project project;
@@ -93,7 +100,7 @@ public AzureArtifact getAzureArtifactById(String artifactId) {
93100
}
94101

95102
public AzureArtifact getAzureArtifactById(AzureArtifactType azureArtifactType, String artifactId) {
96-
return azureArtifactType == AzureArtifactType.File ? AzureArtifact.createFromFile(artifactId) :
103+
return azureArtifactType == File ? AzureArtifact.createFromFile(artifactId) :
97104
getAllSupportedAzureArtifacts().stream().filter(artifact -> StringUtils.equals(getArtifactIdentifier(
98105
artifact), artifactId)).findFirst().orElse(null);
99106
}
@@ -121,6 +128,28 @@ public boolean equalsAzureArtifactIdentifier(AzureArtifact artifact1, AzureArtif
121128
return StringUtils.equals(getArtifactIdentifier(artifact1), getArtifactIdentifier(artifact2));
122129
}
123130

131+
@Nullable
132+
@AzureOperation(
133+
name = "common|artifact.get_module",
134+
type = AzureOperation.Type.TASK
135+
)
136+
public Module getModuleFromAzureArtifact(AzureArtifact azureArtifact) {
137+
if (azureArtifact == null || azureArtifact.getReferencedObject() == null) {
138+
return null;
139+
}
140+
switch (azureArtifact.getType()) {
141+
case Gradle:
142+
final String gradleModulePath = ((ExternalProjectPojo) azureArtifact.getReferencedObject()).getPath();
143+
final VirtualFile gradleVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(gradleModulePath));
144+
return ProjectFileIndex.getInstance(project).getModuleForFile(gradleVirtualFile);
145+
case Maven:
146+
return ProjectFileIndex.getInstance(project).getModuleForFile(((MavenProject) azureArtifact.getReferencedObject()).getFile());
147+
default:
148+
// IntelliJ artifact is bind to project, can not get the related module, same for File artifact
149+
return null;
150+
}
151+
}
152+
124153
private String getGradleProjectId(ExternalProjectPojo gradleProjectPojo) {
125154
ExternalProject externalProject = getRelatedExternalProject(gradleProjectPojo);
126155
return Objects.nonNull(externalProject) ? externalProject.getQName() : null;

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/core/FunctionUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ public static void saveAppSettingsToSecurityStorage(String key, Map<String, Stri
8181
return;
8282
}
8383
final String appSettingsJsonValue = JsonUtils.toJsonString(appSettings);
84-
IdeaSecureStore.getInstance().savePassword(FunctionApp.class.getName(), key, appSettingsJsonValue);
84+
IdeaSecureStore.getInstance().savePassword(key, appSettingsJsonValue);
8585
}
8686

8787
public static Map<String, String> loadAppSettingsFromSecurityStorage(String key) {
8888
if (StringUtils.isEmpty(key)) {
8989
return new HashMap<>();
9090
}
91-
final String value = IdeaSecureStore.getInstance().loadPassword(FunctionApp.class.getName(), key);
91+
final String value = IdeaSecureStore.getInstance().loadPassword(key);
9292
return StringUtils.isEmpty(value) ? new HashMap<>() : JsonUtils.fromJson(value, Map.class);
9393
}
9494

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import com.microsoft.azure.toolkit.intellij.link.mysql.JdbcUrl;
1515
import com.microsoft.azure.toolkit.intellij.link.mysql.MySQLResourceConfig;
1616
import com.microsoft.azure.toolkit.intellij.link.po.MySQLResourcePO;
17+
import com.microsoft.azure.toolkit.intellij.mysql.action.LinkMySQLAction;
1718
import com.microsoft.azure.toolkit.lib.common.form.AzureForm;
19+
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle;
20+
import com.microsoft.azure.toolkit.lib.common.operation.IAzureOperationTitle;
1821
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
1922
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
2023
import com.microsoft.azure.toolkit.lib.link.AzureLinkService;
@@ -30,7 +33,7 @@
3033
public class LinkMySQLToModuleDialog extends AzureDialog<LinkConfig<MySQLResourceConfig, ModuleResourceConfig>> {
3134

3235
private static final String PROMPT_TITLE = "Azure Explorer";
33-
private static final String[] PROMPT_OPTIONS = new String[] {"Yes", "No"};
36+
private static final String[] PROMPT_OPTIONS = new String[]{"Yes", "No"};
3437
private static final String PROMPT_MESSAGE = "This resource already existed in your local environment. Do you want to override it?";
3538
private JPanel rootPanel;
3639
private BasicLinkMySQLPanel basicPanel;
@@ -87,8 +90,8 @@ private void doLink(LinkConfig<MySQLResourceConfig, ModuleResourceConfig> linkCo
8790
boolean storageResource = true;
8891
if (Objects.nonNull(existedResourcePO)) {
8992
if (!StringUtils.equals(resourceConfig.getUrl(), existedResourcePO.getUrl()) ||
90-
!StringUtils.equals(resourceConfig.getUsername(), existedResourcePO.getUsername()) ||
91-
resourceConfig.getPasswordConfig().getPasswordSaveType() != existedResourcePO.getPasswordSave()) {
93+
!StringUtils.equals(resourceConfig.getUsername(), existedResourcePO.getUsername()) ||
94+
resourceConfig.getPasswordConfig().getPasswordSaveType() != existedResourcePO.getPasswordSave()) {
9295
storageResource = DefaultLoader.getUIHelper().showConfirmation(PROMPT_MESSAGE, PROMPT_TITLE, PROMPT_OPTIONS, null);
9396
}
9497
}
@@ -98,9 +101,12 @@ private void doLink(LinkConfig<MySQLResourceConfig, ModuleResourceConfig> linkCo
98101
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
99102
indicator.setIndeterminate(true);
100103
AzureLinkService.getInstance().link(project, linkConfig, finalStorageResource);
104+
final String message = String.format("The connection between database (%s/%s) and project (%s) has been successfully created.",
105+
resourceConfig.getServer().name(), resourceConfig.getDatabase().name(), project.getName());
106+
DefaultLoader.getUIHelper().showInfoNotification(LinkMySQLAction.ACTION_NAME, message);
101107
};
102-
String progressMessage = "Connecting Azure Database for MySQL with Module...";
103-
final AzureTask task = new AzureTask(null, progressMessage, false, runnable);
108+
final IAzureOperationTitle title = AzureOperationBundle.title("azure-mysql.azure-mysql-link-to-module");
109+
final AzureTask task = new AzureTask(null, title, false, runnable);
104110
AzureTaskManager.getInstance().runInBackground(task);
105111
}
106112

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.openapi.extensions.PluginId;
1010
import com.intellij.openapi.project.Project;
1111
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
12+
import com.microsoft.azuretools.ActionConstants;
1213
import com.microsoft.azuretools.authmanage.AuthMethodManager;
1314
import com.microsoft.intellij.actions.AzureSignInAction;
1415
import com.microsoft.intellij.AzurePlugin;
@@ -61,6 +62,16 @@ public void actionPerformed(NodeActionEvent e) {
6162
});
6263
}
6364

65+
@Override
66+
protected String getServiceName(NodeActionEvent event) {
67+
return ActionConstants.parse(ActionConstants.MySQL.CONNECT_TO_SERVER).getServiceName();
68+
}
69+
70+
@Override
71+
protected String getOperationName(NodeActionEvent event) {
72+
return ActionConstants.parse(ActionConstants.MySQL.CONNECT_TO_SERVER).getOperationName();
73+
}
74+
6475
private void doActionPerformed(NodeActionEvent e, boolean isLoggedIn, Project project) {
6576
try {
6677
if (!isLoggedIn ||

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
import com.microsoft.azuretools.ActionConstants;
1515
import com.microsoft.azuretools.authmanage.AuthMethodManager;
1616
import com.microsoft.azuretools.core.mvp.model.mysql.MySQLMvpModel;
17-
import com.microsoft.azuretools.telemetrywrapper.Operation;
18-
import com.microsoft.azuretools.telemetrywrapper.TelemetryManager;
17+
import com.microsoft.azuretools.telemetry.TelemetryConstants;
18+
import com.microsoft.azuretools.telemetrywrapper.*;
19+
20+
import java.util.Collections;
21+
import java.util.Map;
1922

2023
public class AzureMySQLService {
2124
private static final AzureMySQLService instance = new AzureMySQLService();
@@ -36,10 +39,11 @@ public Server createMySQL(final AzureMySQLConfig config) {
3639
final Operation operation = TelemetryManager.createOperation(ActionConstants.MySQL.CREATE);
3740
try {
3841
operation.start();
39-
String subscrptionId = config.getSubscription().subscriptionId();
42+
final String subscriptionId = config.getSubscription().subscriptionId();
43+
EventUtil.logEvent(EventType.info, operation, Collections.singletonMap(TelemetryConstants.SUBSCRIPTIONID, subscriptionId));
4044
// create resource group if necessary.
4145
if (config.getResourceGroup() instanceof Draft) {
42-
Azure azure = AuthMethodManager.getInstance().getAzureClient(subscrptionId);
46+
Azure azure = AuthMethodManager.getInstance().getAzureClient(subscriptionId);
4347
ResourceGroup newResourceGroup = azure.resourceGroups().define(config.getResourceGroup().name()).withRegion(config.getRegion()).create();
4448
config.setResourceGroup(newResourceGroup);
4549
}
@@ -48,13 +52,14 @@ public Server createMySQL(final AzureMySQLConfig config) {
4852
parameters.withAdministratorLogin(config.getAdminUsername())
4953
.withAdministratorLoginPassword(String.valueOf(config.getPassword()))
5054
.withVersion(config.getVersion());
51-
Server server = MySQLMvpModel.create(subscrptionId, config.getResourceGroup().name(), config.getServerName(), config.getRegion(), parameters);
55+
Server server = MySQLMvpModel.create(subscriptionId, config.getResourceGroup().name(), config.getServerName(), config.getRegion(), parameters);
5256
// update access from azure services
53-
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessFromAzureServices(subscrptionId, server, config.isAllowAccessFromAzureServices());
57+
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessFromAzureServices(subscriptionId, server, config.isAllowAccessFromAzureServices());
5458
// update access from local machine
55-
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessToLocalMachine(subscrptionId, server, config.isAllowAccessFromLocalMachine());
59+
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessToLocalMachine(subscriptionId, server, config.isAllowAccessFromLocalMachine());
5660
return server;
5761
} catch (final RuntimeException e) {
62+
EventUtil.logError(operation, ErrorType.systemError, e, null, null);
5863
throw e;
5964
} finally {
6065
operation.complete();

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
import com.intellij.openapi.actionSystem.DataContext;
1616
import com.intellij.openapi.diagnostic.Logger;
1717
import com.intellij.openapi.module.Module;
18-
import com.intellij.openapi.roots.ProjectFileIndex;
1918
import com.intellij.openapi.util.Key;
20-
import com.intellij.openapi.vfs.LocalFileSystem;
21-
import com.intellij.openapi.vfs.VirtualFile;
2219
import com.microsoft.azure.toolkit.intellij.common.AzureArtifact;
2320
import com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager;
2421
import com.microsoft.azure.toolkit.intellij.webapp.runner.webappconfig.WebAppConfiguration;
@@ -107,8 +104,7 @@ private String getModuleName(@NotNull RunConfiguration runConfiguration) {
107104
WebAppConfiguration webAppConfiguration = (WebAppConfiguration) runConfiguration;
108105
final AzureArtifact azureArtifact = AzureArtifactManager.getInstance(runConfiguration.getProject())
109106
.getAzureArtifactById(webAppConfiguration.getAzureArtifactType(), webAppConfiguration.getArtifactIdentifier());
110-
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(azureArtifact.getTargetPath());
111-
Module module = ProjectFileIndex.getInstance(runConfiguration.getProject()).getModuleForFile(virtualFile, false);
107+
final Module module = AzureArtifactManager.getInstance(runConfiguration.getProject()).getModuleFromAzureArtifact(azureArtifact);
112108
return Objects.nonNull(module) ? module.getName() : StringUtils.EMPTY;
113109
}
114110
if (runConfiguration instanceof AbstractRunConfiguration

0 commit comments

Comments
 (0)