Search in sources :

Example 6 with IAppServicePlan

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

the class FunctionAppService method createFunctionApp.

public IFunctionApp createFunctionApp(final FunctionAppConfig config) {
    AzureTelemetry.getActionContext().setProperty(CREATE_NEW_FUNCTION_APP, String.valueOf(true));
    final ResourceGroup resourceGroup = getOrCreateResourceGroup(config);
    final IAppServicePlan appServicePlan = getOrCreateAppServicePlan(config);
    AzureMessager.getMessager().info(String.format(CREATE_FUNCTION_APP, config.getName()));
    final Map<String, String> appSettings = getAppSettings(config);
    // get/create ai instances only if user didn't specify ai connection string in app settings
    AzureTelemetry.getActionContext().setProperty(DISABLE_APP_INSIGHTS, String.valueOf(config.getMonitorConfig().getApplicationInsightsConfig() == null));
    bindApplicationInsights(appSettings, config);
    final IFunctionApp result = Azure.az(AzureAppService.class).subscription(config.getSubscription()).functionApp(resourceGroup.getName(), config.getName()).create().withName(config.getName()).withResourceGroup(resourceGroup.getName()).withPlan(appServicePlan.id()).withRuntime(config.getRuntime()).withAppSettings(appSettings).withDiagnosticConfig(config.getMonitorConfig().getDiagnosticConfig()).commit();
    AzureMessager.getMessager().info(String.format(CREATE_FUNCTION_APP_DONE, result.name()));
    return result;
}
Also used : IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 7 with IAppServicePlan

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

the class AppServiceCreateDialog method fillAppServicePlans.

protected void fillAppServicePlans() {
    Subscription selectedSubscription = getSelectedSubscription();
    if (selectedSubscription == null) {
        return;
    }
    OperatingSystem os = getSelectedOS();
    setComboRefreshingStatus(comboAppServicePlan, true);
    Mono.fromCallable(() -> {
        return Azure.az(AzureAppService.class).appServicePlans(selectedSubscription.getId(), false).stream().filter(asp -> asp.entity().getOperatingSystem() == null || asp.entity().getOperatingSystem() == os).collect(Collectors.toList());
    }).subscribeOn(Schedulers.boundedElastic()).subscribe(appServicePlans -> {
        appServicePlans.sort(Comparator.comparing(IAppServicePlan::name));
        DefaultLoader.getIdeHelper().invokeLater(() -> {
            setComboRefreshingStatus(comboAppServicePlan, false);
            binderAppServicePlan = new ArrayList<>();
            for (IAppServicePlan asp : appServicePlans) {
                binderAppServicePlan.add(asp);
                comboAppServicePlan.add(asp.name());
            }
            if (comboAppServicePlan.getItemCount() > 0) {
                comboAppServicePlan.select(0);
            }
            String aspName = CommonUtils.getPreference(CommonUtils.ASP_NAME);
            CommonUtils.selectComboIndex(comboAppServicePlan, aspName);
            fillAppServicePlansDetails();
        });
    });
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Arrays(java.util.Arrays) Azure(com.microsoft.azure.toolkit.lib.Azure) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) FocusEvent(org.eclipse.swt.events.FocusEvent) StringUtils(org.apache.commons.lang3.StringUtils) Point(org.eclipse.swt.graphics.Point) CommonUtils(com.microsoft.azuretools.webapp.util.CommonUtils) PluginUtil(com.microsoft.azuretools.core.utils.PluginUtil) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) TraverseEvent(org.eclipse.swt.events.TraverseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ILog(org.eclipse.core.runtime.ILog) PlatformUI(org.eclipse.ui.PlatformUI) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Status(org.eclipse.core.runtime.Status) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) TraverseListener(org.eclipse.swt.events.TraverseListener) Window(org.eclipse.jface.window.Window) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) SWT(org.eclipse.swt.SWT) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) SelectionListener(org.eclipse.swt.events.SelectionListener) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) SimpleDateFormat(java.text.SimpleDateFormat) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) Listener(org.eclipse.swt.widgets.Listener) ErrorWindow(com.microsoft.azuretools.core.ui.ErrorWindow) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) Link(org.eclipse.swt.widgets.Link) Nullable(javax.annotation.Nullable) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) TableItem(org.eclipse.swt.widgets.TableItem) FontDescriptor(org.eclipse.jface.resource.FontDescriptor) Shell(org.eclipse.swt.widgets.Shell) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) ASP_CREATE_PRICING(com.microsoft.azuretools.webapp.util.CommonUtils.ASP_CREATE_PRICING) ProgressDialog(com.microsoft.azuretools.core.utils.ProgressDialog) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridLayout(org.eclipse.swt.layout.GridLayout) TableEditor(org.eclipse.swt.custom.TableEditor) Activator(com.microsoft.azuretools.webapp.Activator) URL(java.net.URL) Date(java.util.Date) TableColumn(org.eclipse.swt.widgets.TableColumn) CommonUtils.getSelectedItem(com.microsoft.azuretools.webapp.util.CommonUtils.getSelectedItem) MavenUtils(com.microsoft.azuretools.core.utils.MavenUtils) IStatus(org.eclipse.core.runtime.IStatus) WebContainer(com.microsoft.azure.toolkit.lib.appservice.model.WebContainer) AzureWebAppMvpModel(com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel) Button(org.eclipse.swt.widgets.Button) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) ISharedImages(org.eclipse.ui.ISharedImages) List(java.util.List) CREATE_WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_WEBAPP) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) AzureMvpModel(com.microsoft.azuretools.core.mvp.model.AzureMvpModel) Label(org.eclipse.swt.widgets.Label) WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.WEBAPP) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) HashMap(java.util.HashMap) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Table(org.eclipse.swt.widgets.Table) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) Event(org.eclipse.swt.widgets.Event) Region(com.microsoft.azure.toolkit.lib.common.model.Region) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Schedulers(reactor.core.scheduler.Schedulers) LinkedList(java.util.LinkedList) FillLayout(org.eclipse.swt.layout.FillLayout) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) Combo(org.eclipse.swt.widgets.Combo) MalformedURLException(java.net.MalformedURLException) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) Group(org.eclipse.swt.widgets.Group) ASP_CREATE_LOCATION(com.microsoft.azuretools.webapp.util.CommonUtils.ASP_CREATE_LOCATION) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) AccessibilityUtils(com.microsoft.azuretools.core.utils.AccessibilityUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Comparator(java.util.Comparator) FocusAdapter(org.eclipse.swt.events.FocusAdapter) WebAppSettingModel(com.microsoft.azuretools.core.mvp.model.webapp.WebAppSettingModel) Control(org.eclipse.swt.widgets.Control) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 8 with IAppServicePlan

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

the class AppServiceCreateDialog method fillAppServicePlansDetails.

protected void fillAppServicePlansDetails() {
    int i = comboAppServicePlan.getSelectionIndex();
    if (i < 0) {
        lblAppSevicePlanLocation.setText(NOT_AVAILABLE);
        lblAppServicePlanPricingTier.setText(NOT_AVAILABLE);
    } else {
        IAppServicePlan asp = binderAppServicePlan.get(i);
        lblAppSevicePlanLocation.setText(asp.entity().getRegion());
        lblAppServicePlanPricingTier.setText(asp.entity().getPricingTier().toString());
    }
}
Also used : IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) Point(org.eclipse.swt.graphics.Point)

Example 9 with IAppServicePlan

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

the class PublishWebAppOnLinuxDialog method onAppServicePlanSelection.

private void onAppServicePlanSelection() {
    cpNew.lblLocationValue.setText("N/A");
    cpNew.lblPricingTierValue.setText("N/A");
    IAppServicePlan asp = getSelectedAppServicePlan();
    if (asp != null) {
        cpNew.lblLocationValue.setText(asp.entity().getRegion());
        cpNew.lblPricingTierValue.setText(asp.entity().getPricingTier().getSize());
    }
}
Also used : IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)

Example 10 with IAppServicePlan

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

the class PublishWebAppOnLinuxDialog method renderAppServicePlanList.

@Override
public void renderAppServicePlanList(List<IAppServicePlan> list) {
    // TODO Auto-generated method stub
    appServicePlanList = list;
    cpNew.cbExistingAppServicePlan.removeAll();
    for (IAppServicePlan asp : appServicePlanList) {
        cpNew.cbExistingAppServicePlan.add(asp.name());
    }
    if (cpNew.cbExistingAppServicePlan.getItemCount() > 0) {
        cpNew.cbExistingAppServicePlan.select(0);
    }
    onAppServicePlanSelection();
}
Also used : IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)

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