Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.microsoft.azuretools.authmanage.AuthMethod;
import com.microsoft.azuretools.authmanage.AuthMethodManager;
import com.microsoft.azuretools.authmanage.models.AuthMethodDetails;
import com.microsoft.azuretools.ijidea.ui.ErrorWindow;
import com.microsoft.azuretools.ijidea.ui.SignInWindow;
import com.microsoft.azuretools.ijidea.utility.AzureAnAction;
import com.microsoft.azuretools.telemetry.TelemetryConstants;
Expand Down Expand Up @@ -122,25 +121,20 @@ private static String getSignOutWarningMessage(@NotNull AuthMethodManager authMe

public static void onAzureSignIn(Project project) {
JFrame frame = WindowManager.getInstance().getFrame(project);
try {
AuthMethodManager authMethodManager = AuthMethodManager.getInstance();
boolean isSignIn = authMethodManager.isSignedIn();
if (isSignIn) {
boolean res = DefaultLoader.getUIHelper().showYesNoDialog(frame.getRootPane(),
getSignOutWarningMessage(authMethodManager),
"Azure Sign Out",
new ImageIcon("icons/azure.png"));
if (res) {
EventUtil.executeWithLog(ACCOUNT, SIGNOUT, (operation) -> {
authMethodManager.signOut();
});
}
} else {
doSignIn(authMethodManager, project);
AuthMethodManager authMethodManager = AuthMethodManager.getInstance();
boolean isSignIn = authMethodManager.isSignedIn();
if (isSignIn) {
boolean res = DefaultLoader.getUIHelper().showYesNoDialog(frame.getRootPane(),
getSignOutWarningMessage(authMethodManager),
"Azure Sign Out",
new ImageIcon("icons/azure.png"));
if (res) {
EventUtil.executeWithLog(ACCOUNT, SIGNOUT, (operation) -> {
authMethodManager.signOut();
});
}
} catch (Exception ex) {
ex.printStackTrace();
ErrorWindow.show(project, ex.getMessage(), "AzureSignIn Action Error");
} else {
doSignIn(authMethodManager, project);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private SignInWindow(AuthMethodDetails authMethodDetails, Project project) {
setOKButtonText("Sign in");

this.authMethodDetails = authMethodDetails;
authFileTextField.setText(authMethodDetails.getCredFilePath());
authFileTextField.setText(authMethodDetails == null ? null : authMethodDetails.getCredFilePath());

automatedRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Expand Down Expand Up @@ -223,7 +223,7 @@ protected void init() {
AzureTokenWrapper tokenWrapper = null;
try {
tokenWrapper = AzureAuthHelper.getAzureCLICredential(null);
} catch (IOException e) {
} catch (IOException | RuntimeException e) {
// swallow exception while getting azure cli credential
}
if (tokenWrapper != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
public class AzureFunctionMvpModel {
public static final PricingTier CONSUMPTION_PRICING_TIER = new PricingTier("Consumption", "");

private static final String CANNOT_GET_FUNCTION_APP_WITH_ID = "Cannot get Function App with ID: ";
private final Map<String, List<ResourceEx<FunctionApp>>> subscriptionIdToFunctionApps;

private AzureFunctionMvpModel() {
Expand All @@ -64,8 +63,8 @@ public static AzureFunctionMvpModel getInstance() {
public FunctionApp getFunctionById(String sid, String id) throws AzureToolkitRuntimeException {
final FunctionApp app = getFunctionAppsClient(sid).getById(id);
if (Objects.isNull(app)) {
final String error = String.format("Cannot find FunctionApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid);
final String action = String.format("Confirm if the FunctionApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id));
final String error = String.format("cannot find FunctionApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid);
final String action = String.format("confirm if the FunctionApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id));
throw new AzureToolkitRuntimeException(error, action);
}
return app;
Expand Down Expand Up @@ -229,12 +228,9 @@ public static boolean isApplicationLogEnabled(WebAppBase webAppBase) {
return false;
}
final ApplicationLogsConfig applicationLogsConfig = config.inner().applicationLogs();
return (applicationLogsConfig.fileSystem() != null
&& applicationLogsConfig.fileSystem().level() != LogLevel.OFF) ||
(applicationLogsConfig.azureBlobStorage() != null
&& applicationLogsConfig.azureBlobStorage().level() != LogLevel.OFF) ||
(applicationLogsConfig.azureTableStorage() != null
&& applicationLogsConfig.azureTableStorage().level() != LogLevel.OFF);
return (applicationLogsConfig.fileSystem() != null && applicationLogsConfig.fileSystem().level() != LogLevel.OFF) ||
(applicationLogsConfig.azureBlobStorage() != null && applicationLogsConfig.azureBlobStorage().level() != LogLevel.OFF) ||
(applicationLogsConfig.azureTableStorage() != null && applicationLogsConfig.azureTableStorage().level() != LogLevel.OFF);
}

@AzureOperation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static AzureWebAppMvpModel getInstance() {
public WebApp getWebAppById(String sid, String id) throws AzureToolkitRuntimeException {
final WebApp webapp = this.getNullableWebAppById(sid, id);
if (Objects.isNull(webapp)) {
final String error = String.format("Cannot find WebApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid);
final String action = String.format("Confirm if the WebApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id));
final String error = String.format("cannot find WebApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid);
final String action = String.format("confirm if the WebApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id));
throw new AzureToolkitRuntimeException(error, action);
}
return webapp;
Expand Down