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

enable deploy to slot option for linux apps #4581

Merged
merged 3 commits into from
Jun 20, 2017
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 @@ -14,6 +14,12 @@
"loc.input.help.WebAppName": "Enter or Select the name of an existing Azure App Service.",
"loc.input.label.ServerfarmId": "Serverfarm id",
"loc.input.label.WebAppKind": "Web app kind",
"loc.input.label.DeployToSlotFlag": "Deploy to slot",
"loc.input.help.DeployToSlotFlag": "Select the option to deploy to an existing slot other than the Production slot. If this option is not selected, then the Azure App Service will be deployed to the Production slot.",
"loc.input.label.ResourceGroupName": "Resource group",
"loc.input.help.ResourceGroupName": "Enter or Select the Azure Resource group that contains the Azure App Service specified above.",
"loc.input.label.SlotName": "Slot",
"loc.input.help.SlotName": "Enter or Select an existing Slot other than the Production slot.",
"loc.input.label.DockerNamespace": "Registry or Namespace",
"loc.input.help.DockerNamespace": "A globally unique top-level domain name for your specific registry or namespace.<br/> Note: Fully qualified image name will be of the format: '<b>`<registry or namespace`></b>/`<repository`>:`<tag`>'. For example, '<b>myregistry.azurecr.io</b>/nginx:latest'.",
"loc.input.label.DockerRepository": "Repository",
Expand All @@ -22,12 +28,6 @@
"loc.input.help.DockerImageTag": "Tags are optional, it is the mechanism that registries use to give Docker images a version.<br/> Note: Fully qualified image name will be of the format: '`<registry or namespace`>/`<repository`>:<b>`<tag`></b>'. For example, 'myregistry.azurecr.io/nginx:<b>latest</b>'.",
"loc.input.label.StartupCommand": "Startup command ",
"loc.input.help.StartupCommand": "Enter the start up command.",
"loc.input.label.DeployToSlotFlag": "Deploy to slot",
"loc.input.help.DeployToSlotFlag": "Select the option to deploy to an existing slot other than the Production slot. If this option is not selected, then the Azure App Service will be deployed to the Production slot.",
"loc.input.label.ResourceGroupName": "Resource group",
"loc.input.help.ResourceGroupName": "Enter or Select the Azure Resource group that contains the Azure App Service specified above.",
"loc.input.label.SlotName": "Slot",
"loc.input.help.SlotName": "Enter or Select an existing Slot other than the Production slot.",
"loc.input.label.VirtualApplication": "Virtual application",
"loc.input.help.VirtualApplication": "Specify the name of the Virtual application that has been configured in the Azure portal. The option is not required for deployments to the App Service root.",
"loc.input.label.Package": "Package or folder",
Expand Down
38 changes: 18 additions & 20 deletions Tasks/AzureRmWebAppDeployment/azurermwebappcontainerdeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import util = require('util');
var azureRESTUtility = require ('azurerest-common/azurerestutility.js');
var parameterParser = require("./parameterparser.js").parse;

export async function deployWebAppImage(endPoint, resourceGroupName, webAppName) {
export async function deployWebAppImage(endPoint, resourceGroupName, webAppName, deployToSlotFlag, slotName) {
var startupCommand = tl.getInput('StartupCommand', false);
var appSettings = tl.getInput('AppSettings', false);
var imageSourceAndTag;
Expand All @@ -29,29 +29,27 @@ export async function deployWebAppImage(endPoint, resourceGroupName, webAppName)
imageSourceAndTag = dockerNamespace + "/" + dockerRepository;
}

if(imageSourceAndTag)
{
tl.debug("Deploying the image " + imageSourceAndTag + " to the webapp " + webAppName);
var appName = deployToSlotFlag ? webAppName + "-" + slotName : webAppName;
tl.debug("Deploying the image " + imageSourceAndTag + " to the webapp " + appName);

tl.debug("Updating the webapp configuration.");
var updatedConfigDetails = JSON.stringify({
"properties": {
"appCommandLine": startupCommand,
"linuxFxVersion": "DOCKER|" + imageSourceAndTag
}
});
tl.debug("Updating the webapp configuration.");
var updatedConfigDetails = JSON.stringify({
"properties": {
"appCommandLine": startupCommand,
"linuxFxVersion": "DOCKER|" + imageSourceAndTag
}
});

await azureRESTUtility.updateAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, false, null, updatedConfigDetails);
await azureRESTUtility.updateAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName, updatedConfigDetails);

tl.debug("Updating the webapp application settings.");
appSettings = appSettings ? appSettings.trim() : "";
appSettings = "-DOCKER_CUSTOM_IMAGE_NAME " + imageSourceAndTag + " " + appSettings;
tl.debug("Updating the webapp application settings.");
appSettings = appSettings ? appSettings.trim() : "";
appSettings = "-DOCKER_CUSTOM_IMAGE_NAME " + imageSourceAndTag + " " + appSettings;

// Update webapp application setting
var webAppSettings = await azureRESTUtility.getWebAppAppSettings(endPoint, webAppName, resourceGroupName, false, null);
mergeAppSettings(appSettings, webAppSettings);
await azureRESTUtility.updateWebAppAppSettings(endPoint, webAppName, resourceGroupName, false, null, webAppSettings);
}
// Update webapp application setting
var webAppSettings = await azureRESTUtility.getWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
mergeAppSettings(appSettings, webAppSettings);
await azureRESTUtility.updateWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName, webAppSettings);
}

function mergeAppSettings(appSettings, webAppSettings) {
Expand Down
6 changes: 1 addition & 5 deletions Tasks/AzureRmWebAppDeployment/azurermwebappdeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ async function run() {
endPoint["envAuthUrl"] = tl.getEndpointDataParameter(connectedServiceName, 'environmentAuthorityUrl', true);
endPoint["url"] = tl.getEndpointUrl(connectedServiceName, true);

if(webAppKind && webAppKind === "linux") {
deployToSlotFlag = false;
}

if(deployToSlotFlag) {
if (slotName.toLowerCase() === "production") {
deployToSlotFlag = false;
Expand All @@ -74,7 +70,7 @@ async function run() {
{
tl.debug("Performing container based deployment.");

await deployWebAppImage(endPoint, resourceGroupName, webAppName);
await deployWebAppImage(endPoint, resourceGroupName, webAppName, deployToSlotFlag, slotName);
}
else
{
Expand Down
68 changes: 34 additions & 34 deletions Tasks/AzureRmWebAppDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 3,
"Patch": 8
"Patch": 9
},
"releaseNotes": "What's new in Version 3.0: <br/>&nbsp;&nbsp;Supports File Transformations (XDT) <br/>&nbsp;&nbsp;Supports Variable Substitutions(XML, JSON) <br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.",
"minimumAgentVersion": "2.104.1",
Expand Down Expand Up @@ -90,6 +90,39 @@
"PopulateDefaultValue": "true"
}
},
{
"name": "DeployToSlotFlag",
"type": "boolean",
"label": "Deploy to slot",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Select the option to deploy to an existing slot other than the Production slot. If this option is not selected, then the Azure App Service will be deployed to the Production slot.",
"visibleRule": "WebAppKind = app || WebAppKind = functionapp || WebAppKind = linux"
},
{
"name": "ResourceGroupName",
"type": "pickList",
"label": "Resource group",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "Enter or Select the Azure Resource group that contains the Azure App Service specified above.",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "SlotName",
"type": "pickList",
"label": "Slot",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "Enter or Select an existing Slot other than the Production slot.",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "DockerNamespace",
"type": "string",
Expand Down Expand Up @@ -126,39 +159,6 @@
"visibleRule": "WebAppKind = linux",
"helpMarkDown": "Enter the start up command."
},
{
"name": "DeployToSlotFlag",
"type": "boolean",
"label": "Deploy to slot",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Select the option to deploy to an existing slot other than the Production slot. If this option is not selected, then the Azure App Service will be deployed to the Production slot.",
"visibleRule": "WebAppKind = app || WebAppKind = functionapp"
},
{
"name": "ResourceGroupName",
"type": "pickList",
"label": "Resource group",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "Enter or Select the Azure Resource group that contains the Azure App Service specified above.",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "SlotName",
"type": "pickList",
"label": "Slot",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "Enter or Select an existing Slot other than the Production slot.",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "VirtualApplication",
"type": "string",
Expand Down
68 changes: 34 additions & 34 deletions Tasks/AzureRmWebAppDeployment/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 3,
"Patch": 8
"Patch": 9
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"minimumAgentVersion": "2.104.1",
Expand Down Expand Up @@ -90,6 +90,39 @@
"PopulateDefaultValue": "true"
}
},
{
"name": "DeployToSlotFlag",
"type": "boolean",
"label": "ms-resource:loc.input.label.DeployToSlotFlag",
"defaultValue": "false",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.DeployToSlotFlag",
"visibleRule": "WebAppKind = app || WebAppKind = functionapp || WebAppKind = linux"
},
{
"name": "ResourceGroupName",
"type": "pickList",
"label": "ms-resource:loc.input.label.ResourceGroupName",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "ms-resource:loc.input.help.ResourceGroupName",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "SlotName",
"type": "pickList",
"label": "ms-resource:loc.input.label.SlotName",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "ms-resource:loc.input.help.SlotName",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "DockerNamespace",
"type": "string",
Expand Down Expand Up @@ -126,39 +159,6 @@
"visibleRule": "WebAppKind = linux",
"helpMarkDown": "ms-resource:loc.input.help.StartupCommand"
},
{
"name": "DeployToSlotFlag",
"type": "boolean",
"label": "ms-resource:loc.input.label.DeployToSlotFlag",
"defaultValue": "false",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.DeployToSlotFlag",
"visibleRule": "WebAppKind = app || WebAppKind = functionapp"
},
{
"name": "ResourceGroupName",
"type": "pickList",
"label": "ms-resource:loc.input.label.ResourceGroupName",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "ms-resource:loc.input.help.ResourceGroupName",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "SlotName",
"type": "pickList",
"label": "ms-resource:loc.input.label.SlotName",
"defaultValue": "",
"required": true,
"properties": {
"EditableOptions": "True"
},
"helpMarkDown": "ms-resource:loc.input.help.SlotName",
"visibleRule": "DeployToSlotFlag = true"
},
{
"name": "VirtualApplication",
"type": "string",
Expand Down