Search in sources :

Example 1 with DockerConfiguration

use of com.microsoft.azure.toolkit.lib.appservice.model.DockerConfiguration 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();
}
Also used : AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) DockerConfiguration(com.microsoft.azure.toolkit.lib.appservice.model.DockerConfiguration) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with DockerConfiguration

use of com.microsoft.azure.toolkit.lib.appservice.model.DockerConfiguration in project azure-tools-for-java by Microsoft.

the class AzureWebAppMvpModel method updateWebAppOnDocker.

/**
 * Update container settings for existing Web App on Linux.
 *
 * @param webAppId     id of Web App on Linux instance
 * @param imageSetting new container settings
 * @return instance of the updated Web App on Linux
 */
@AzureOperation(name = "docker|image.update", params = { "nameFromResourceId(webAppId)", "imageSetting.getImageNameWithTag()" }, type = AzureOperation.Type.SERVICE)
public IWebApp updateWebAppOnDocker(String webAppId, ImageSetting imageSetting) {
    final IWebApp app = com.microsoft.azure.toolkit.lib.Azure.az(AzureAppService.class).webapp(webAppId);
    // clearTags(app);
    if (imageSetting instanceof PrivateRegistryImageSetting) {
        final PrivateRegistryImageSetting pr = (PrivateRegistryImageSetting) imageSetting;
        final DockerConfiguration dockerConfiguration = DockerConfiguration.builder().image(pr.getImageTagWithServerUrl()).registryUrl(pr.getServerUrl()).userName(pr.getUsername()).password(pr.getPassword()).startUpCommand(pr.getStartupFile()).build();
        app.update().withDockerConfiguration(dockerConfiguration).commit();
    }
    // status-free restart.
    app.restart();
    return app;
}
Also used : DockerConfiguration(com.microsoft.azure.toolkit.lib.appservice.model.DockerConfiguration) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

DockerConfiguration (com.microsoft.azure.toolkit.lib.appservice.model.DockerConfiguration)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)1 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)1 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)1 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)1 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)1