Search in sources :

Example 1 with FunctionDeploymentConfigurationFactory

use of com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory in project azure-tools-for-java by Microsoft.

the class DeployFunctionAppAction method getRunConfigurationSettings.

private RunnerAndConfigurationSettings getRunConfigurationSettings(RunManagerEx manager) {
    final ConfigurationFactory factory = new FunctionDeploymentConfigurationFactory(functionType);
    final String runConfigurationName = String.format("%s: %s:%s", factory.getName(), project.getName(), functionNode.getName());
    RunnerAndConfigurationSettings settings = manager.findConfigurationByName(runConfigurationName);
    if (settings == null) {
        settings = manager.createConfiguration(runConfigurationName, factory);
    }
    final RunConfiguration runConfiguration = settings.getConfiguration();
    if (runConfiguration instanceof FunctionDeployConfiguration) {
        final IFunctionApp functionApp = Azure.az(AzureAppService.class).functionApp(functionNode.getId());
        final FunctionAppConfig config = FunctionAppService.getInstance().getFunctionAppConfigFromExistingFunction(functionApp);
        ((FunctionDeployConfiguration) runConfiguration).saveConfig(config);
    }
    return settings;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FunctionDeployConfiguration(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)

Example 2 with FunctionDeploymentConfigurationFactory

use of com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory in project azure-tools-for-java by Microsoft.

the class DeployFunctionAction method runConfiguration.

private void runConfiguration(Module module) {
    // todo: investigate when will module be null
    if (module == null) {
        return;
    }
    final Project project = module.getProject();
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = new FunctionDeploymentConfigurationFactory(configType);
    final RunnerAndConfigurationSettings settings = RunConfigurationUtils.getOrCreateRunConfigurationSettings(module, manager, factory);
    if (RunDialog.editConfiguration(project, settings, message("function.deploy.configuration.title"), DefaultRunExecutor.getRunExecutorInstance())) {
        final List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
        manager.addConfiguration(settings, false, tasks, false);
        manager.setSelectedConfiguration(settings);
        ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)2 FunctionDeploymentConfigurationFactory (com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)2 BeforeRunTask (com.intellij.execution.BeforeRunTask)1 RunManagerEx (com.intellij.execution.RunManagerEx)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 Project (com.intellij.openapi.project.Project)1 FunctionDeployConfiguration (com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration)1 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)1 IFunctionApp (com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp)1 FunctionAppConfig (com.microsoft.azure.toolkit.lib.function.FunctionAppConfig)1 ArrayList (java.util.ArrayList)1