Search in sources :

Example 1 with DiagnosticConfig

use of com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig in project azure-tools-for-java by Microsoft.

the class AzureWebAppMvpModel method createWebAppFromSettingModel.

/**
 * API to create new Web App by setting model.
 */
@AzureOperation(name = "webapp.create_detail", params = { "model.getWebAppName()" }, type = AzureOperation.Type.SERVICE)
public IWebApp createWebAppFromSettingModel(@NotNull WebAppSettingModel model) {
    final ResourceGroup resourceGroup = getOrCreateResourceGroup(model.getSubscriptionId(), model.getResourceGroup(), model.getRegion());
    final AppServicePlanEntity servicePlanEntity = AppServicePlanEntity.builder().id(model.getAppServicePlanId()).subscriptionId(model.getSubscriptionId()).name(model.getAppServicePlanName()).resourceGroup(model.getResourceGroup()).region(model.getRegion()).operatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem.fromString(model.getOperatingSystem())).pricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier.fromString(model.getPricing())).build();
    final IAppServicePlan appServicePlan = getOrCreateAppServicePlan(servicePlanEntity);
    final DiagnosticConfig diagnosticConfig = DiagnosticConfig.builder().enableApplicationLog(model.isEnableApplicationLog()).applicationLogLevel(com.microsoft.azure.toolkit.lib.appservice.model.LogLevel.fromString(model.getApplicationLogLevel())).enableWebServerLogging(model.isEnableWebServerLogging()).webServerLogQuota(model.getWebServerLogQuota()).webServerRetentionPeriod(model.getWebServerRetentionPeriod()).enableDetailedErrorMessage(model.isEnableDetailedErrorMessage()).enableFailedRequestTracing(model.isEnableFailedRequestTracing()).build();
    return getAzureAppServiceClient(model.getSubscriptionId()).webapp(model.getResourceGroup(), model.getWebAppName()).create().withName(model.getWebAppName()).withResourceGroup(resourceGroup.getName()).withPlan(appServicePlan.id()).withRuntime(model.getRuntime()).withDiagnosticConfig(diagnosticConfig).commit();
}
Also used : AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) DiagnosticConfig(com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with DiagnosticConfig

use of com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig in project azure-tools-for-java by Microsoft.

the class AppServiceMonitorPanel method setData.

@Override
public void setData(final MonitorConfig data) {
    if (titleApplicationInsights.isVisible()) {
        if (data.getApplicationInsightsConfig() != null) {
            rdoEnableApplicationLog.setSelected(true);
            applicationInsightsComboBox.setValue(data.getApplicationInsightsConfig());
        } else {
            rdoDisableApplicationLog.setSelected(true);
            applicationInsightsComboBox.setSelectedItem(null);
        }
    }
    if (titleAppServiceLog.isVisible()) {
        final DiagnosticConfig diagnosticConfig = data.getDiagnosticConfig();
        if (lblWebServerLog.isVisible()) {
            rdoEnableWebServerLog.setSelected(diagnosticConfig.isEnableWebServerLogging());
            txtQuota.setValue(diagnosticConfig.getWebServerLogQuota());
            txtRetention.setValue(diagnosticConfig.getWebServerRetentionPeriod());
            rdoEnableDetailError.setSelected(diagnosticConfig.isEnableDetailedErrorMessage());
            rdoEnableFailedRequest.setSelected(diagnosticConfig.isEnableFailedRequestTracing());
        }
        if (lblApplicationInsights.isVisible()) {
            rdoEnableApplicationLog.setSelected(diagnosticConfig.isEnableApplicationLog());
            cbLogLevel.setSelectedItem(diagnosticConfig.getApplicationLogLevel());
        }
    }
    this.repaint();
}
Also used : DiagnosticConfig(com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig)

Example 3 with DiagnosticConfig

use of com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig in project azure-tools-for-java by Microsoft.

the class AppServiceMonitorPanel method getData.

@Override
public MonitorConfig getData() {
    final ApplicationInsightsConfig insightsConfig = (rdoEnableApplicationInsights.isSelected() && titleApplicationInsights.isVisible()) ? applicationInsightsComboBox.getValue() : null;
    final DiagnosticConfig diagnosticConfig = DiagnosticConfig.builder().enableWebServerLogging(rdoEnableWebServerLog.isSelected() && lblWebServerLog.isVisible()).webServerLogQuota(txtQuota.getValue()).webServerRetentionPeriod(txtRetention.getValue()).enableDetailedErrorMessage(rdoEnableDetailError.isSelected()).enableFailedRequestTracing(rdoEnableFailedRequest.isSelected()).enableApplicationLog(rdoEnableApplicationLog.isSelected() && lblApplicationLog.isVisible()).applicationLogLevel(cbLogLevel.getValue()).build();
    return MonitorConfig.builder().applicationInsightsConfig(insightsConfig).diagnosticConfig(diagnosticConfig).build();
}
Also used : ApplicationInsightsConfig(com.microsoft.azure.toolkit.lib.appservice.ApplicationInsightsConfig) DiagnosticConfig(com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig)

Example 4 with DiagnosticConfig

use of com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig in project azure-tools-for-java by Microsoft.

the class WebAppService method convertConfig2Settings.

@AzureOperation(name = "webapp.init_config", type = AzureOperation.Type.TASK)
public static WebAppSettingModel convertConfig2Settings(final WebAppConfig config) {
    final WebAppSettingModel settings = new WebAppSettingModel();
    settings.setSubscriptionId(config.getSubscription().getId());
    // creating if id is empty
    settings.setCreatingResGrp(config.getResourceGroup() instanceof Draft || StringUtils.isEmpty(config.getResourceGroup().getId()));
    settings.setResourceGroup(config.getResourceGroup().getName());
    settings.setWebAppName(config.getName());
    settings.setRegion(config.getRegion().getName());
    settings.saveRuntime(config.getRuntime());
    // creating if id is empty
    settings.setCreatingAppServicePlan(config.getServicePlan() instanceof Draft || StringUtils.isEmpty(config.getServicePlan().getId()));
    if (settings.isCreatingAppServicePlan()) {
        settings.setAppServicePlanName(config.getServicePlan().getName());
    } else {
        settings.setAppServicePlanId(config.getServicePlan().getId());
    }
    settings.setPricing(config.getServicePlan().getPricingTier().getSize());
    final MonitorConfig monitorConfig = config.getMonitorConfig();
    if (monitorConfig != null) {
        final DiagnosticConfig diagnosticConfig = monitorConfig.getDiagnosticConfig();
        settings.setEnableApplicationLog(diagnosticConfig.isEnableApplicationLog());
        settings.setApplicationLogLevel(diagnosticConfig.getApplicationLogLevel() == null ? null : diagnosticConfig.getApplicationLogLevel().getValue());
        settings.setEnableWebServerLogging(diagnosticConfig.isEnableWebServerLogging());
        settings.setWebServerLogQuota(diagnosticConfig.getWebServerLogQuota());
        settings.setWebServerRetentionPeriod(diagnosticConfig.getWebServerRetentionPeriod());
        settings.setEnableDetailedErrorMessage(diagnosticConfig.isEnableDetailedErrorMessage());
        settings.setEnableFailedRequestTracing(diagnosticConfig.isEnableFailedRequestTracing());
    }
    settings.setTargetName(config.getApplication() == null ? null : config.getApplication().toFile().getName());
    settings.setTargetPath(config.getApplication() == null ? null : config.getApplication().toString());
    return settings;
}
Also used : Draft(com.microsoft.azure.toolkit.intellij.common.Draft) WebAppSettingModel(com.microsoft.azuretools.core.mvp.model.webapp.WebAppSettingModel) DiagnosticConfig(com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig) MonitorConfig(com.microsoft.azure.toolkit.lib.appservice.MonitorConfig) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

DiagnosticConfig (com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig)4 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 Draft (com.microsoft.azure.toolkit.intellij.common.Draft)1 ApplicationInsightsConfig (com.microsoft.azure.toolkit.lib.appservice.ApplicationInsightsConfig)1 MonitorConfig (com.microsoft.azure.toolkit.lib.appservice.MonitorConfig)1 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)1 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)1 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)1 WebAppSettingModel (com.microsoft.azuretools.core.mvp.model.webapp.WebAppSettingModel)1