Source:
<code>public NodeAndInitialCredentials<VMDeployment> createNodeWithGroupEncodedIntoName( final String group, final String name, final Template template) { final String location = template.getLocation().getId(); DeploymentTemplateBuilder deploymentTemplateBuilder = api.deploymentTemplateFactory().create(group, name, template); final String loginUser = deploymentTemplateBuilder.getLoginUserUsername(); final String loginPassword = deploymentTemplateBuilder.getLoginPassword(); DeploymentBody deploymentTemplateBody = deploymentTemplateBuilder.getDeploymentTemplate(); DeploymentProperties properties = DeploymentProperties.create(deploymentTemplateBody); final String deploymentTemplate = UrlEscapers.urlFormParameterEscaper().escape(deploymentTemplateBuilder.getDeploymentTemplateJson(properties)); logger.debug("Deployment created with name: %s", name); final Set<VMDeployment> deployments = Sets.newHashSet(); ResourceGroupApi resourceGroupApi = api.getResourceGroupApi(); ResourceGroup resourceGroup = resourceGroupApi.get(azureGroup); final String resourceGroupName; if (resourceGroup == null){ final Map<String, String> tags = ImmutableMap.of("description", "jClouds managed VMs"); resourceGroupName = resourceGroupApi.create(azureGroup, location, tags).name(); } else { resourceGroupName = resourceGroup.name(); } if (!retry(new Predicate<String>() { @Override public boolean apply(final String name) { runningNumber++; Deployment deployment = api.getDeploymentApi(resourceGroupName).create(name, deploymentTemplate); if (deployment != null) { VMDeployment vmDeployment = new VMDeployment(); vmDeployment.deployment = deployment; deployments.add(vmDeployment); } else { logger.debug("Failed to create deployment!"); } return !deployments.isEmpty(); } }, azureComputeConstants.operationTimeout(), 1, SECONDS).apply(name)) { <START> final String illegalStateExceptionMessage = format("Deployment %s was not created within %sms so it will be destroyed.", <END> name, azureComputeConstants.operationTimeout()); logger.warn(illegalStateExceptionMessage); throw new IllegalStateException(illegalStateExceptionMessage); } final VMDeployment deployment = deployments.iterator().next(); return new NodeAndInitialCredentials<VMDeployment>(deployment, name, LoginCredentials.builder().user(loginUser).identity(loginUser).password(loginPassword).authenticateSudo(true).build()); }</code><technical_language>destroying deployment? destroyDeployment takes care of deleting cloud resources created for this deployment</technical_language>

Target:
public NodeAndInitialCredentials<VMDeployment> createNodeWithGroupEncodedIntoName( final String group, final String name, final Template template) { DeploymentTemplateBuilder deploymentTemplateBuilder = api.deploymentTemplateFactory().create(group, name, template); final String loginUser = DeploymentTemplateBuilder.getLoginUserUsername(); final String loginPassword = DeploymentTemplateBuilder.getLoginPassword(); DeploymentBody deploymentTemplateBody = deploymentTemplateBuilder.getDeploymentTemplate(); DeploymentProperties properties = DeploymentProperties.create(deploymentTemplateBody); final String deploymentTemplate = UrlEscapers.urlFormParameterEscaper().escape(deploymentTemplateBuilder.getDeploymentTemplateJson(properties)); logger.debug("Deployment created with name: %s group: %s", name, group); final Set<VMDeployment> deployments = Sets.newHashSet(); final DeploymentApi deploymentApi = api.getDeploymentApi(group); if (!retry(new Predicate<String>() { @Override public boolean apply(final String name) { Deployment deployment = deploymentApi.create(name, deploymentTemplate); if (deployment != null) { VMDeployment vmDeployment = new VMDeployment(); vmDeployment.deployment = deployment; deployments.add(vmDeployment); } else { logger.debug("Failed to create deployment!"); } return !deployments.isEmpty(); } }, azureComputeConstants.operationTimeout(), 1, SECONDS).apply(name)) { final String illegalStateExceptionMessage = format("Deployment %s was not created within %sms so it will be destroyed.", name, azureComputeConstants.operationTimeout()); logger.warn(illegalStateExceptionMessage); destroyNode(name); throw new IllegalStateException(illegalStateExceptionMessage); } final VMDeployment deployment = deployments.iterator().next(); return new NodeAndInitialCredentials<VMDeployment>(deployment, name, LoginCredentials.builder().user(loginUser).identity(loginUser).password(loginPassword).authenticateSudo(true).build()); }