Search in sources :

Example 1 with ResourceGroup

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

the class PublishWebAppOnLinuxDialog method onResourceGroupSelection.

private void onResourceGroupSelection() {
    cpNew.cbExistingAppServicePlan.removeAll();
    cpNew.lblLocationValue.setText("");
    cpNew.lblPricingTierValue.setText("");
    Subscription sub = getSelectedSubscription();
    ResourceGroup rg = getSelectedResourceGroup();
    if (sub != null && rg != null) {
        // TODO: a minor bug here, if rg is null, related labels should be set to "N/A"
        webAppOnLinuxDeployPresenter.onLoadAppServicePlan(sub.getId(), rg.getName());
    }
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 2 with ResourceGroup

use of com.microsoft.azure.toolkit.lib.common.model.ResourceGroup 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 3 with ResourceGroup

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

the class PublishWebAppOnLinuxDialog method getSelectedResourceGroup.

private ResourceGroup getSelectedResourceGroup() {
    ResourceGroup rg = null;
    int rgIndex = cpNew.cbExistingResourceGroup.getSelectionIndex();
    if (resourceGroupList != null && rgIndex >= 0 && rgIndex < resourceGroupList.size()) {
        rg = resourceGroupList.get(rgIndex);
    }
    return rg;
}
Also used : ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) Point(org.eclipse.swt.graphics.Point)

Example 4 with ResourceGroup

use of com.microsoft.azure.toolkit.lib.common.model.ResourceGroup 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 5 with ResourceGroup

use of com.microsoft.azure.toolkit.lib.common.model.ResourceGroup 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

ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)24 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)12 Region (com.microsoft.azure.toolkit.lib.common.model.Region)6 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)5 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)3 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)3 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)3 Draft (com.microsoft.azure.toolkit.intellij.common.Draft)2 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)2 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)2 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)2 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)2 DraftResourceGroup (com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup)2 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 MessageType (com.intellij.openapi.ui.MessageType)1 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)1 StatusBar (com.intellij.openapi.wm.StatusBar)1 WindowManager (com.intellij.openapi.wm.WindowManager)1