use of com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan in project azure-tools-for-java by Microsoft.
the class PublishWebAppOnLinuxDialog method apply.
private void apply() {
model.setDockerFilePath(cpAcr.getDockerfilePath());
// set ACR info
model.setPrivateRegistryImageSetting(new PrivateRegistryImageSetting(cpAcr.getServerUrl(), cpAcr.getUserName(), cpAcr.getPassword(), cpAcr.getImageTag(), cpAcr.getStartupFile()));
// set target
model.setTargetPath(targetPath);
model.setTargetName(Paths.get(targetPath).getFileName().toString());
// set web app info
if (rdoExistingWebApp.getSelection()) {
// existing web app
model.setCreatingNewWebAppOnLinux(false);
IWebApp selectedWebApp = getSelectedWebApp();
if (selectedWebApp != null) {
model.setWebAppId(selectedWebApp.id());
model.setWebAppName(selectedWebApp.name());
model.setSubscriptionId(selectedWebApp.subscriptionId());
model.setResourceGroupName(selectedWebApp.resourceGroup());
} else {
model.setWebAppId(null);
model.setWebAppName(null);
model.setSubscriptionId(null);
model.setResourceGroupName(null);
}
} else if (rdoNewWebApp.getSelection()) {
// create new web app
model.setCreatingNewWebAppOnLinux(true);
model.setWebAppId("");
model.setWebAppName(cpNew.txtAppName.getText());
Subscription selectedSubscription = getSelectedSubscription();
if (selectedSubscription != null) {
model.setSubscriptionId(selectedSubscription.getId());
}
// resource group
if (cpNew.rdoExistingResourceGroup.getSelection()) {
// existing RG
model.setCreatingNewResourceGroup(false);
ResourceGroup selectedRg = getSelectedResourceGroup();
if (selectedRg != null) {
model.setResourceGroupName(selectedRg.getName());
} else {
model.setResourceGroupName(null);
}
} else if (cpNew.rdoNewResourceGroup.getSelection()) {
// new RG
model.setCreatingNewResourceGroup(true);
model.setResourceGroupName(cpNew.txtNewResourceGroupName.getText());
}
// app service plan
if (cpNew.rdoNewAppServicePlan.getSelection()) {
model.setCreatingNewAppServicePlan(true);
model.setAppServicePlanName(cpNew.txtAppServicePlanName.getText());
Region selectedLocation = getSelectedLocation();
if (selectedLocation != null) {
model.setLocationName(selectedLocation.getLabel());
} else {
model.setLocationName(null);
}
PricingTier selectedPricingTier = getSelectedPricingTier();
if (selectedPricingTier != null) {
model.setPricingSkuTier(selectedPricingTier.getTier());
model.setPricingSkuSize(selectedPricingTier.getSize());
} else {
model.setPricingSkuTier(null);
model.setPricingSkuSize(null);
}
} else if (cpNew.rdoExistingAppServicePlan.getSelection()) {
model.setCreatingNewAppServicePlan(false);
IAppServicePlan selectedAsp = getSelectedAppServicePlan();
if (selectedAsp != null) {
model.setAppServicePlanId(selectedAsp.id());
} else {
model.setAppServicePlanId(null);
}
}
}
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan in project azure-tools-for-java by Microsoft.
the class PublishWebAppOnLinuxDialog method getSelectedAppServicePlan.
private IAppServicePlan getSelectedAppServicePlan() {
IAppServicePlan asp = null;
int index = cpNew.cbExistingAppServicePlan.getSelectionIndex();
if (appServicePlanList != null && index >= 0 && index < appServicePlanList.size()) {
asp = appServicePlanList.get(index);
}
return asp;
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan in project azure-tools-for-java by Microsoft.
the class AzureWebAppMvpModel method createAzureWebAppWithPrivateRegistryImage.
/**
* API to create Web App on Docker.
*
* @param model parameters
* @return instance of created WebApp
*/
@AzureOperation(name = "docker.create_from_private_image", params = { "model.getWebAppName()", "model.getSubscriptionId()", "model.getPrivateRegistryImageSetting().getImageNameWithTag()" }, type = AzureOperation.Type.SERVICE)
public IWebApp createAzureWebAppWithPrivateRegistryImage(@NotNull WebAppOnLinuxDeployModel model) {
final ResourceGroup resourceGroup = getOrCreateResourceGroup(model.getSubscriptionId(), model.getResourceGroupName(), model.getLocationName());
final AppServicePlanEntity servicePlanEntity = AppServicePlanEntity.builder().id(model.getAppServicePlanId()).subscriptionId(model.getSubscriptionId()).name(model.getAppServicePlanName()).resourceGroup(model.getResourceGroupName()).region(model.getLocationName()).operatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem.DOCKER).pricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier.fromString(model.getPricingSkuSize())).build();
final IAppServicePlan appServicePlan = getOrCreateAppServicePlan(servicePlanEntity);
final PrivateRegistryImageSetting pr = model.getPrivateRegistryImageSetting();
// todo: support start up file in docker configuration
final DockerConfiguration dockerConfiguration = DockerConfiguration.builder().image(pr.getImageTagWithServerUrl()).registryUrl(pr.getServerUrl()).userName(pr.getUsername()).password(pr.getPassword()).startUpCommand(pr.getStartupFile()).build();
return getAzureAppServiceClient(model.getSubscriptionId()).webapp(model.getResourceGroupName(), model.getWebAppName()).create().withName(model.getWebAppName()).withResourceGroup(resourceGroup.getName()).withPlan(appServicePlan.id()).withRuntime(Runtime.DOCKER).withDockerConfiguration(dockerConfiguration).commit();
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan in project azure-tools-for-java by Microsoft.
the class AzureWebAppMvpModel method getOrCreateAppServicePlan.
private IAppServicePlan getOrCreateAppServicePlan(AppServicePlanEntity servicePlanEntity) {
final AzureAppService az = getAzureAppServiceClient(servicePlanEntity.getSubscriptionId());
final IAppServicePlan appServicePlan = az.appServicePlan(servicePlanEntity);
if (appServicePlan.exists()) {
return appServicePlan;
}
return appServicePlan.create().withName(servicePlanEntity.getName()).withResourceGroup(servicePlanEntity.getResourceGroup()).withRegion(com.microsoft.azure.toolkit.lib.common.model.Region.fromName(servicePlanEntity.getRegion())).withPricingTier(servicePlanEntity.getPricingTier()).withOperatingSystem(servicePlanEntity.getOperatingSystem()).commit();
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan in project azure-tools-for-java by Microsoft.
the class AzureWebAppMvpModel method createWebAppFromSettingModel.
/**
* API to create new Web App by setting model.
*/
@AzureOperation(name = "webapp.create_detail", params = { "model.getWebAppName()" }, type = AzureOperation.Type.SERVICE)
public IWebApp createWebAppFromSettingModel(@NotNull WebAppSettingModel model) {
final ResourceGroup resourceGroup = getOrCreateResourceGroup(model.getSubscriptionId(), model.getResourceGroup(), model.getRegion());
final AppServicePlanEntity servicePlanEntity = AppServicePlanEntity.builder().id(model.getAppServicePlanId()).subscriptionId(model.getSubscriptionId()).name(model.getAppServicePlanName()).resourceGroup(model.getResourceGroup()).region(model.getRegion()).operatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem.fromString(model.getOperatingSystem())).pricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier.fromString(model.getPricing())).build();
final IAppServicePlan appServicePlan = getOrCreateAppServicePlan(servicePlanEntity);
final DiagnosticConfig diagnosticConfig = DiagnosticConfig.builder().enableApplicationLog(model.isEnableApplicationLog()).applicationLogLevel(com.microsoft.azure.toolkit.lib.appservice.model.LogLevel.fromString(model.getApplicationLogLevel())).enableWebServerLogging(model.isEnableWebServerLogging()).webServerLogQuota(model.getWebServerLogQuota()).webServerRetentionPeriod(model.getWebServerRetentionPeriod()).enableDetailedErrorMessage(model.isEnableDetailedErrorMessage()).enableFailedRequestTracing(model.isEnableFailedRequestTracing()).build();
return getAzureAppServiceClient(model.getSubscriptionId()).webapp(model.getResourceGroup(), model.getWebAppName()).create().withName(model.getWebAppName()).withResourceGroup(resourceGroup.getName()).withPlan(appServicePlan.id()).withRuntime(model.getRuntime()).withDiagnosticConfig(diagnosticConfig).commit();
}
Aggregations