use of com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity 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.entity.AppServicePlanEntity 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();
}
use of com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity in project azure-tools-for-java by Microsoft.
the class AppServiceInfoAdvancedPanel method onServicePlanChanged.
private void onServicePlanChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final AppServicePlanEntity plan = (AppServicePlanEntity) e.getItem();
if (plan == null || plan.getPricingTier() == null) {
return;
}
final String pricing = Objects.equals(plan.getPricingTier(), PricingTier.CONSUMPTION) ? "Consumption" : String.format("%s_%s", plan.getPricingTier().getTier(), plan.getPricingTier().getSize());
this.textSku.setText(pricing);
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
this.textSku.setText(NOT_APPLICABLE);
}
}
use of com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity in project azure-tools-for-java by Microsoft.
the class WebAppBasePropertyViewPresenter method generateProperty.
protected <T extends AppServiceBaseEntity> WebAppProperty generateProperty(@Nonnull final IAppService<T> appService, @Nonnull final IAppServicePlan plan) {
final AppServiceBaseEntity appServiceEntity = appService.entity();
final AppServicePlanEntity planEntity = plan.entity();
final Map<String, String> appSettingsMap = appServiceEntity.getAppSettings();
final Map<String, Object> propertyMap = new HashMap<>();
propertyMap.put(KEY_NAME, appServiceEntity.getName());
propertyMap.put(KEY_RESOURCE_GRP, appServiceEntity.getResourceGroup());
propertyMap.put(KEY_LOCATION, appServiceEntity.getRegion().getLabel());
propertyMap.put(KEY_SUB_ID, appService.subscriptionId());
propertyMap.put(KEY_STATUS, appService.state());
propertyMap.put(KEY_PLAN, plan.name());
propertyMap.put(KEY_URL, appService.hostName());
final PricingTier pricingTier = planEntity.getPricingTier();
propertyMap.put(KEY_PRICING, String.format("%s_%s", pricingTier.getTier(), pricingTier.getSize()));
final Runtime runtime = appService.getRuntime();
final JavaVersion javaVersion = runtime.getJavaVersion();
if (javaVersion != null && ObjectUtils.notEqual(javaVersion, JavaVersion.OFF)) {
propertyMap.put(KEY_JAVA_VERSION, javaVersion.getValue());
propertyMap.put(KEY_JAVA_CONTAINER, runtime.getWebContainer().getValue());
}
propertyMap.put(KEY_OPERATING_SYS, runtime.getOperatingSystem());
propertyMap.put(KEY_APP_SETTING, appSettingsMap);
return new WebAppProperty(propertyMap);
}
use of com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity in project azure-tools-for-java by Microsoft.
the class AppServiceInfoAdvancedPanel method getData.
@Override
public T getData() {
final Subscription subscription = this.selectorSubscription.getValue();
final ResourceGroup resourceGroup = this.selectorGroup.getValue();
final String name = this.textName.getValue();
final Runtime runtime = this.selectorRuntime.getValue();
final Region region = this.selectorRegion.getValue();
final AppServicePlanEntity servicePlan = this.selectorServicePlan.getValue();
final AzureArtifact artifact = this.selectorApplication.getValue();
final T config = supplier.get();
config.setSubscription(subscription);
config.setResourceGroup(resourceGroup);
config.setName(name);
config.setRuntime(runtime);
config.setRegion(region);
config.setServicePlan(servicePlan);
if (Objects.nonNull(artifact)) {
final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.project);
final String path = manager.getFileForDeployment(this.selectorApplication.getValue());
config.setApplication(Paths.get(path));
}
return config;
}
Aggregations