use of com.microsoft.azure.toolkit.intellij.arm.action.CreateDeploymentAction.NOTIFY_CREATE_DEPLOYMENT_FAIL 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);
}
Aggregations