Search in sources :

Example 1 with AppServicePlanEntity

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

the class AzureWebAppMvpModel method createAzureWebAppWithPrivateRegistryImage.

/**
 * API to create Web App on Docker.
 *
 * @param model parameters
 * @return instance of created WebApp
 */
@AzureOperation(name = "docker.create_from_private_image", params = { "model.getWebAppName()", "model.getSubscriptionId()", "model.getPrivateRegistryImageSetting().getImageNameWithTag()" }, type = AzureOperation.Type.SERVICE)
public IWebApp createAzureWebAppWithPrivateRegistryImage(@NotNull WebAppOnLinuxDeployModel model) {
    final ResourceGroup resourceGroup = getOrCreateResourceGroup(model.getSubscriptionId(), model.getResourceGroupName(), model.getLocationName());
    final AppServicePlanEntity servicePlanEntity = AppServicePlanEntity.builder().id(model.getAppServicePlanId()).subscriptionId(model.getSubscriptionId()).name(model.getAppServicePlanName()).resourceGroup(model.getResourceGroupName()).region(model.getLocationName()).operatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem.DOCKER).pricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier.fromString(model.getPricingSkuSize())).build();
    final IAppServicePlan appServicePlan = getOrCreateAppServicePlan(servicePlanEntity);
    final PrivateRegistryImageSetting pr = model.getPrivateRegistryImageSetting();
    // todo: support start up file in docker configuration
    final DockerConfiguration dockerConfiguration = DockerConfiguration.builder().image(pr.getImageTagWithServerUrl()).registryUrl(pr.getServerUrl()).userName(pr.getUsername()).password(pr.getPassword()).startUpCommand(pr.getStartupFile()).build();
    return getAzureAppServiceClient(model.getSubscriptionId()).webapp(model.getResourceGroupName(), model.getWebAppName()).create().withName(model.getWebAppName()).withResourceGroup(resourceGroup.getName()).withPlan(appServicePlan.id()).withRuntime(Runtime.DOCKER).withDockerConfiguration(dockerConfiguration).commit();
}
Also used : AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) DockerConfiguration(com.microsoft.azure.toolkit.lib.appservice.model.DockerConfiguration) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with AppServicePlanEntity

use of com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity 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 3 with AppServicePlanEntity

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

the class AppServiceInfoAdvancedPanel method onServicePlanChanged.

private void onServicePlanChanged(final ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        final AppServicePlanEntity plan = (AppServicePlanEntity) e.getItem();
        if (plan == null || plan.getPricingTier() == null) {
            return;
        }
        final String pricing = Objects.equals(plan.getPricingTier(), PricingTier.CONSUMPTION) ? "Consumption" : String.format("%s_%s", plan.getPricingTier().getTier(), plan.getPricingTier().getSize());
        this.textSku.setText(pricing);
    } else if (e.getStateChange() == ItemEvent.DESELECTED) {
        this.textSku.setText(NOT_APPLICABLE);
    }
}
Also used : AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)

Example 4 with AppServicePlanEntity

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

the class WebAppBasePropertyViewPresenter method generateProperty.

protected <T extends AppServiceBaseEntity> WebAppProperty generateProperty(@Nonnull final IAppService<T> appService, @Nonnull final IAppServicePlan plan) {
    final AppServiceBaseEntity appServiceEntity = appService.entity();
    final AppServicePlanEntity planEntity = plan.entity();
    final Map<String, String> appSettingsMap = appServiceEntity.getAppSettings();
    final Map<String, Object> propertyMap = new HashMap<>();
    propertyMap.put(KEY_NAME, appServiceEntity.getName());
    propertyMap.put(KEY_RESOURCE_GRP, appServiceEntity.getResourceGroup());
    propertyMap.put(KEY_LOCATION, appServiceEntity.getRegion().getLabel());
    propertyMap.put(KEY_SUB_ID, appService.subscriptionId());
    propertyMap.put(KEY_STATUS, appService.state());
    propertyMap.put(KEY_PLAN, plan.name());
    propertyMap.put(KEY_URL, appService.hostName());
    final PricingTier pricingTier = planEntity.getPricingTier();
    propertyMap.put(KEY_PRICING, String.format("%s_%s", pricingTier.getTier(), pricingTier.getSize()));
    final Runtime runtime = appService.getRuntime();
    final JavaVersion javaVersion = runtime.getJavaVersion();
    if (javaVersion != null && ObjectUtils.notEqual(javaVersion, JavaVersion.OFF)) {
        propertyMap.put(KEY_JAVA_VERSION, javaVersion.getValue());
        propertyMap.put(KEY_JAVA_CONTAINER, runtime.getWebContainer().getValue());
    }
    propertyMap.put(KEY_OPERATING_SYS, runtime.getOperatingSystem());
    propertyMap.put(KEY_APP_SETTING, appSettingsMap);
    return new WebAppProperty(propertyMap);
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AppServiceBaseEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity) AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) HashMap(java.util.HashMap) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) WebAppProperty(com.microsoft.azuretools.core.mvp.ui.webapp.WebAppProperty)

Example 5 with AppServicePlanEntity

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

the class AppServiceInfoAdvancedPanel method getData.

@Override
public T getData() {
    final Subscription subscription = this.selectorSubscription.getValue();
    final ResourceGroup resourceGroup = this.selectorGroup.getValue();
    final String name = this.textName.getValue();
    final Runtime runtime = this.selectorRuntime.getValue();
    final Region region = this.selectorRegion.getValue();
    final AppServicePlanEntity servicePlan = this.selectorServicePlan.getValue();
    final AzureArtifact artifact = this.selectorApplication.getValue();
    final T config = supplier.get();
    config.setSubscription(subscription);
    config.setResourceGroup(resourceGroup);
    config.setName(name);
    config.setRuntime(runtime);
    config.setRegion(region);
    config.setServicePlan(servicePlan);
    if (Objects.nonNull(artifact)) {
        final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.project);
        final String path = manager.getFileForDeployment(this.selectorApplication.getValue());
        config.setApplication(Paths.get(path));
    }
    return config;
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AzureArtifact(com.microsoft.azure.toolkit.intellij.common.AzureArtifact) AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Aggregations

AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)5 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)3 Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)2 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 AzureArtifact (com.microsoft.azure.toolkit.intellij.common.AzureArtifact)1 AzureArtifactManager (com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager)1 AppServiceBaseEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity)1 DiagnosticConfig (com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig)1 DockerConfiguration (com.microsoft.azure.toolkit.lib.appservice.model.DockerConfiguration)1 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)1 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)1 Region (com.microsoft.azure.toolkit.lib.common.model.Region)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 WebAppProperty (com.microsoft.azuretools.core.mvp.ui.webapp.WebAppProperty)1 HashMap (java.util.HashMap)1