Search in sources :

Example 1 with FunctionAppConfig

use of com.microsoft.azure.toolkit.lib.function.FunctionAppConfig in project azure-tools-for-java by Microsoft.

the class CreateFunctionAppAction method openDialog.

@AzureOperation(name = "function.open_creation_dialog", type = AzureOperation.Type.ACTION)
private void openDialog(final Project project, @Nullable final FunctionAppConfig data) {
    final FunctionAppCreationDialog dialog = new FunctionAppCreationDialog(project);
    if (Objects.nonNull(data)) {
        dialog.setData(data);
    }
    dialog.setOkActionListener((config) -> {
        dialog.close();
        this.createFunctionApp(config).subscribe(functionApp -> {
        }, (error) -> {
            final String title = String.format("Reopen dialog \"%s\"", dialog.getTitle());
            final Consumer<Object> act = t -> AzureTaskManager.getInstance().runLater("open dialog", () -> this.openDialog(project, config));
            final Action<?> action = new Action<>(act, new ActionView.Builder(title));
            AzureMessager.getMessager().error(error, null, action);
        });
    });
    dialog.show();
}
Also used : FunctionAppCreationDialog(com.microsoft.azure.toolkit.intellij.function.FunctionAppCreationDialog) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) AzureBundle.message(com.microsoft.intellij.ui.messages.AzureBundle.message) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) IntellijAzureMessager(com.microsoft.azure.toolkit.intellij.common.messager.IntellijAzureMessager) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Single(rx.Single) AzureOperationBundle.title(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title) Project(com.intellij.openapi.project.Project) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) FunctionAppService(com.microsoft.azure.toolkit.lib.function.FunctionAppService) ProgressManager(com.intellij.openapi.progress.ProgressManager) AzureActionEnum(com.microsoft.tooling.msservices.serviceexplorer.AzureActionEnum) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) AzureMessager(com.microsoft.azure.toolkit.lib.common.messager.AzureMessager) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable) IAzureMessage(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessage) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) Name(com.microsoft.tooling.msservices.helpers.Name) FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig) AzureTelemetry(com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetry) Objects(java.util.Objects) Consumer(java.util.function.Consumer) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) FunctionModule(com.microsoft.tooling.msservices.serviceexplorer.azure.function.FunctionModule) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) Action(com.microsoft.azure.toolkit.lib.common.action.Action) TelemetryManager(com.microsoft.azuretools.telemetrywrapper.TelemetryManager) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) Action(com.microsoft.azure.toolkit.lib.common.action.Action) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) FunctionAppCreationDialog(com.microsoft.azure.toolkit.intellij.function.FunctionAppCreationDialog) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with FunctionAppConfig

use of com.microsoft.azure.toolkit.lib.function.FunctionAppConfig 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 3 with FunctionAppConfig

use of com.microsoft.azure.toolkit.lib.function.FunctionAppConfig in project azure-tools-for-java by Microsoft.

the class FunctionDeploymentState method createFunctionApp.

private IFunctionApp createFunctionApp(@NotNull RunProcessHandler processHandler) {
    IFunctionApp functionApp = Azure.az(AzureAppService.class).subscription(functionDeployConfiguration.getSubscriptionId()).functionApp(functionDeployConfiguration.getConfig().getResourceGroup().getName(), functionDeployConfiguration.getAppName());
    if (functionApp.exists()) {
        return functionApp;
    }
    processHandler.setText(message("function.create.hint.creating", functionDeployConfiguration.getAppName()));
    // Load app settings from security storage
    final FunctionAppConfig config = deployModel.getFunctionAppConfig();
    config.setAppSettings(FunctionUtils.loadAppSettingsFromSecurityStorage(functionDeployConfiguration.getAppSettingsKey()));
    // create function app
    functionApp = FunctionAppService.getInstance().createFunctionApp(config);
    // update run configuration
    functionDeployConfiguration.setFunctionId(functionApp.id());
    // Notify explorer refresh
    AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, functionApp));
    processHandler.setText(message("function.create.hint.created", functionDeployConfiguration.getAppName()));
    return functionApp;
}
Also used : FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent)

Example 4 with FunctionAppConfig

use of com.microsoft.azure.toolkit.lib.function.FunctionAppConfig in project azure-tools-for-java by Microsoft.

the class FunctionAppConfigFormPanelAdvance method getData.

@Override
public FunctionAppConfig getData() {
    final FunctionAppConfig data = appServiceConfigPanelAdvanced.getData();
    data.setMonitorConfig(appServiceMonitorPanel.getData());
    return data;
}
Also used : FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig)

Example 5 with FunctionAppConfig

use of com.microsoft.azure.toolkit.lib.function.FunctionAppConfig in project azure-tools-for-java by Microsoft.

the class FunctionDeployConfiguration method validate.

@Override
public void validate() throws ConfigurationException {
    checkAzurePreconditions();
    if (this.module == null) {
        throw new ConfigurationException(message("function.deploy.validate.noModule"));
    }
    final FunctionAppConfig functionAppConfig = functionDeployModel.getFunctionAppConfig();
    if (StringUtils.isAllEmpty(functionAppConfig.getResourceId(), functionAppConfig.getName())) {
        throw new ConfigurationException(message("function.deploy.validate.noTarget"));
    }
}
Also used : FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Aggregations

FunctionAppConfig (com.microsoft.azure.toolkit.lib.function.FunctionAppConfig)5 IFunctionApp (com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp)3 AzureUIRefreshEvent (com.microsoft.azuretools.utils.AzureUIRefreshEvent)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 Project (com.intellij.openapi.project.Project)1 IntellijAzureMessager (com.microsoft.azure.toolkit.intellij.common.messager.IntellijAzureMessager)1 FunctionAppCreationDialog (com.microsoft.azure.toolkit.intellij.function.FunctionAppCreationDialog)1 FunctionDeployConfiguration (com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration)1 FunctionDeploymentConfigurationFactory (com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)1 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)1 Action (com.microsoft.azure.toolkit.lib.common.action.Action)1 ActionView (com.microsoft.azure.toolkit.lib.common.action.ActionView)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 AzureMessager (com.microsoft.azure.toolkit.lib.common.messager.AzureMessager)1 IAzureMessage (com.microsoft.azure.toolkit.lib.common.messager.IAzureMessage)1