Search in sources :

Example 6 with ResourceGroup

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

the class SettingPanel method onComboResourceGroupSelection.

private void onComboResourceGroupSelection(ItemEvent event) {
    if (event.getStateChange() == ItemEvent.SELECTED) {
        cbExistAppServicePlan.removeAllItems();
        lblLocation.setText("");
        lblPricing.setText("");
        final Subscription sub = (Subscription) comboSubscription.getSelectedItem();
        final ResourceGroup rg = (ResourceGroup) comboResourceGroup.getSelectedItem();
        if (sub != null && rg != null) {
            updateAppServicePlanList(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 7 with ResourceGroup

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

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

the class CreateDeploymentForm method doOKAction.

@Override
protected void doOKAction() {
    deploymentName = deploymentNameTextField.getText();
    final AzureString title = AzureOperationBundle.title("arm|deployment.deploy", deploymentName);
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        EventUtil.executeWithLog(TelemetryConstants.ARM, TelemetryConstants.CREATE_DEPLOYMENT, (operation -> {
            Subscription subs = (Subscription) subscriptionCb.getSelectedItem();
            com.microsoft.azure.management.Azure azure = AuthMethodManager.getInstance().getAzureClient(subs.getId());
            WithTemplate template;
            if (createNewRgButton.isSelected()) {
                rgName = rgNameTextFiled.getText();
                final Region region = (Region) regionCb.getSelectedItem();
                template = azure.deployments().define(deploymentName).withNewResourceGroup(rgNameTextFiled.getText(), com.microsoft.azure.management.resources.fluentcore.arm.Region.fromName(region.getName()));
            } else {
                ResourceGroup rg = (ResourceGroup) rgNameCb.getSelectedItem();
                List<ResourceEx<Deployment>> deployments = AzureMvpModel.getInstance().getDeploymentByRgName(subs.getId(), rg.getName());
                boolean isExist = deployments.parallelStream().anyMatch(deployment -> deployment.getResource().name().equals(deploymentName));
                if (isExist) {
                    throw new RuntimeException(DUPLICATED_DEPLOYMENT_NAME);
                }
                rgName = rg.getName();
                template = azure.deployments().define(deploymentName).withExistingResourceGroup(rg.getName());
            }
            String fileText = templateTextField.getText();
            String content = IOUtils.toString(new FileReader(fileText));
            String parametersPath = parametersTextField.getText();
            String parameters = StringUtils.isEmpty(parametersPath) ? "{}" : IOUtils.toString(new FileReader(parametersPath));
            parameters = DeploymentUtils.parseParameters(parameters);
            template.withTemplate(content).withParameters(parameters).withMode(DeploymentMode.INCREMENTAL).create();
            UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_SUCCESS, MessageType.INFO);
            updateUI();
        }), (ex) -> {
            UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_FAIL + ", " + ex.getMessage(), MessageType.ERROR);
            updateUI();
        });
    }));
    close(DialogWrapper.OK_EXIT_CODE, true);
}
Also used : AuthMethodManager(com.microsoft.azuretools.authmanage.AuthMethodManager) Azure(com.microsoft.azure.toolkit.lib.Azure) NOTIFY_CREATE_DEPLOYMENT_FAIL(com.microsoft.azure.toolkit.intellij.arm.action.CreateDeploymentAction.NOTIFY_CREATE_DEPLOYMENT_FAIL) MessageType(com.intellij.openapi.ui.MessageType) SimpleListCellRenderer(com.intellij.ui.SimpleListCellRenderer) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) StringUtils(org.apache.commons.lang3.StringUtils) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) NOTIFY_CREATE_DEPLOYMENT_SUCCESS(com.microsoft.azure.toolkit.intellij.arm.action.CreateDeploymentAction.NOTIFY_CREATE_DEPLOYMENT_SUCCESS) StatusBar(com.intellij.openapi.wm.StatusBar) WithTemplate(com.microsoft.azure.management.resources.Deployment.DefinitionStages.WithTemplate) ResourceManagementNode(com.microsoft.tooling.msservices.serviceexplorer.azure.arm.ResourceManagementNode) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) JComboBox(javax.swing.JComboBox) ResourceEx(com.microsoft.azuretools.core.mvp.model.ResourceEx) WindowManager(com.intellij.openapi.wm.WindowManager) JRadioButton(javax.swing.JRadioButton) RegionComboBox(com.microsoft.azure.toolkit.intellij.common.component.RegionComboBox) IOUtils(org.apache.commons.io.IOUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) AzureMvpModel(com.microsoft.azuretools.core.mvp.model.AzureMvpModel) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) JPanel(javax.swing.JPanel) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) JTextField(javax.swing.JTextField) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) AzureOperationBundle(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Region(com.microsoft.azure.toolkit.lib.common.model.Region) DeploymentMode(com.microsoft.azure.management.resources.DeploymentMode) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) JComponent(javax.swing.JComponent) Deployment(com.microsoft.azure.management.resources.Deployment) ButtonGroup(javax.swing.ButtonGroup) UIUtils(com.microsoft.intellij.ui.util.UIUtils) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) JList(javax.swing.JList) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) JLabel(javax.swing.JLabel) FileReader(java.io.FileReader) SubscriptionComboBox(com.microsoft.azure.toolkit.intellij.common.component.SubscriptionComboBox) BROWSE_TEMPLATE_SAMPLES(com.microsoft.azuretools.telemetry.TelemetryConstants.BROWSE_TEMPLATE_SAMPLES) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) WithTemplate(com.microsoft.azure.management.resources.Deployment.DefinitionStages.WithTemplate) Region(com.microsoft.azure.toolkit.lib.common.model.Region) FileReader(java.io.FileReader) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceEx(com.microsoft.azuretools.core.mvp.model.ResourceEx) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 9 with ResourceGroup

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

the class CreateDeploymentForm method fillResourceGroup.

private void fillResourceGroup() {
    if (subscriptionCb.getSelectedItem() == null) {
        return;
    }
    String sid = ((Subscription) subscriptionCb.getSelectedItem()).getId();
    rgNameCb.removeAllItems();
    for (ResourceEx<ResourceGroup> rg : AzureMvpModel.getInstance().getResourceGroups(sid)) {
        rgNameCb.addItem(rg.getResource());
    }
}
Also used : AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 10 with ResourceGroup

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

the class CreateArmStorageAccountForm method fillGroups.

public void fillGroups() {
    final Subscription subs = (Subscription) subscriptionComboBox.getData(subscriptionComboBox.getText());
    List<ResourceGroup> resourceGroups = Azure.az(AzureGroup.class).list(subs.getId(), true);
    List<String> sortedGroups = resourceGroups.stream().map(ResourceGroup::getName).sorted().collect(Collectors.toList());
    AzureTaskManager.getInstance().runLater(new Runnable() {

        @Override
        public void run() {
            final Vector<Object> vector = new Vector<Object>();
            vector.addAll(sortedGroups);
            resourceGroupViewer.setInput(vector);
            if (sortedGroups.size() > 0) {
                resourceGrpCombo.select(0);
            }
        }
    });
}
Also used : AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) Vector(java.util.Vector) DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

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