Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgmt, support webapp with windows container #16130

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 2.0.0 (2020-09-27)

- Supported the configuration of container image for Windows web app.
- Supported the configuration of container image for deployment slot in update stage.
- Changed return type of `list` and `listByResourceGroup` in `WebApps`, `FunctionApps`, `DeploymentSlots`, `FunctionDeploymentSlots`.
- Added site properties for `WebApp`, `FunctionApp`, `DeploymentSlot`, `FunctionDeploymentSlot`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ abstract class AppServiceBaseImpl<

private final ClientLogger logger = new ClientLogger(getClass());

protected static final String SETTING_DOCKER_IMAGE = "DOCKER_CUSTOM_IMAGE_NAME";
protected static final String SETTING_REGISTRY_SERVER = "DOCKER_REGISTRY_SERVER_URL";
protected static final String SETTING_REGISTRY_USERNAME = "DOCKER_REGISTRY_SERVER_USERNAME";
protected static final String SETTING_REGISTRY_PASSWORD = "DOCKER_REGISTRY_SERVER_PASSWORD";

AppServiceBaseImpl(
String name,
SiteInner innerObject,
Expand Down Expand Up @@ -450,7 +445,7 @@ public FluentImplT withPublicDockerHubImage(String imageAndTag) {
if (siteConfig == null) {
siteConfig = new SiteConfigResourceInner();
}
siteConfig.withLinuxFxVersion(String.format("DOCKER|%s", imageAndTag));
setAppFrameworkVersion(String.format("DOCKER|%s", imageAndTag));
withAppSetting(SETTING_DOCKER_IMAGE, imageAndTag);
return (FluentImplT) this;
}
Expand All @@ -467,7 +462,7 @@ public FluentImplT withPrivateRegistryImage(String imageAndTag, String serverUrl
if (siteConfig == null) {
siteConfig = new SiteConfigResourceInner();
}
siteConfig.withLinuxFxVersion(String.format("DOCKER|%s", imageAndTag));
setAppFrameworkVersion(String.format("DOCKER|%s", imageAndTag));
withAppSetting(SETTING_DOCKER_IMAGE, imageAndTag);
withAppSetting(SETTING_REGISTRY_SERVER, serverUrl);
return (FluentImplT) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.azure.resourcemanager.appservice.models.ConnectionString;
import com.azure.resourcemanager.appservice.models.CsmPublishingProfileOptions;
import com.azure.resourcemanager.appservice.models.CsmSlotEntity;
import com.azure.resourcemanager.appservice.models.DeploymentSlotBase;
import com.azure.resourcemanager.appservice.models.HostnameBinding;
import com.azure.resourcemanager.appservice.models.MSDeploy;
import com.azure.resourcemanager.appservice.models.PublishingProfile;
Expand Down Expand Up @@ -39,7 +40,8 @@ abstract class DeploymentSlotBaseImpl<
ParentImplT extends AppServiceBaseImpl<?, ?, ?, ?>,
FluentWithCreateT,
FluentUpdateT>
extends WebAppBaseImpl<FluentT, FluentImplT> {
extends WebAppBaseImpl<FluentT, FluentImplT>
implements DeploymentSlotBase<FluentT>, DeploymentSlotBase.Update<FluentT> {
private final ParentImplT parent;
private final String name;
WebAppBase configurationSource;
Expand Down Expand Up @@ -467,4 +469,77 @@ public Mono<Void> verifyDomainOwnershipAsync(String certificateOrderName, String
resourceGroupName(), parent().name(), name(), certificateOrderName, identifierInner)
.then(Mono.empty());
}

@Override
public FluentImplT withRuntime(String runtime) {
return withAppSetting(SETTING_FUNCTIONS_WORKER_RUNTIME, runtime);
}

@Override
public FluentImplT withRuntimeVersion(String version) {
return withAppSetting(SETTING_FUNCTIONS_EXTENSION_VERSION, version.startsWith("~") ? version : "~" + version);
}

@Override
public FluentImplT withLatestRuntimeVersion() {
return withRuntimeVersion("latest");
}

@Override
public FluentImplT withPublicDockerHubImage(String imageAndTag) {
cleanUpContainerSettings();
if (siteConfig == null) {
siteConfig = new SiteConfigResourceInner();
}
setAppFrameworkVersion(String.format("DOCKER|%s", imageAndTag));
return withAppSetting(SETTING_DOCKER_IMAGE, imageAndTag);
}

@Override
public FluentImplT withPrivateDockerHubImage(String imageAndTag) {
return withPublicDockerHubImage(imageAndTag);
}

@Override
public FluentImplT withPrivateRegistryImage(String imageAndTag, String serverUrl) {
imageAndTag = Utils.smartCompletionPrivateRegistryImage(imageAndTag, serverUrl);

cleanUpContainerSettings();
if (siteConfig == null) {
siteConfig = new SiteConfigResourceInner();
}
setAppFrameworkVersion(String.format("DOCKER|%s", imageAndTag));
withAppSetting(SETTING_DOCKER_IMAGE, imageAndTag);
return withAppSetting(SETTING_REGISTRY_SERVER, serverUrl);
}

@Override
public FluentImplT withCredentials(String username, String password) {
withAppSetting(SETTING_REGISTRY_USERNAME, username);
return withAppSetting(SETTING_REGISTRY_PASSWORD, password);
}

@Override
@SuppressWarnings("unchecked")
public FluentImplT withStartUpCommand(String startUpCommand) {
if (siteConfig == null) {
siteConfig = new SiteConfigResourceInner();
}
siteConfig.withAppCommandLine(startUpCommand);
return (FluentImplT) this;
}

protected void cleanUpContainerSettings() {
if (siteConfig != null && siteConfig.linuxFxVersion() != null) {
siteConfig.withLinuxFxVersion(null);
}
if (siteConfig != null && siteConfig.windowsFxVersion() != null) {
siteConfig.withWindowsFxVersion(null);
}
// Docker Hub
withoutAppSetting(SETTING_DOCKER_IMAGE);
withoutAppSetting(SETTING_REGISTRY_SERVER);
withoutAppSetting(SETTING_REGISTRY_USERNAME);
withoutAppSetting(SETTING_REGISTRY_PASSWORD);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.resourcemanager.appservice.implementation;

import com.azure.resourcemanager.appservice.models.DeploymentSlot;
import com.azure.resourcemanager.appservice.models.DeploymentSlotBase;
import com.azure.resourcemanager.appservice.models.WebApp;
import com.azure.resourcemanager.appservice.fluent.models.SiteConfigResourceInner;
import com.azure.resourcemanager.appservice.fluent.models.SiteInner;
Expand All @@ -21,8 +22,8 @@ class DeploymentSlotImpl
DeploymentSlotImpl,
WebAppImpl,
DeploymentSlot.DefinitionStages.WithCreate,
DeploymentSlot.Update>
implements DeploymentSlot, DeploymentSlot.Definition, DeploymentSlot.Update {
DeploymentSlotBase.Update<DeploymentSlot>>
implements DeploymentSlot, DeploymentSlot.Definition {

DeploymentSlotImpl(
String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class FunctionAppImpl

private final ClientLogger logger = new ClientLogger(getClass());

private static final String SETTING_FUNCTIONS_WORKER_RUNTIME = "FUNCTIONS_WORKER_RUNTIME";
private static final String SETTING_FUNCTIONS_EXTENSION_VERSION = "FUNCTIONS_EXTENSION_VERSION";
private static final String SETTING_WEBSITE_CONTENTAZUREFILECONNECTIONSTRING =
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING";
private static final String SETTING_WEBSITE_CONTENTSHARE = "WEBSITE_CONTENTSHARE";
Expand Down Expand Up @@ -394,6 +392,9 @@ protected void cleanUpContainerSettings() {
if (siteConfig != null && siteConfig.linuxFxVersion() != null) {
siteConfig.withLinuxFxVersion(null);
}
if (siteConfig != null && siteConfig.windowsFxVersion() != null) {
siteConfig.withWindowsFxVersion(null);
}
// Docker Hub
withoutAppSetting(SETTING_DOCKER_IMAGE);
withoutAppSetting(SETTING_REGISTRY_SERVER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.resourcemanager.appservice.implementation;

import com.azure.resourcemanager.appservice.fluent.models.SitePatchResourceInner;
import com.azure.resourcemanager.appservice.models.DeploymentSlotBase;
import com.azure.resourcemanager.appservice.models.FunctionApp;
import com.azure.resourcemanager.appservice.models.FunctionDeploymentSlot;
import com.azure.resourcemanager.appservice.fluent.models.SiteConfigResourceInner;
Expand All @@ -21,8 +22,8 @@ class FunctionDeploymentSlotImpl
FunctionDeploymentSlotImpl,
FunctionAppImpl,
FunctionDeploymentSlot.DefinitionStages.WithCreate,
FunctionDeploymentSlot.Update>
implements FunctionDeploymentSlot, FunctionDeploymentSlot.Definition, FunctionDeploymentSlot.Update {
DeploymentSlotBase<FunctionDeploymentSlot>>
implements FunctionDeploymentSlot, FunctionDeploymentSlot.Definition {

FunctionDeploymentSlotImpl(
String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ abstract class WebAppBaseImpl<FluentT extends WebAppBase, FluentImplT extends We

private final ClientLogger logger = new ClientLogger(getClass());

protected static final String SETTING_DOCKER_IMAGE = "DOCKER_CUSTOM_IMAGE_NAME";
protected static final String SETTING_REGISTRY_SERVER = "DOCKER_REGISTRY_SERVER_URL";
protected static final String SETTING_REGISTRY_USERNAME = "DOCKER_REGISTRY_SERVER_USERNAME";
protected static final String SETTING_REGISTRY_PASSWORD = "DOCKER_REGISTRY_SERVER_PASSWORD";

protected static final String SETTING_FUNCTIONS_WORKER_RUNTIME = "FUNCTIONS_WORKER_RUNTIME";
protected static final String SETTING_FUNCTIONS_EXTENSION_VERSION = "FUNCTIONS_EXTENSION_VERSION";

private static final Map<AzureEnvironment, String> DNS_MAP =
new HashMap<AzureEnvironment, String>() {
{
Expand Down Expand Up @@ -456,6 +464,14 @@ public String linuxFxVersion() {
return siteConfig.linuxFxVersion();
}

@Override
public String windowsFxVersion() {
if (siteConfig == null) {
return null;
}
return siteConfig.windowsFxVersion();
}

@Override
public String autoSwapSlotName() {
if (siteConfig == null) {
Expand Down Expand Up @@ -1702,4 +1718,12 @@ public void close() throws IOException {
super.close();
}
}

protected void setAppFrameworkVersion(String fxVersion) {
if (operatingSystem() == OperatingSystem.LINUX) {
siteConfig.withLinuxFxVersion(fxVersion);
} else {
siteConfig.withWindowsFxVersion(fxVersion);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class WebAppImpl extends AppServiceBaseImpl<WebApp, WebAppImpl, WebApp.Definitio
WebApp.Definition,
WebApp.DefinitionStages.ExistingWindowsPlanWithGroup,
WebApp.DefinitionStages.ExistingLinuxPlanWithGroup,
WebApp.DefinitionStages.WithWindowsRuntimeStack,
WebApp.Update,
WebApp.UpdateStages.WithCredentials,
WebApp.UpdateStages.WithStartUpCommand {
Expand Down Expand Up @@ -85,6 +84,9 @@ protected void cleanUpContainerSettings() {
if (siteConfig != null && siteConfig.linuxFxVersion() != null) {
siteConfig.withLinuxFxVersion(null);
}
if (siteConfig != null && siteConfig.windowsFxVersion() != null) {
siteConfig.withWindowsFxVersion(null);
}
// PHP
if (siteConfig != null && siteConfig.phpVersion() != null) {
siteConfig.withPhpVersion(null);
Expand All @@ -93,6 +95,14 @@ protected void cleanUpContainerSettings() {
if (siteConfig != null && siteConfig.nodeVersion() != null) {
siteConfig.withNodeVersion(null);
}
// Python
if (siteConfig != null && siteConfig.pythonVersion() != null) {
siteConfig.withPythonVersion(null);
}
// Java
if (siteConfig != null && siteConfig.javaVersion() != null) {
siteConfig.withJavaVersion(null);
}
// .NET
if (siteConfig != null && siteConfig.netFrameworkVersion() != null) {
siteConfig.withNetFrameworkVersion("v4.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.azure.resourcemanager.appservice.fluent.models.SiteInner;
import com.azure.resourcemanager.resources.fluentcore.arm.models.HasParent;
import com.azure.resourcemanager.resources.fluentcore.arm.models.IndependentChildResource;
import com.azure.resourcemanager.resources.fluentcore.model.Appliable;
import com.azure.resourcemanager.resources.fluentcore.model.Creatable;
import com.azure.resourcemanager.resources.fluentcore.model.Updatable;
import java.io.File;
Expand All @@ -20,8 +19,8 @@
public interface DeploymentSlot
extends IndependentChildResource<AppServiceManager, SiteInner>,
WebDeploymentSlotBasic,
WebAppBase,
Updatable<DeploymentSlot.Update>,
DeploymentSlotBase<DeploymentSlot>,
Updatable<DeploymentSlotBase.Update<DeploymentSlot>>,
HasParent<WebApp> {

/**
Expand Down Expand Up @@ -147,8 +146,4 @@ interface WithConfiguration {
interface WithCreate extends Creatable<DeploymentSlot>, WebAppBase.DefinitionStages.WithCreate<DeploymentSlot> {
}
}

/** The template for a web app update operation, containing all the settings that can be modified. */
interface Update extends Appliable<DeploymentSlot>, WebAppBase.Update<DeploymentSlot> {
}
}
Loading