Search in sources :

Example 1 with IAppServicePlan

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

the class PublishWebAppOnLinuxDialog method apply.

private void apply() {
    model.setDockerFilePath(cpAcr.getDockerfilePath());
    // set ACR info
    model.setPrivateRegistryImageSetting(new PrivateRegistryImageSetting(cpAcr.getServerUrl(), cpAcr.getUserName(), cpAcr.getPassword(), cpAcr.getImageTag(), cpAcr.getStartupFile()));
    // set target
    model.setTargetPath(targetPath);
    model.setTargetName(Paths.get(targetPath).getFileName().toString());
    // set web app info
    if (rdoExistingWebApp.getSelection()) {
        // existing web app
        model.setCreatingNewWebAppOnLinux(false);
        IWebApp selectedWebApp = getSelectedWebApp();
        if (selectedWebApp != null) {
            model.setWebAppId(selectedWebApp.id());
            model.setWebAppName(selectedWebApp.name());
            model.setSubscriptionId(selectedWebApp.subscriptionId());
            model.setResourceGroupName(selectedWebApp.resourceGroup());
        } else {
            model.setWebAppId(null);
            model.setWebAppName(null);
            model.setSubscriptionId(null);
            model.setResourceGroupName(null);
        }
    } else if (rdoNewWebApp.getSelection()) {
        // create new web app
        model.setCreatingNewWebAppOnLinux(true);
        model.setWebAppId("");
        model.setWebAppName(cpNew.txtAppName.getText());
        Subscription selectedSubscription = getSelectedSubscription();
        if (selectedSubscription != null) {
            model.setSubscriptionId(selectedSubscription.getId());
        }
        // resource group
        if (cpNew.rdoExistingResourceGroup.getSelection()) {
            // existing RG
            model.setCreatingNewResourceGroup(false);
            ResourceGroup selectedRg = getSelectedResourceGroup();
            if (selectedRg != null) {
                model.setResourceGroupName(selectedRg.getName());
            } else {
                model.setResourceGroupName(null);
            }
        } else if (cpNew.rdoNewResourceGroup.getSelection()) {
            // new RG
            model.setCreatingNewResourceGroup(true);
            model.setResourceGroupName(cpNew.txtNewResourceGroupName.getText());
        }
        // app service plan
        if (cpNew.rdoNewAppServicePlan.getSelection()) {
            model.setCreatingNewAppServicePlan(true);
            model.setAppServicePlanName(cpNew.txtAppServicePlanName.getText());
            Region selectedLocation = getSelectedLocation();
            if (selectedLocation != null) {
                model.setLocationName(selectedLocation.getLabel());
            } else {
                model.setLocationName(null);
            }
            PricingTier selectedPricingTier = getSelectedPricingTier();
            if (selectedPricingTier != null) {
                model.setPricingSkuTier(selectedPricingTier.getTier());
                model.setPricingSkuSize(selectedPricingTier.getSize());
            } else {
                model.setPricingSkuTier(null);
                model.setPricingSkuSize(null);
            }
        } else if (cpNew.rdoExistingAppServicePlan.getSelection()) {
            model.setCreatingNewAppServicePlan(false);
            IAppServicePlan selectedAsp = getSelectedAppServicePlan();
            if (selectedAsp != null) {
                model.setAppServicePlanId(selectedAsp.id());
            } else {
                model.setAppServicePlanId(null);
            }
        }
    }
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)

Example 2 with IAppServicePlan

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

the class PublishWebAppOnLinuxDialog method getSelectedAppServicePlan.

private IAppServicePlan getSelectedAppServicePlan() {
    IAppServicePlan asp = null;
    int index = cpNew.cbExistingAppServicePlan.getSelectionIndex();
    if (appServicePlanList != null && index >= 0 && index < appServicePlanList.size()) {
        asp = appServicePlanList.get(index);
    }
    return asp;
}
Also used : IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) Point(org.eclipse.swt.graphics.Point)

Example 3 with IAppServicePlan

use of com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan 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 4 with IAppServicePlan

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

the class AzureWebAppMvpModel method getOrCreateAppServicePlan.

private IAppServicePlan getOrCreateAppServicePlan(AppServicePlanEntity servicePlanEntity) {
    final AzureAppService az = getAzureAppServiceClient(servicePlanEntity.getSubscriptionId());
    final IAppServicePlan appServicePlan = az.appServicePlan(servicePlanEntity);
    if (appServicePlan.exists()) {
        return appServicePlan;
    }
    return appServicePlan.create().withName(servicePlanEntity.getName()).withResourceGroup(servicePlanEntity.getResourceGroup()).withRegion(com.microsoft.azure.toolkit.lib.common.model.Region.fromName(servicePlanEntity.getRegion())).withPricingTier(servicePlanEntity.getPricingTier()).withOperatingSystem(servicePlanEntity.getOperatingSystem()).commit();
}
Also used : AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)

Example 5 with IAppServicePlan

use of com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan 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)

Aggregations

IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)12 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)5 Point (org.eclipse.swt.graphics.Point)4 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)3 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)3 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)2 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)2 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)2 Region (com.microsoft.azure.toolkit.lib.common.model.Region)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 Azure (com.microsoft.azure.toolkit.lib.Azure)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 OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)1 Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)1 WebContainer (com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)1 IFunctionApp (com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp)1 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)1 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)1