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());
}
}
}
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;
}
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);
}
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());
}
}
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);
}
}
});
}
Aggregations