Skip to content

Commit

Permalink
Merge pull request #923 from JetBrains/rival/improve-function-run
Browse files Browse the repository at this point in the history
Fix some issues with Azure Function run
  • Loading branch information
rafaelldi authored Sep 18, 2024
2 parents 9a40458 + 7df5463 commit 7787dc3
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 45 deletions.
8 changes: 8 additions & 0 deletions PluginsAndFeatures/azure-toolkit-for-rider/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

## [Unreleased]

### Fixed

- Improve error notification if unable to get Azure Function worker PID ([RIDER-116398](https://youtrack.jetbrains.com/issue/RIDER-116398))

### Added

- Setting to disable Azurite executable check before running a configuration ([RIDER-106668](https://youtrack.jetbrains.com/issue/RIDER-106668))

## [4.1.3] - 2024-09-06

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class FunctionIsolatedDebugProfileState(
throw CantRunException("Azure Functions host process terminated before the debugger could attach")
}

if (pid == 0) {
if (pid == null || pid == 0) {
LOG.warn("Azure Functions host did not return isolated worker process id")

Notification(
Expand All @@ -132,7 +132,7 @@ class FunctionIsolatedDebugProfileState(
throw CantRunException("Azure Functions host did not return isolated worker process id")
}

return executionResult to requireNotNull(pid)
return executionResult to pid
}

override suspend fun createWorkerRunInfo(lifetime: Lifetime, helper: DebuggerHelperHost, port: Int) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.microsoft.azure.toolkit.intellij.common.IntelliJAzureIcons
import com.microsoft.azure.toolkit.intellij.storage.azurite.services.AzuriteService
import com.microsoft.azure.toolkit.intellij.storage.azurite.settings.AzuriteSettings
import javax.swing.Icon
import kotlin.io.path.exists

class AzuriteBeforeRunTask : BeforeRunTask<AzuriteBeforeRunTask>(AzuriteBeforeRunTaskProvider.ID)

Expand All @@ -36,20 +35,6 @@ class AzuriteBeforeRunTaskProvider : BeforeRunTaskProvider<AzuriteBeforeRunTask>

override fun createTask(runConfiguration: RunConfiguration): AzuriteBeforeRunTask {
val task = AzuriteBeforeRunTask()

val project = runConfiguration.project
val settings = AzuriteSettings.getInstance(project)
val azuritePath = settings.getAzuriteExecutablePath()
if (azuritePath == null || !azuritePath.exists()) {
task.isEnabled = false
return task
}
val workspacePath = settings.getAzuriteWorkspacePath()
if (!workspacePath.exists()) {
task.isEnabled = false
return task
}

task.isEnabled = runConfiguration.type.id == "AzureFunctionAppRun"
return task
}
Expand All @@ -61,9 +46,10 @@ class AzuriteBeforeRunTaskProvider : BeforeRunTaskProvider<AzuriteBeforeRunTask>
task: AzuriteBeforeRunTask
): Boolean {
val project = configuration.project
val checkAzuriteExecutable = AzuriteSettings.getInstance(project).checkAzuriteExecutable
val service = AzuriteService.getInstance()
if (!service.isRunning) {
service.start(project)
service.start(project, !checkAzuriteExecutable)
}

return true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2018-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license.
*/

package com.microsoft.azure.toolkit.intellij.storage.azurite.actions

import com.intellij.notification.Notification
import com.intellij.notification.NotificationAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.microsoft.azure.toolkit.intellij.storage.azurite.settings.AzuriteSettings

class DisableAzuriteCheckNotificationAction : NotificationAction("Do not show again") {
override fun actionPerformed(event: AnActionEvent, notification: Notification) {
val project = event.project ?: return
val settings = AzuriteSettings.getInstance(project)
settings.checkAzuriteExecutable = false
notification.expire()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.options.ShowSettingsUtil
import com.microsoft.azure.toolkit.intellij.storage.azurite.settings.AzuriteConfigurable

class ShowAzuriteSettingsNotificationAction: NotificationAction("Show settings") {
class ShowAzuriteSettingsNotificationAction : NotificationAction("Show settings") {
override fun actionPerformed(e: AnActionEvent, n: Notification) {
val project = e.project ?: return
ShowSettingsUtil.getInstance().showSettingsDialog(project, AzuriteConfigurable::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.intellij.util.application
import com.intellij.util.io.BaseOutputReader
import com.jetbrains.rd.platform.util.idea.LifetimedService
import com.jetbrains.rd.util.lifetime.SequentialLifetimes
import com.microsoft.azure.toolkit.intellij.storage.azurite.actions.DisableAzuriteCheckNotificationAction
import com.microsoft.azure.toolkit.intellij.storage.azurite.actions.ShowAzuriteSettingsNotificationAction
import com.microsoft.azure.toolkit.intellij.storage.azurite.settings.AzuriteSettings
import com.microsoft.azure.toolkit.lib.storage.AzuriteStorageAccount
Expand Down Expand Up @@ -64,7 +65,7 @@ class AzuriteService(private val scope: CoroutineScope) : LifetimedService() {
return sessionStarted.get() && !sessionLifetimes.isTerminated
}

fun start(project: Project) {
fun start(project: Project, silent: Boolean = false) {
if (isRunning) {
LOG.warn("The caller should verify if an existing session is running, before calling start()")
return
Expand All @@ -75,39 +76,24 @@ class AzuriteService(private val scope: CoroutineScope) : LifetimedService() {
val settings = AzuriteSettings.getInstance(project)
val azuritePath = settings.getAzuriteExecutablePath()
if (azuritePath == null || !azuritePath.exists()) {
Notification(
"Azure AppServices",
"Unable to find Azurite executable location",
azuritePath?.let { "${it.absolutePathString()} isn't exists" } ?: "",
NotificationType.WARNING
)
.addAction(ShowAzuriteSettingsNotificationAction())
.notify(project)
if (!silent) {
showUnableToFindAzuriteExecutableNotification(azuritePath, project)
}
return
}

val workspacePath = settings.getAzuriteWorkspacePath()
if (!workspacePath.exists()) {
Notification(
"Azure AppServices",
"Unable to find Azurite workspace location",
"${workspacePath.absolutePathString()} isn't exists",
NotificationType.WARNING
)
.addAction(ShowAzuriteSettingsNotificationAction())
.notify(project)
if (!silent) {
showUnableToFindAzuriteWorkspaceNotification(workspacePath, project)
}
return
}

if (settings.basicOAuth && settings.certificatePath.isEmpty()) {
Notification(
"Azure AppServices",
"The certificate path cannot be empty if OAuth is enabled",
"",
NotificationType.WARNING
)
.addAction(ShowAzuriteSettingsNotificationAction())
.notify(project)
if (!silent) {
showEmptyCertificatePathNotification(project)
}
return
}

Expand Down Expand Up @@ -322,4 +308,40 @@ class AzuriteService(private val scope: CoroutineScope) : LifetimedService() {
application.messageBus
.syncPublisher(AzuriteSessionListener.TOPIC)
.sessionStopped()

private fun showUnableToFindAzuriteExecutableNotification(azuritePath: Path?, project: Project) {
Notification(
"Azure AppServices",
"Unable to find Azurite executable location",
azuritePath?.let { "${it.absolutePathString()} isn't exists" } ?: "",
NotificationType.WARNING
)
.addAction(ShowAzuriteSettingsNotificationAction())
.addAction(DisableAzuriteCheckNotificationAction())
.notify(project)
}

private fun showUnableToFindAzuriteWorkspaceNotification(workspacePath: Path, project: Project) {
Notification(
"Azure AppServices",
"Unable to find Azurite workspace location",
"${workspacePath.absolutePathString()} isn't exists",
NotificationType.WARNING
)
.addAction(ShowAzuriteSettingsNotificationAction())
.addAction(DisableAzuriteCheckNotificationAction())
.notify(project)
}

private fun showEmptyCertificatePathNotification(project: Project) {
Notification(
"Azure AppServices",
"The certificate path cannot be empty if OAuth is enabled",
"",
NotificationType.WARNING
)
.addAction(ShowAzuriteSettingsNotificationAction())
.addAction(DisableAzuriteCheckNotificationAction())
.notify(project)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class AzuriteConfigurable(private val project: Project) : BoundConfigurable("Azu
)
}
}
row {
checkBox("Check the Azurite executable before running a configuration")
.bindSelected(settings::checkAzuriteExecutable)
}
}
group("Host/Port Settings") {
row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class AzuriteSettings(private val project: Project) : SimplePersistentStateCompo
state.showAzuriteService = value
}

var checkAzuriteExecutable
get() = state.checkAzuriteExecutable
set(value) {
state.checkAzuriteExecutable = value
}

var blobHost
get() = state.blobHost ?: ""
set(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AzuriteSettingsState : BaseState() {
var workspacePath by string("")
var looseMode by property(false)
var showAzuriteService by property(true)
var checkAzuriteExecutable by property(true)
var blobHost by string("127.0.0.1")
var blobPort by property(10000)
var queueHost by string("127.0.0.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.jetbrains
pluginName = azure-toolkit-for-rider
pluginRepositoryUrl = https://github.com/JetBrains/azure-tools-for-intellij
# SemVer format -> https://semver.org
pluginVersion = 4.1.3
pluginVersion = 4.2.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 242
Expand Down

0 comments on commit 7787dc3

Please sign in to comment.