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();
}
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;
}
Aggregations