diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/resources/META-INF/platformPlugin.xml b/PluginsAndFeatures/azure-toolkit-for-intellij/resources/META-INF/platformPlugin.xml index 1c5f6daec7..473dfc6b84 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/resources/META-INF/platformPlugin.xml +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/resources/META-INF/platformPlugin.xml @@ -7,7 +7,7 @@

Added:

diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/META-INF/plugin.xml b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/META-INF/plugin.xml index 67aceb786c..8f83e72e43 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/META-INF/plugin.xml +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/META-INF/plugin.xml @@ -26,7 +26,7 @@

[3.50.0-2023.1]

@@ -40,7 +40,7 @@

Fixed bugs:

@@ -344,6 +344,7 @@ implementationClass="org.jetbrains.plugins.azure.functions.completion.csharp.TimerTriggerCompletionContributor" /> + diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/messages/RiderAzureMessages.properties b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/messages/RiderAzureMessages.properties index b9e03445d1..860fa57662 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/messages/RiderAzureMessages.properties +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/resources/messages/RiderAzureMessages.properties @@ -34,10 +34,6 @@ settings.app_services.function_app.core_tools.download_path.invalid=Not a valid settings.app_services.function_app.core_tools.download_path_description=Azure Functions Core Tools download path settings.app_services.function_app.core_tools.description=Configure the Azure Functions Core Tools to be used for an Azure Functions version. -settings.app_services.function_app.azurite.group=Azurite (Storage Emulator) -settings.app_services.function_app.azurite.group.description=An Azure storage emulator required when running Azure Functions on your local machine. -settings.app_services.function_app.azurite.automaticstart=Automatically start Azurite on run/debug Azure Functions - settings.managedidentity.name=Service Authentication settings.managedidentity.description=When logged in with Azure CLI, your apps can use your developer credentials\nto authenticate and access Azure resources when debugging. settings.managedidentity.info.title=How does Azure service authentication work? @@ -467,6 +463,8 @@ action.azurite.show_settings.name=Azurite Settings action.azurite.show_settings.description=Show Azurite Settings action.azurite.reattach.workspace=Workspace: {0} action.azurite.reattach.finished=Attached to Azurite process. +run_config.azurite.before_run_tasks.run_azurite_name=Start Azurite +run_config.azurite.before_run_tasks.run_azurite_description=Start Azurite Storage Emulator action.identity.ad.register_app.name=Register Azure AD application action.identity.ad.register_app.description=Register application in Azure Active Directory diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/AzureRiderSettings.kt b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/AzureRiderSettings.kt index 7fcdb03408..838ff8b14d 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/AzureRiderSettings.kt +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/AzureRiderSettings.kt @@ -51,8 +51,6 @@ object AzureRiderSettings { @Deprecated("To be removed with 2022.3") const val PROPERTY_FUNCTIONS_MIGRATE_CORETOOLS_PATH_NOTIFICATION = "AzureFunctionsCoreToolsPath_Migration_Notify" - const val PROPERTY_FUNCTIONS_AZURITE_AUTOSTART = "AzureFunctionsAzuriteAutoStart" - data class AzureCoreToolsPathEntry(var functionsVersion: String, var coreToolsPath: String) { fun toStringEntry() = "$functionsVersion|$coreToolsPath" diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/ui/AzureFunctionsConfigurationPanel.kt b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/ui/AzureFunctionsConfigurationPanel.kt index a14528ceac..30f61485b2 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/ui/AzureFunctionsConfigurationPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/com/microsoft/intellij/configuration/ui/AzureFunctionsConfigurationPanel.kt @@ -236,20 +236,6 @@ class AzureFunctionsConfigurationPanel(parentDisposable: Disposable) } } - group(message("settings.app_services.function_app.azurite.group")) { - row { - text(message("settings.app_services.function_app.azurite.group.description")) - } - - row { - var value = properties.getBoolean(AzureRiderSettings.PROPERTY_FUNCTIONS_AZURITE_AUTOSTART, true) - - checkBox(message("settings.app_services.function_app.azurite.automaticstart")) - .bindSelected(MutableProperty({ value }, { value = it })) - .onApply { properties.setValue(AzureRiderSettings.PROPERTY_FUNCTIONS_AZURITE_AUTOSTART, value) } - } - } - row { placeholder() } diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/org/jetbrains/plugins/azure/functions/buildTasks/BuildFunctionsProjectBeforeRunTaskProvider.kt b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/org/jetbrains/plugins/azure/functions/buildTasks/BuildFunctionsProjectBeforeRunTaskProvider.kt index 402fac643e..9beb6c9d10 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/org/jetbrains/plugins/azure/functions/buildTasks/BuildFunctionsProjectBeforeRunTaskProvider.kt +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/src/org/jetbrains/plugins/azure/functions/buildTasks/BuildFunctionsProjectBeforeRunTaskProvider.kt @@ -50,9 +50,7 @@ class BuildFunctionsProjectBeforeRunTaskProvider : BeforeRunTaskProvider(AzuriteBeforeRunTaskProvider.providerId) + +class AzuriteBeforeRunTaskProvider : BeforeRunTaskProvider() { + companion object { + val providerId = Key.create("RunAzuriteTask") + } + + override fun getId(): Key? = providerId + + override fun getName(): String? = RiderAzureBundle.message("run_config.azurite.before_run_tasks.run_azurite_name") + + + override fun isConfigurable() = false + + override fun getIcon(): Icon = CommonIcons.Azurite + + private fun shouldCreateBuildBeforeRunTaskByDefault(runConfiguration: RunConfiguration): Boolean { + return runConfiguration is AzureFunctionsHostConfiguration + } + + override fun createTask(runConfiguration: RunConfiguration): AzuriteBeforeRunTask? { + if (!shouldCreateBuildBeforeRunTaskByDefault(runConfiguration)) return null + val task = AzuriteBeforeRunTask() + task.isEnabled = true + return task + } + + override fun executeTask(context: DataContext, + configuration: RunConfiguration, + env: ExecutionEnvironment, + task: AzuriteBeforeRunTask): Boolean { + + val project = configuration.project + + ActionUtil.invokeAction( + StartAzuriteAction(), + SimpleDataContext.getProjectContext(project), + ActionPlaces.INTENTION_MENU, + null, + null) + + return true + } +} \ No newline at end of file diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/test-integration/org/cases/runconfig/functionapp/FunctionHostConfigurationTestBase.kt b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/test-integration/org/cases/runconfig/functionapp/FunctionHostConfigurationTestBase.kt index 7226a364ae..a925268d3d 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/rider/test-integration/org/cases/runconfig/functionapp/FunctionHostConfigurationTestBase.kt +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/rider/test-integration/org/cases/runconfig/functionapp/FunctionHostConfigurationTestBase.kt @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020-2022 JetBrains s.r.o. + * Copyright (c) 2020-2023 JetBrains s.r.o. * * All rights reserved. * @@ -37,6 +37,7 @@ import org.jetbrains.plugins.azure.functions.buildTasks.BuildFunctionsProjectBef import org.jetbrains.plugins.azure.functions.daemon.AzureRunnableProjectKinds import org.jetbrains.plugins.azure.functions.run.AzureFunctionsHostConfiguration import org.jetbrains.plugins.azure.functions.run.AzureFunctionsHostConfigurationType +import org.jetbrains.plugins.azure.storage.azurite.AzuriteBeforeRunTaskProvider import org.testng.annotations.Test import kotlin.test.fail @@ -70,7 +71,7 @@ abstract class FunctionHostConfigurationTestBase( //region Before Run Tasks @Test(description = "Verifies Function Host run configuration has Build Function App before run task by default.") - fun testFunctionHost_BeforeRunTasks_Defaults() { + fun testFunctionHost_BeforeRunTasks_Defaults_BuildFunctionsProject() { val configuration = createRunConfiguration( name = "Run Function App: ${project.name}", configurationType = AzureFunctionsHostConfigurationType::class.java @@ -78,13 +79,28 @@ abstract class FunctionHostConfigurationTestBase( configuration.name.shouldBe("Run Function App: $projectName") - configuration.beforeRunTasks.size.shouldBe(1) - configuration.beforeRunTasks[0].providerId.shouldBe(BuildFunctionsProjectBeforeRunTaskProvider.providerId) + configuration.beforeRunTasks.shouldContains { beforeRunTask -> + beforeRunTask.providerId == BuildFunctionsProjectBeforeRunTaskProvider.providerId + } + } + + @Test(description = "Verifies Function Host run configuration has Start Azurite before run task by default.") + fun testFunctionHost_BeforeRunTasks_Defaults_AzuriteBeforeRunTask() { + val configuration = createRunConfiguration( + name = "Run Function App: ${project.name}", + configurationType = AzureFunctionsHostConfigurationType::class.java + ) as AzureFunctionsHostConfiguration + + configuration.name.shouldBe("Run Function App: $projectName") + + configuration.beforeRunTasks.shouldContains { beforeRunTask -> + beforeRunTask.providerId == AzuriteBeforeRunTaskProvider.providerId + } } // TODO: Need to make sure function core tools is available on a server before enable. - @Test(enabled = false, description = "Check before run task that should build a function app project.") - fun testFunctionHost_BeforeRunTasks_BuildFunctionProject() { + @Test(enabled = false, description = "Check before run task that should build a function app project and start Azurite.") + fun testFunctionHost_BeforeRunTasks_BuildFunctionProject_StartAzurite() { addProject(arrayOf(projectName), "ConsoleApp1", ProjectTemplateIds.core(coreVersion).consoleApplication) val configuration = createRunConfiguration( @@ -102,8 +118,13 @@ abstract class FunctionHostConfigurationTestBase( configuration.parameters.exePath = projectToRun.projectOutputs.first().exePath configuration.parameters.projectTfm = projectToRun.projectOutputs.first().tfm?.presentableName ?: "" - configuration.beforeRunTasks.size.shouldBe(1) - configuration.beforeRunTasks[0].providerId.shouldBe(BuildFunctionsProjectBeforeRunTaskProvider.providerId) + configuration.beforeRunTasks.shouldContains { beforeRunTask -> + beforeRunTask.providerId == BuildFunctionsProjectBeforeRunTaskProvider.providerId + } + + configuration.beforeRunTasks.shouldContains { beforeRunTask -> + beforeRunTask.providerId == AzuriteBeforeRunTaskProvider.providerId + } checkCanExecuteRunConfiguration(configuration)