From ff56945e0348c26145b653df780f6848757daa8b Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Fri, 27 May 2016 12:30:04 +0530 Subject: [PATCH 01/12] Powershell handler 3 support to the task --- .../AzureRmWebAppDeployment.ps1 | 222 +++++------ .../AzureRmWebAppDeployment/AzureUtility.ps1 | 10 +- .../resources.resjson/en-US/resources.resjson | 22 +- Tasks/AzureRmWebAppDeployment/Utility.ps1 | 18 +- Tasks/AzureRmWebAppDeployment/task.json | 361 +++++++++--------- Tasks/AzureRmWebAppDeployment/task.loc.json | 31 +- .../VstsAzureHelpers_/VstsAzureHelpers_.psm1 | 36 ++ .../resources.resjson/en-US/resources.resjson | 10 +- common.json | 6 + 9 files changed, 415 insertions(+), 301 deletions(-) diff --git a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 index 985834956eba..c9ba39709e92 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 @@ -1,134 +1,142 @@ -param -( - [String] [Parameter(Mandatory = $true)] - $ConnectedServiceName, - - [String] [Parameter(Mandatory = $true)] - $WebAppName, +[CmdletBinding()] +param() + +Trace-VstsEnteringInvocation $MyInvocation + +try{ + + # Get inputs. + $WebAppName = Get-VstsInput -Name WebAppName -Require + $DeployToSlotFlag = Get-VstsInput -Name DeployToSlotFlag -Require + $ResourceGroupName = Get-VstsInput -Name ResourceGroupName + $SlotName = Get-VstsInput -Name SlotName + $Package = Get-VstsInput -Name Package -Require + $RemoveAdditionalFilesFlag = Get-VstsInput -Name ScriptArgument + $ExcludeFilesFromAppDataFlag = Get-VstsInput -Name ExcludeFilesFromAppDataFlag + $TakeAppOfflineFlag = Get-VstsInput -Name TakeAppOfflineFlag + $VirtualApplication = Get-VstsInput -Name VirtualApplication + $AdditionalArguments = Get-VstsInput -Name AdditionalArguments + $WebAppUri = Get-VstsInput -Name WebAppUri + $SetParametersFile = Get-VstsInput -Name SetParametersFile + + # Initialize Azure. + + Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ + Initialize-Azure + + # Import the loc strings. + Import-VstsLocStrings -LiteralPath $PSScriptRoot/Task.json + + + Write-Verbose "Starting AzureRM WebApp Deployment Task" + + Write-Verbose "ConnectedServiceName = $ConnectedServiceName" + Write-Verbose "WebAppName = $WebAppName" + Write-Verbose "DeployToSlotFlag = $DeployToSlotFlag" + Write-Verbose "ResourceGroupName = $ResourceGroupName" + Write-Verbose "SlotName = $SlotName" + Write-Verbose "Package = $Package" + Write-Verbose "SetParametersFile = $SetParametersFile" + Write-Verbose "RemoveAdditionalFilesFlag = $RemoveAdditionalFilesFlag" + Write-Verbose "ExcludeFilesFromAppDataFlag = $ExcludeFilesFromAppDataFlag" + Write-Verbose "TakeAppOfflineFlag = $TakeAppOfflineFlag" + Write-Verbose "VirtualApplication = $VirtualApplication" + Write-Verbose "AdditionalArguments = $AdditionalArguments" + Write-Verbose "WebAppUri = $WebAppUri" + + $WebAppUri = $WebAppUri.Trim() + $Package = $Package.Trim('"').Trim() + + if( [string]::IsNullOrEmpty($Package) ){ + Throw (Get-VstsLocString -Key "Invalidwebapppackagepathprovided") + } - [String] [Parameter(Mandatory = $true)] - $DeployToSlotFlag, + if ($ExcludeFilesFromAppDataFlag -match '[\r\n]' -or [string]::IsNullOrEmpty($ExcludeFilesFromAppDataFlag)) { + $ExcludeFilesFromAppDataFlag = $false + } - [String] [Parameter(Mandatory = $false)] - $ResourceGroupName, + if ($TakeAppOfflineFlag -match '[\r\n]' -or [string]::IsNullOrEmpty($TakeAppOfflineFlag)) { + $TakeAppOfflineFlag = $false + } - [String] [Parameter(Mandatory = $false)] - $SlotName, + if ($RemoveAdditionalFilesFlag -match '[\r\n]' -or [string]::IsNullOrEmpty($RemoveAdditionalFilesFlag)) { + $RemoveAdditionalFilesFlag = $false + } - [String] [Parameter(Mandatory = $true)] - $Package, - - [String] [Parameter(Mandatory = $false)] - $SetParametersFile, + $SetParametersFile = $SetParametersFile.Trim('"').Trim() - [String] [Parameter(Mandatory = $false)] - $RemoveAdditionalFilesFlag, - [String] [Parameter(Mandatory = $false)] - $ExcludeFilesFromAppDataFlag, + # Load all dependent files for execution + Import-Module ./AzureUtility.ps1 -Force + Import-Module ./Utility.ps1 -Force + Import-Module ./FindInstalledMSDeploy.ps1 - [String] [Parameter(Mandatory = $false)] - $TakeAppOfflineFlag, + # Importing required version of azure cmdlets according to azureps installed on machine + $azureUtility = Get-AzureUtility - [String] [Parameter(Mandatory = $false)] - $VirtualApplication, + Write-Verbose "Loading $azureUtility" + Import-Module ./$azureUtility -Force - [String] [Parameter(Mandatory = $false)] - [String] $AdditionalArguments, + $ErrorActionPreference = 'Stop' - [String] [Parameter(Mandatory = $false)] - [string]$WebAppUri -) + #### MAIN EXECUTION OF AZURERM WEBAPP DEPLOYMENT TASK BEGINS HERE #### -Write-Verbose "Starting AzureRM WebApp Deployment Task" + # Get msdeploy.exe path + $msDeployExePath = Get-MsDeployExePath -Write-Verbose "ConnectedServiceName = $ConnectedServiceName" -Write-Verbose "WebAppName = $WebAppName" -Write-Verbose "DeployToSlotFlag = $DeployToSlotFlag" -Write-Verbose "ResourceGroupName = $ResourceGroupName" -Write-Verbose "SlotName = $SlotName" -Write-Verbose "Package = $Package" -Write-Verbose "SetParametersFile = $SetParametersFile" -Write-Verbose "RemoveAdditionalFilesFlag = $RemoveAdditionalFilesFlag" -Write-Verbose "ExcludeFilesFromAppDataFlag = $ExcludeFilesFromAppDataFlag" -Write-Verbose "TakeAppOfflineFlag = $TakeAppOfflineFlag" -Write-Verbose "VirtualApplication = $VirtualApplication" -Write-Verbose "AdditionalArguments = $AdditionalArguments" -Write-Verbose "WebAppUri = $WebAppUri" + # Ensure that at most a package (.zip) file is found + $packageFilePath = Get-SingleFilePath -file $Package -$WebAppUri = $WebAppUri.Trim() -$Package = $Package.Trim('"').Trim() + Write-Verbose "Value of package file path : $SetParametersFile" -verbose -if( [string]::IsNullOrEmpty($Package) ){ - Throw (Get-LocalizedString -Key "Invalid webapp package path provided") -} - -$SetParametersFile = $SetParametersFile.Trim('"').Trim() + # Since the SetParametersFile is optional, but it's a FilePath type, it will have the value System.DefaultWorkingDirectory when not specified + if( $SetParametersFile -eq $env:SYSTEM_DEFAULTWORKINGDIRECTORY -or $SetParametersFile -eq [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\" ) -or [string]::IsNullOrEmpty($SetParametersFile) ){ + Write-Verbose "Is empty" -verbose + $setParametersFilePath = "" + } else { + Write-Verbose "Is not empty" -verbose + $setParametersFilePath = Get-SingleFilePath -file $SetParametersFile + } -# Import all the dlls and modules which have cmdlets we need -Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal" -Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Common" + # Get destination azureRM webApp connection details + $azureRMWebAppConnectionDetails = Get-AzureRMWebAppConnectionDetails -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` + -resourceGroupName $ResourceGroupName -slotName $SlotName -# Load all dependent files for execution -Import-Module ./AzureUtility.ps1 -Force -Import-Module ./Utility.ps1 -Force -Import-Module ./FindInstalledMSDeploy.ps1 + # webApp Name to be used in msdeploy command + $webAppNameForMSDeployCmd = Get-WebAppNameForMSDeployCmd -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag -slotName $SlotName - # Importing required version of azure cmdlets according to azureps installed on machine - $azureUtility = Get-AzureUtility + # Construct arguments for msdeploy command + $msDeployCmdArgs = Get-MsDeployCmdArgs -packageFile $packageFilePath -webAppNameForMSDeployCmd $webAppNameForMSDeployCmd -azureRMWebAppConnectionDetails $azureRMWebAppConnectionDetails -removeAdditionalFilesFlag $RemoveAdditionalFilesFlag ` + -excludeFilesFromAppDataFlag $ExcludeFilesFromAppDataFlag -takeAppOfflineFlag $TakeAppOfflineFlag -virtualApplication $VirtualApplication -AdditionalArguments $AdditionalArguments ` + -setParametersFile $setParametersFilePath - Write-Verbose "Loading $azureUtility" - Import-Module ./$azureUtility -Force + # Deploy azureRM webApp using msdeploy Command + Run-MsDeployCommand -msDeployExePath $msDeployExePath -msDeployCmdArgs $msDeployCmdArgs -$ErrorActionPreference = 'Stop' + # Get azure webapp hosted url + $azureWebsitePublishURL = Get-AzureRMWebAppPublishUrl -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` + -resourceGroupName $ResourceGroupName -slotName $SlotName -#### MAIN EXECUTION OF AZURERM WEBAPP DEPLOYMENT TASK BEGINS HERE #### + # Publish azure webApp url + Write-Host (Get-VstsLocString -Key "WebappsuccessfullypublishedatUrl0" -ArgumentList $azureWebsitePublishURL) -# Get msdeploy.exe path -$msDeployExePath = Get-MsDeployExePath + # Set ouput vairable with azureWebsitePublishUrl + if(-not [string]::IsNullOrEmpty($WebAppUri)) + { + + if( [string]::IsNullOrEmpty($azureWebsitePublishURL)) + { + Throw (Get-VstsLocString -Key "Unabletoretrievewebapppublishurlforwebapp0" -ArgumentList $webAppName) + } + + Write-Host "##vso[task.setvariable variable=$WebAppUri;]$azureWebsitePublishURL" + } -# Ensure that at most a package (.zip) file is found -$packageFilePath = Get-SingleFilePath -file $Package + Write-Verbose "Completed AzureRM WebApp Deployment Task" -# Since the SetParametersFile is optional, but it's a FilePath type, it will have the value System.DefaultWorkingDirectory when not specified -if( $SetParametersFile -eq $env:SYSTEM_DEFAULTWORKINGDIRECTORY -or $SetParametersFile -eq [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\")){ - $setParametersFilePath = "" -} else { - $setParametersFilePath = Get-SingleFilePath -file $SetParametersFile +} finally { + Trace-VstsLeavingInvocation $MyInvocation } -# Get destination azureRM webApp connection details -$azureRMWebAppConnectionDetails = Get-AzureRMWebAppConnectionDetails -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` - -resourceGroupName $ResourceGroupName -slotName $SlotName - -# webApp Name to be used in msdeploy command -$webAppNameForMSDeployCmd = Get-WebAppNameForMSDeployCmd -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag -slotName $SlotName - -# Construct arguments for msdeploy command -$msDeployCmdArgs = Get-MsDeployCmdArgs -packageFile $packageFilePath -webAppNameForMSDeployCmd $webAppNameForMSDeployCmd -azureRMWebAppConnectionDetails $azureRMWebAppConnectionDetails -removeAdditionalFilesFlag $RemoveAdditionalFilesFlag ` - -excludeFilesFromAppDataFlag $ExcludeFilesFromAppDataFlag -takeAppOfflineFlag $TakeAppOfflineFlag -virtualApplication $VirtualApplication -AdditionalArguments $AdditionalArguments ` - -setParametersFile $setParametersFilePath - -# Deploy azureRM webApp using msdeploy Command -Run-MsDeployCommand -msDeployExePath $msDeployExePath -msDeployCmdArgs $msDeployCmdArgs - -# Get azure webapp hosted url -$azureWebsitePublishURL = Get-AzureRMWebAppPublishUrl -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` - -resourceGroupName $ResourceGroupName -slotName $SlotName - -# Publish azure webApp url -Write-Host (Get-LocalizedString -Key "Webapp successfully published at Url : {0}" -ArgumentList $azureWebsitePublishURL) -# Set ouput vairable with azureWebsitePublishUrl -if(-not [string]::IsNullOrEmpty($WebAppUri)) -{ - - if( [string]::IsNullOrEmpty($azureWebsitePublishURL)) - { - Throw (Get-LocalizedString -Key "Unable to retrieve webapp publish url for webapp : '{0}'." -ArgumentList $webAppName) - } - - Write-Host "##vso[task.setvariable variable=$WebAppUri;]$azureWebsitePublishURL" -} -Write-Verbose "Completed AzureRM WebApp Deployment Task" diff --git a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 index 2d8fc59ec813..51c16716206a 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 @@ -58,7 +58,7 @@ function Get-AzureRMWebAppConnectionDetailsWithSpecificSlot [String][Parameter(Mandatory=$true)] $resourceGroupName, [String][Parameter(Mandatory=$true)] $slotName) - Write-Host (Get-LocalizedString -Key "Getting connection details for azureRM WebApp:'{0}' under Slot:'{1}'." -ArgumentList $webAppName, $slotName) + Write-Host (Get-VstsLocString -Key "GettingconnectiondetailsforazureRMWebApp0underSlot1" -ArgumentList $webAppName, $slotName) $kuduHostName = $webAppName + "-" + $slotName + ".scm.azurewebsites.net" Write-Verbose "`t Using KuduHostName:'$kuduHostName' for azureRM WebApp:'$webAppName' under Slot:'$slotName'." @@ -69,7 +69,7 @@ function Get-AzureRMWebAppConnectionDetailsWithSpecificSlot # construct object to store webApp connection details $azureRMWebAppConnectionDetailsWithSpecificSlot = Construct-AzureWebAppConnectionObject -kuduHostName $kuduHostName -webAppProfileForMSDeploy $webAppProfileForMSDeploy - Write-Host (Get-LocalizedString -Key "Got connection details for azureRM WebApp:'{0}' under Slot:'{1}'." -ArgumentList $webAppName, $slotName) + Write-Host (Get-VstsLocString -Key "GotconnectiondetailsforazureRMWebApp0underSlot1" -ArgumentList $webAppName, $slotName) return $azureRMWebAppConnectionDetailsWithSpecificSlot } @@ -77,7 +77,7 @@ function Get-AzureRMWebAppConnectionDetailsWithProductionSlot { param([String][Parameter(Mandatory=$true)] $webAppName) - Write-Host (Get-LocalizedString -Key "Getting connection details for azureRM WebApp:'{0}' under Production Slot." -ArgumentList $webAppName) + Write-Host (Get-VstsLocString -Key "GettingconnectiondetailsforazureRMWebApp0underProductionSlot" -ArgumentList $webAppName) $kuduHostName = $webAppName + ".scm.azurewebsites.net" Write-Verbose "`t Using KuduHostName:'$kuduHostName' for azureRM WebApp:'$webAppName' under default Slot." @@ -86,7 +86,7 @@ function Get-AzureRMWebAppConnectionDetailsWithProductionSlot $azureRMWebAppDetails = Get-AzureRMWebAppDetails -webAppName $webAppName if( $azureRMWebAppDetails.Count -eq 0 ){ - Throw (Get-LocalizedString -Key "WebApp '{0}' does not exist." -ArgumentList $webAppName) + Throw (Get-VstsLocString -Key "WebApp0doesnotexist" -ArgumentList $webAppName) } # Get resourcegroup name under which azure webApp exists @@ -102,7 +102,7 @@ function Get-AzureRMWebAppConnectionDetailsWithProductionSlot # construct object to store webApp connection details $azureRMWebAppConnectionDetailsWithProductionSlot = Construct-AzureWebAppConnectionObject -kuduHostName $kuduHostName -webAppProfileForMSDeploy $webAppProfileForMSDeploy - Write-Host (Get-LocalizedString -Key "Got connection details for azureRM WebApp:'{0}' under Production Slot." -ArgumentList $webAppName) + Write-Host (Get-VstsLocString -Key "GotconnectiondetailsforazureRMWebApp0underProductionSlot" -ArgumentList $webAppName) return $azureRMWebAppConnectionDetailsWithProductionSlot } diff --git a/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson index 58932a5daacf..905eee3eee0a 100644 --- a/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson @@ -29,5 +29,25 @@ "loc.input.label.AdditionalArguments": "Additional Arguments", "loc.input.help.AdditionalArguments": "Additional Web Deploy arguments that will be applied when deploying the Azure Web App like,-disableLink:AppPoolExtension -disableLink:ContentExtension.", "loc.input.label.WebAppUri": "Web App Hosted Url", - "loc.input.help.WebAppUri": "Provide a name for the variable for the webapp hosted url. The variable can be used as $(variableName) to refer to the hosted url of webapp in subsequent tasks like in the PowerShell on Target Machines task." + "loc.input.help.WebAppUri": "Provide a name for the variable for the webapp hosted url. The variable can be used as $(variableName) to refer to the hosted url of webapp in subsequent tasks like in the PowerShell on Target Machines task.", + "loc.messages.Invalidwebapppackagepathprovided": "Invalid webapp package path provided", + "loc.messages.WebappsuccessfullypublishedatUrl0": "Webapp successfully published at Url : {0}", + "loc.messages.Unabletoretrievewebapppublishurlforwebapp0": "Unable to retrieve webapp publish url for webapp : '{0}'.", + "loc.messages.GettingconnectiondetailsforazureRMWebApp0underSlot1": "Getting connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", + "loc.messages.GotconnectiondetailsforazureRMWebApp0underSlot1": "Got connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", + "loc.messages.GettingconnectiondetailsforazureRMWebApp0underProductionSlot": "Getting connection details for azureRM WebApp:'{0}' under Production Slot.", + "loc.messages.WebApp0doesnotexist": "WebApp '{0}' does not exist.", + "loc.messages.GotconnectiondetailsforazureRMWebApp0underProductionSlot": "Got connection details for azureRM WebApp:'{0}' under Production Slot.", + "loc.messages.WebApp0notfound": "Web App: '{0}' not found.", + "loc.messages.Unabletofindwebapppublishprofiledetailsforwebapp0": "Unable to find webapp publish profile details for webapp {0}.", + "loc.messages.UsinglocalMSDeployexe": "Using local MSDeploy.exe", + "loc.messages.msdeployexeislocatedat0": "msdeploy.exe is located at '{0}'", + "loc.messages.Foundmorethanonefiletodeploywithsearchpattern0Therecanbeonlyone": "Found more than one file to deploy with search pattern {0}. There can be only one.", + "loc.messages.Nofileswerefoundtodeploywithsearchpattern0": "No files were found to deploy with search pattern {0}.", + "loc.messages.packageFileFindFilesSearchPattern0": "packageFile = Find-Files -SearchPattern {0}", + "loc.messages.packageFile0": "packageFile = {0}", + "loc.messages.Runningmsdeploycommand0": "Running msdeploy command: `n`t{0}", + "loc.messages.msdeploycommandransuccessfully": "msdeploy command ran successfully.", + "loc.messages.filePathFindFilesSearchPattern0": "filePath = Find-Files -SearchPattern {0}", + "loc.messages.filePath0": "filePath = {0}" } \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/Utility.ps1 b/Tasks/AzureRmWebAppDeployment/Utility.ps1 index a9c4fb0911c2..62055c337c66 100644 --- a/Tasks/AzureRmWebAppDeployment/Utility.ps1 +++ b/Tasks/AzureRmWebAppDeployment/Utility.ps1 @@ -19,14 +19,14 @@ function Get-MsDeployExePath if( [string]::IsNullOrEmpty($MSDeployExePath) ) { - Write-Verbose (Get-LocalizedString -Key "Using local MSDeploy.exe") + Write-Verbose (Get-VstsLocString -Key "UsinglocalMSDeployexe") $currentDir = (Get-Item -Path ".\").FullName $msDeployExeDir = Join-Path $currentDir "MSDeploy3.6" $MSDeployExePath = Join-Path $msDeployExeDir "msdeploy.exe" } - Write-Host (Get-LocalizedString -Key "msdeploy.exe is located at '{0}'" -ArgumentList $MSDeployExePath) + Write-Host (Get-VstsLocString -Key msdeployexeislocatedat0 -ArgumentList $MSDeployExePath) return $MSDeployExePath } @@ -38,13 +38,13 @@ function Get-SingleFile if ($files -is [system.array]) { - throw (Get-LocalizedString -Key "Found more than one file to deploy with search pattern {0}. There can be only one." -ArgumentList $pattern) + throw (Get-VstsLocString -Key Foundmorethanonefiletodeploywithsearchpattern0Therecanbeonlyone -ArgumentList $pattern) } else { if (!$files) { - throw (Get-LocalizedString -Key "No files were found to deploy with search pattern {0}." -ArgumentList $pattern) + throw (Get-VstsLocString -Key Nofileswerefoundtodeploywithsearchpattern0 -ArgumentList $pattern) } return $files @@ -55,9 +55,9 @@ function Get-SingleFilePath { param([String][Parameter(Mandatory=$true)] $file) - Write-Host (Get-LocalizedString -Key "filePath = Find-Files -SearchPattern {0}" -ArgumentList $file) - $filePath = Find-Files -SearchPattern $file - Write-Host (Get-LocalizedString -Key "filePath = {0}" -ArgumentList $filePath) + Write-Host (Get-VstsLocString -Key filePathFindFilesSearchPattern0 -ArgumentList $file) + $filePath = Find-VstsFiles -LegacyPattern $file + Write-Host (Get-VstsLocString -Key filePath0 -ArgumentList $filePath) $filePath = Get-SingleFile -files $filePath -pattern $file return $filePath @@ -182,7 +182,7 @@ function Run-MsDeployCommand $msDeployCmd = "`"$msDeployExePath`" $msDeployCmdArgs" $msDeployCmdForLogs = Get-MsDeployCmdForLogs -msDeployCmd $msDeployCmd - Write-Host (Get-LocalizedString -Key "Running msdeploy command: `n`t{0}" -ArgumentList $msDeployCmdForLogs) + Write-Host (Get-VstsLocString -Key Runningmsdeploycommand0 -ArgumentList $msDeployCmdForLogs) Run-Command -command $msDeployCmd - Write-Host (Get-LocalizedString -Key "msdeploy command ran successfully.") + Write-Host (Get-VstsLocString -Key msdeploycommandransuccessfully ) } \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index 6884c880b395..0f02d50c1667 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -1,178 +1,197 @@ -{ - "id": "497D490F-EEA7-4F2B-AB94-48D9C1ACDCB1", - "name": "AzureRMWebAppDeployment", - "friendlyName": "AzureRM Web App Deployment ( Preview )", - "description": "Deploy the web project to the AzureRM Web App using Web Deploy", - "helpMarkDown": "[More Information](http://aka.ms/azurermwebdeployreadme)", - "category": "Deploy", +{ + "id": "497D490F-EEA7-4F2B-AB94-48D9C1ACDCB1", + "name": "AzureRMWebAppDeployment", + "friendlyName": "AzureRM Web App Deployment ( Preview )", + "description": "Deploy the web project to the AzureRM Web App using Web Deploy", + "helpMarkDown": "[More Information](http://aka.ms/azurermwebdeployreadme)", + "category": "Deploy", "visibility": [ - "Preview", "Build", "Release" ], - "author": "Microsoft Corporation", - "version": { - "Major": 1, - "Minor": 0, - "Patch": 5 + "author": "Microsoft Corporation", + "version": { + "Major": 1, + "Minor": 0, + "Patch": 6 + }, + "minimumAgentVersion": "1.99.0", + "groups": [ + { + "name": "output", + "displayName": "Output", + "isExpanded": true + } + ], + "inputs": [ + { + "name": "ConnectedServiceName", + "type": "connectedService:AzureRM", + "label": "AzureRM Subscription", + "defaultValue": "", + "required": true, + "helpMarkDown": "Select the Azure Resource Manager subscription for the deployment." + }, + { + "name": "WebAppName", + "type": "pickList", + "label": "Web App Name", + "defaultValue": "", + "required": true, + "properties": { + "EditableOptions": "True" + }, + "helpMarkDown": "Enter or Select the name of an existing AzureRM Web Application." + }, + { + "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 AzureRM Web App will be deployed to the Production slot." + }, + { + "name": "ResourceGroupName", + "type": "pickList", + "label": "Resource Group", + "defaultValue": "", + "required": true, + "properties": { + "EditableOptions": "True" + }, + "helpMarkDown": "Enter or Select the Azure Resource Group that contains the AzureRM Web App 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": "Package", + "type": "filePath", + "label": "Package", + "defaultValue": "", + "required": true, + "helpMarkDown": "Location of the Web App zip package on the automation agent or on a UNC path accessible to the automation agent like, \\\\\\\\BudgetIT\\Web\\Deploy\\Fabrikam.zip. Predefined system variables and wild cards like, $(System.DefaultWorkingDirectory)\\\\***.zip` can be also used here." + }, + { + "name": "SetParametersFile", + "type": "filePath", + "label": "SetParameters File", + "defaultValue": "", + "required": false, + "helpMarkDown": "Optional: location of the SetParameters.xml file to use." + }, + { + "name": "RemoveAdditionalFilesFlag", + "type": "boolean", + "label": "Remove Additional Files at Destination", + "defaultValue": "false", + "required": false, + "helpMarkDown": "Select the option to delete files on the AzureRM Web App that have no matching files in the Web App zip package." + }, + { + "name": "ExcludeFilesFromAppDataFlag", + "type": "boolean", + "label": "Exclude Files from the App_Data Folder", + "defaultValue": "false", + "required": false, + "helpMarkDown": "Select the option to prevent files in the App_Data folder from being deployed to the AzureRM Web App." }, - "minimumAgentVersion": "1.99.0", - "groups": [ - { - "name": "output", - "displayName": "Output", - "isExpanded": true - } - ], - "inputs": [ - { - "name": "ConnectedServiceName", - "type": "connectedService:AzureRM", - "label": "AzureRM Subscription", - "defaultValue": "", - "required": true, - "helpMarkDown": "Select the Azure Resource Manager subscription for the deployment." - }, - { - "name": "WebAppName", - "type": "pickList", - "label": "Web App Name", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Enter or Select the name of an existing AzureRM Web Application." - }, - { - "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 AzureRM Web App will be deployed to the Production slot." - }, - { - "name": "ResourceGroupName", - "type": "pickList", - "label": "Resource Group", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Enter or Select the Azure Resource Group that contains the AzureRM Web App 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": "Package", - "type": "filePath", - "label": "Package", - "defaultValue": "", - "required": true, - "helpMarkDown": "Location of the Web App zip package on the automation agent or on a UNC path accessible to the automation agent like, \\\\\\\\BudgetIT\\Web\\Deploy\\Fabrikam.zip. Predefined system variables and wild cards like, $(System.DefaultWorkingDirectory)\\\\***.zip` can be also used here." - }, - { - "name": "SetParametersFile", - "type": "filePath", - "label": "SetParameters File", - "defaultValue": "", - "required": false, - "helpMarkDown": "Optional: location of the SetParameters.xml file to use." - }, - { - "name": "RemoveAdditionalFilesFlag", - "type": "boolean", - "label": "Remove Additional Files at Destination", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Select the option to delete files on the AzureRM Web App that have no matching files in the Web App zip package." - }, - { - "name": "ExcludeFilesFromAppDataFlag", - "type": "boolean", - "label": "Exclude Files from the App_Data Folder", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Select the option to prevent files in the App_Data folder from being deployed to the AzureRM Web App." - }, - { - "name": "TakeAppOfflineFlag", - "type": "boolean", - "label": "Take App Offline", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Select the option to take the AzureRM Web App offline by placing an app_offline.htm file in the root directory of the Web App before the sync operation begins. The file will be removed after the sync operation completes successfully." - }, - { - "name": "VirtualApplication", - "type": "string", - "label": "Virtual Application", - "defaultValue": "", - "required": false, - "helpMarkDown": "Specify the name of the Virtual Application that has been configured in the Azure portal. The option is not required for deployments to the website root." - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "required": false, - "defaultValue": "", - "helpMarkDown": "Additional Web Deploy arguments that will be applied when deploying the Azure Web App like,-disableLink:AppPoolExtension -disableLink:ContentExtension." - }, - { - "name": "WebAppUri", - "type": "string", - "label": "Web App Hosted Url", - "required": false, - "defaultValue": "", - "groupName": "output", - "helpMarkDown": "Provide a name for the variable for the webapp hosted url. The variable can be used as $(variableName) to refer to the hosted url of webapp in subsequent tasks like in the PowerShell on Target Machines task." - } - ], - "dataSourceBindings": [ - { - "target": "WebAppName", - "endpointId": "$(ConnectedServiceName)", - "dataSourceName": "AzureRMWebAppNames" - }, - { - "target": "ResourceGroupName", - "endpointId": "$(ConnectedServiceName)", - "dataSourceName": "AzureRMWebAppResourceGroup", - "parameters": { - "WebAppName": "$(WebAppName)" - } - }, - { - "target": "SlotName", - "endpointId": "$(ConnectedServiceName)", - "dataSourceName": "AzureRMWebAppSlotsId", - "parameters": { - "WebAppName": "$(WebAppName)", - "ResourceGroupName": "$(ResourceGroupName)" - }, - "resultTemplate": "{{#extractResource slots}}" - } - ], - "instanceNameFormat": "Deploy AzureRM Web App: $(WebAppName)", - "execution": { - "AzurePowerShell": { - "target": "$(currentDirectory)\\AzureRMWebAppDeployment.ps1", - "argumentFormat": "", - "workingDirectory": "$(currentDirectory)" - } + { + "name": "TakeAppOfflineFlag", + "type": "boolean", + "label": "Take App Offline", + "defaultValue": "false", + "required": false, + "helpMarkDown": "Select the option to take the AzureRM Web App offline by placing an app_offline.htm file in the root directory of the Web App before the sync operation begins. The file will be removed after the sync operation completes successfully." + }, + { + "name": "VirtualApplication", + "type": "string", + "label": "Virtual Application", + "defaultValue": "", + "required": false, + "helpMarkDown": "Specify the name of the Virtual Application that has been configured in the Azure portal. The option is not required for deployments to the website root." + }, + { + "name": "AdditionalArguments", + "type": "string", + "label": "Additional Arguments", + "required": false, + "defaultValue": "", + "helpMarkDown": "Additional Web Deploy arguments that will be applied when deploying the Azure Web App like,-disableLink:AppPoolExtension -disableLink:ContentExtension." + }, + { + "name": "WebAppUri", + "type": "string", + "label": "Web App Hosted Url", + "required": false, + "defaultValue": "", + "groupName": "output", + "helpMarkDown": "Provide a name for the variable for the webapp hosted url. The variable can be used as $(variableName) to refer to the hosted url of webapp in subsequent tasks like in the PowerShell on Target Machines task." + } + ], + "dataSourceBindings": [ + { + "target": "WebAppName", + "endpointId": "$(ConnectedServiceName)", + "dataSourceName": "AzureRMWebAppNames" + }, + { + "target": "ResourceGroupName", + "endpointId": "$(ConnectedServiceName)", + "dataSourceName": "AzureRMWebAppResourceGroup", + "parameters": { + "WebAppName": "$(WebAppName)" + } + }, + { + "target": "SlotName", + "endpointId": "$(ConnectedServiceName)", + "dataSourceName": "AzureRMWebAppSlotsId", + "parameters": { + "WebAppName": "$(WebAppName)", + "ResourceGroupName": "$(ResourceGroupName)" + }, + "resultTemplate": "{{#extractResource slots}}" + } + ], + "instanceNameFormat": "Deploy AzureRM Web App: $(WebAppName)", + "execution": { + "PowerShell3": { + "target": "AzureRMWebAppDeployment.ps1" } + }, + "messages": { + "Invalidwebapppackagepathprovided": "Invalid webapp package path provided", + "WebappsuccessfullypublishedatUrl0": "Webapp successfully published at Url : {0}", + "Unabletoretrievewebapppublishurlforwebapp0": "Unable to retrieve webapp publish url for webapp : '{0}'.", + "GettingconnectiondetailsforazureRMWebApp0underSlot1": "Getting connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", + "GotconnectiondetailsforazureRMWebApp0underSlot1": "Got connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", + "GettingconnectiondetailsforazureRMWebApp0underProductionSlot": "Getting connection details for azureRM WebApp:'{0}' under Production Slot.", + "WebApp0doesnotexist": "WebApp '{0}' does not exist.", + "GotconnectiondetailsforazureRMWebApp0underProductionSlot": "Got connection details for azureRM WebApp:'{0}' under Production Slot.", + "WebApp0notfound": "Web App: '{0}' not found.", + "Unabletofindwebapppublishprofiledetailsforwebapp0": "Unable to find webapp publish profile details for webapp {0}.", + "UsinglocalMSDeployexe": "Using local MSDeploy.exe", + "msdeployexeislocatedat0": "msdeploy.exe is located at '{0}'", + "Foundmorethanonefiletodeploywithsearchpattern0Therecanbeonlyone": "Found more than one file to deploy with search pattern {0}. There can be only one.", + "Nofileswerefoundtodeploywithsearchpattern0": "No files were found to deploy with search pattern {0}.", + "packageFileFindFilesSearchPattern0": "packageFile = Find-Files -SearchPattern {0}", + "packageFile0": "packageFile = {0}", + "Runningmsdeploycommand0": "Running msdeploy command: `n`t{0}", + "msdeploycommandransuccessfully": "msdeploy command ran successfully.", + "filePathFindFilesSearchPattern0": "filePath = Find-Files -SearchPattern {0}", + "filePath0":"filePath = {0}" + } } \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/task.loc.json b/Tasks/AzureRmWebAppDeployment/task.loc.json index 43dc74d55706..c21b965f5d12 100644 --- a/Tasks/AzureRmWebAppDeployment/task.loc.json +++ b/Tasks/AzureRmWebAppDeployment/task.loc.json @@ -6,7 +6,6 @@ "helpMarkDown": "ms-resource:loc.helpMarkDown", "category": "Deploy", "visibility": [ - "Preview", "Build", "Release" ], @@ -14,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 4 + "Patch": 6 }, "minimumAgentVersion": "1.99.0", "groups": [ @@ -169,10 +168,30 @@ ], "instanceNameFormat": "ms-resource:loc.instanceNameFormat", "execution": { - "AzurePowerShell": { - "target": "$(currentDirectory)\\AzureRMWebAppDeployment.ps1", - "argumentFormat": "", - "workingDirectory": "$(currentDirectory)" + "PowerShell3": { + "target": "AzureRMWebAppDeployment.ps1" } + }, + "messages": { + "Invalidwebapppackagepathprovided": "ms-resource:loc.messages.Invalidwebapppackagepathprovided", + "WebappsuccessfullypublishedatUrl0": "ms-resource:loc.messages.WebappsuccessfullypublishedatUrl0", + "Unabletoretrievewebapppublishurlforwebapp0": "ms-resource:loc.messages.Unabletoretrievewebapppublishurlforwebapp0", + "GettingconnectiondetailsforazureRMWebApp0underSlot1": "ms-resource:loc.messages.GettingconnectiondetailsforazureRMWebApp0underSlot1", + "GotconnectiondetailsforazureRMWebApp0underSlot1": "ms-resource:loc.messages.GotconnectiondetailsforazureRMWebApp0underSlot1", + "GettingconnectiondetailsforazureRMWebApp0underProductionSlot": "ms-resource:loc.messages.GettingconnectiondetailsforazureRMWebApp0underProductionSlot", + "WebApp0doesnotexist": "ms-resource:loc.messages.WebApp0doesnotexist", + "GotconnectiondetailsforazureRMWebApp0underProductionSlot": "ms-resource:loc.messages.GotconnectiondetailsforazureRMWebApp0underProductionSlot", + "WebApp0notfound": "ms-resource:loc.messages.WebApp0notfound", + "Unabletofindwebapppublishprofiledetailsforwebapp0": "ms-resource:loc.messages.Unabletofindwebapppublishprofiledetailsforwebapp0", + "UsinglocalMSDeployexe": "ms-resource:loc.messages.UsinglocalMSDeployexe", + "msdeployexeislocatedat0": "ms-resource:loc.messages.msdeployexeislocatedat0", + "Foundmorethanonefiletodeploywithsearchpattern0Therecanbeonlyone": "ms-resource:loc.messages.Foundmorethanonefiletodeploywithsearchpattern0Therecanbeonlyone", + "Nofileswerefoundtodeploywithsearchpattern0": "ms-resource:loc.messages.Nofileswerefoundtodeploywithsearchpattern0", + "packageFileFindFilesSearchPattern0": "ms-resource:loc.messages.packageFileFindFilesSearchPattern0", + "packageFile0": "ms-resource:loc.messages.packageFile0", + "Runningmsdeploycommand0": "ms-resource:loc.messages.Runningmsdeploycommand0", + "msdeploycommandransuccessfully": "ms-resource:loc.messages.msdeploycommandransuccessfully", + "filePathFindFilesSearchPattern0": "ms-resource:loc.messages.filePathFindFilesSearchPattern0", + "filePath0": "ms-resource:loc.messages.filePath0" } } \ No newline at end of file diff --git a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 index db11a2b5c41b..f774ed715bd4 100644 --- a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 +++ b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 @@ -51,5 +51,41 @@ function Initialize-Azure { } } +function Get-AzureCmdletsVersion +{ + $module = Get-Module -Name AzureRM* -ListAvailable | Select-Object -First 1 + if($module) + { + return ($module).Version + } + return (Get-Module Azure -ListAvailable).Version +} + +function Get-AzureVersionComparison +{ + param + ( + [System.Version] [Parameter(Mandatory = $true)] + $AzureVersion, + + [System.Version] [Parameter(Mandatory = $true)] + $CompareVersion + ) + + $result = $AzureVersion.CompareTo($CompareVersion) + + if ($result -lt 0) + { + #AzureVersion is before CompareVersion + return $false + } + else + { + return $true + } +} + # Export only the public function. +Export-ModuleMember -Function Get-AzureVersionComparison +Export-ModuleMember -Function Get-AzureCmdletsVersion Export-ModuleMember -Function Initialize-Azure \ No newline at end of file diff --git a/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson b/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson index d78ee6f36873..a30e73c151a4 100644 --- a/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson @@ -6,7 +6,7 @@ "loc.group.displayName.junitTestResults": "JUnit Test Results", "loc.group.displayName.codeCoverage": "Code Coverage", "loc.group.displayName.advanced": "Advanced", - "loc.group.displayName.SQAnalysis": "SonarQube Analysis", + "loc.group.displayName.CodeAnalysis": "Code Analysis", "loc.input.label.mavenPOMFile": "Maven POM file", "loc.input.help.mavenPOMFile": "Relative path from the repository root to the Maven POM file.", "loc.input.label.options": "Options", @@ -50,5 +50,11 @@ "loc.input.label.sqDbUsername": "Db Username", "loc.input.help.sqDbUsername": "SonarQube server 5.1 and lower only. Enter the username for the database user (i.e. sonar.jdbc.username).", "loc.input.label.sqDbPassword": "Db User Password", - "loc.input.help.sqDbPassword": "SonarQube server 5.1 and lower only. Enter the password for the database user i.e. sonar.jdbc.password" + "loc.input.help.sqDbPassword": "SonarQube server 5.1 and lower only. Enter the password for the database user i.e. sonar.jdbc.password", + "loc.input.label.pmdAnalysisEnabled": "Run PMD Analysis", + "loc.input.help.pmdAnalysisEnabled": "Use the PMD Java static analysis tool to look for bugs in the code.", + "loc.messages.codeAnalysisBuildSummaryLine_SomeViolationsSomeFiles": "%s found %d violations in %d files.", + "loc.messages.codeAnalysisBuildSummaryLine_SomeViolationsOneFile": "%s found %d violations in 1 file.", + "loc.messages.codeAnalysisBuildSummaryLine_OneViolationOneFile": "%s found 1 violation in 1 file.", + "loc.messages.codeAnalysisBuildSummaryLine_NoViolations": "%s found no violations." } \ No newline at end of file diff --git a/common.json b/common.json index c66dc74eea46..0820adc1925c 100644 --- a/common.json +++ b/common.json @@ -4,6 +4,12 @@ "module": "VstsAzureHelpers_", "dest": "ps_modules" } + ], + "AzureRMWebAppDeployment": [ + { + "module": "VstsAzureHelpers_", + "dest": "ps_modules" + } ], "MSBuild": [ { From b673c1277a9144350663a605ca4d2ac122be7032 Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Fri, 27 May 2016 13:08:27 +0530 Subject: [PATCH 02/12] Indentation correction --- Tasks/MSBuild/task.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tasks/MSBuild/task.json b/Tasks/MSBuild/task.json index cb3a1127cdb0..6a44919b8fd4 100644 --- a/Tasks/MSBuild/task.json +++ b/Tasks/MSBuild/task.json @@ -1,11 +1,11 @@ { - "id": "C6C4C611-AA2E-4A33-B606-5EABA2196824", - "name": "MSBuild", - "friendlyName": "MSBuild", - "description": "Build with MSBuild", - "helpMarkDown": "[More Information](http://go.microsoft.com/fwlink/?LinkID=613724)", - "category": "Build", - "visibility": [ + "id": "C6C4C611-AA2E-4A33-B606-5EABA2196824", + "name": "MSBuild", + "friendlyName": "MSBuild", + "description": "Build with MSBuild", + "helpMarkDown": "[More Information](http://go.microsoft.com/fwlink/?LinkID=613724)", + "category": "Build", + "visibility": [ "Build" ], "author": "Microsoft Corporation", From c2f562369fe1e9089216c39b5ed6960d2cf976ad Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Fri, 27 May 2016 13:46:52 +0530 Subject: [PATCH 03/12] indentation corrections --- Tasks/AzureRmWebAppDeployment/task.json | 376 ++++++++++++------------ 1 file changed, 188 insertions(+), 188 deletions(-) diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index 0f02d50c1667..95404091e30e 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -1,197 +1,197 @@ { - "id": "497D490F-EEA7-4F2B-AB94-48D9C1ACDCB1", - "name": "AzureRMWebAppDeployment", - "friendlyName": "AzureRM Web App Deployment ( Preview )", - "description": "Deploy the web project to the AzureRM Web App using Web Deploy", - "helpMarkDown": "[More Information](http://aka.ms/azurermwebdeployreadme)", - "category": "Deploy", + "id": "497D490F-EEA7-4F2B-AB94-48D9C1ACDCB1", + "name": "AzureRMWebAppDeployment", + "friendlyName": "AzureRM Web App Deployment ( Preview )", + "description": "Deploy the web project to the AzureRM Web App using Web Deploy", + "helpMarkDown": "[More Information](http://aka.ms/azurermwebdeployreadme)", + "category": "Deploy", "visibility": [ "Build", "Release" ], - "author": "Microsoft Corporation", - "version": { - "Major": 1, - "Minor": 0, - "Patch": 6 - }, - "minimumAgentVersion": "1.99.0", - "groups": [ - { - "name": "output", - "displayName": "Output", - "isExpanded": true - } - ], - "inputs": [ - { - "name": "ConnectedServiceName", - "type": "connectedService:AzureRM", - "label": "AzureRM Subscription", - "defaultValue": "", - "required": true, - "helpMarkDown": "Select the Azure Resource Manager subscription for the deployment." - }, - { - "name": "WebAppName", - "type": "pickList", - "label": "Web App Name", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Enter or Select the name of an existing AzureRM Web Application." - }, - { - "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 AzureRM Web App will be deployed to the Production slot." - }, - { - "name": "ResourceGroupName", - "type": "pickList", - "label": "Resource Group", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Enter or Select the Azure Resource Group that contains the AzureRM Web App 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": "Package", - "type": "filePath", - "label": "Package", - "defaultValue": "", - "required": true, - "helpMarkDown": "Location of the Web App zip package on the automation agent or on a UNC path accessible to the automation agent like, \\\\\\\\BudgetIT\\Web\\Deploy\\Fabrikam.zip. Predefined system variables and wild cards like, $(System.DefaultWorkingDirectory)\\\\***.zip` can be also used here." - }, - { - "name": "SetParametersFile", - "type": "filePath", - "label": "SetParameters File", - "defaultValue": "", - "required": false, - "helpMarkDown": "Optional: location of the SetParameters.xml file to use." - }, - { - "name": "RemoveAdditionalFilesFlag", - "type": "boolean", - "label": "Remove Additional Files at Destination", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Select the option to delete files on the AzureRM Web App that have no matching files in the Web App zip package." + "author": "Microsoft Corporation", + "version": { + "Major": 1, + "Minor": 0, + "Patch": 6 }, - { - "name": "ExcludeFilesFromAppDataFlag", - "type": "boolean", - "label": "Exclude Files from the App_Data Folder", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Select the option to prevent files in the App_Data folder from being deployed to the AzureRM Web App." + "minimumAgentVersion": "1.99.0", + "groups": [ + { + "name": "output", + "displayName": "Output", + "isExpanded": true + } + ], + "inputs": [ + { + "name": "ConnectedServiceName", + "type": "connectedService:AzureRM", + "label": "AzureRM Subscription", + "defaultValue": "", + "required": true, + "helpMarkDown": "Select the Azure Resource Manager subscription for the deployment." + }, + { + "name": "WebAppName", + "type": "pickList", + "label": "Web App Name", + "defaultValue": "", + "required": true, + "properties": { + "EditableOptions": "True" + }, + "helpMarkDown": "Enter or Select the name of an existing AzureRM Web Application." + }, + { + "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 AzureRM Web App will be deployed to the Production slot." + }, + { + "name": "ResourceGroupName", + "type": "pickList", + "label": "Resource Group", + "defaultValue": "", + "required": true, + "properties": { + "EditableOptions": "True" + }, + "helpMarkDown": "Enter or Select the Azure Resource Group that contains the AzureRM Web App 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": "Package", + "type": "filePath", + "label": "Package", + "defaultValue": "", + "required": true, + "helpMarkDown": "Location of the Web App zip package on the automation agent or on a UNC path accessible to the automation agent like, \\\\\\\\BudgetIT\\Web\\Deploy\\Fabrikam.zip. Predefined system variables and wild cards like, $(System.DefaultWorkingDirectory)\\\\***.zip` can be also used here." + }, + { + "name": "SetParametersFile", + "type": "filePath", + "label": "SetParameters File", + "defaultValue": "", + "required": false, + "helpMarkDown": "Optional: location of the SetParameters.xml file to use." + }, + { + "name": "RemoveAdditionalFilesFlag", + "type": "boolean", + "label": "Remove Additional Files at Destination", + "defaultValue": "false", + "required": false, + "helpMarkDown": "Select the option to delete files on the AzureRM Web App that have no matching files in the Web App zip package." + }, + { + "name": "ExcludeFilesFromAppDataFlag", + "type": "boolean", + "label": "Exclude Files from the App_Data Folder", + "defaultValue": "false", + "required": false, + "helpMarkDown": "Select the option to prevent files in the App_Data folder from being deployed to the AzureRM Web App." + }, + { + "name": "TakeAppOfflineFlag", + "type": "boolean", + "label": "Take App Offline", + "defaultValue": "false", + "required": false, + "helpMarkDown": "Select the option to take the AzureRM Web App offline by placing an app_offline.htm file in the root directory of the Web App before the sync operation begins. The file will be removed after the sync operation completes successfully." + }, + { + "name": "VirtualApplication", + "type": "string", + "label": "Virtual Application", + "defaultValue": "", + "required": false, + "helpMarkDown": "Specify the name of the Virtual Application that has been configured in the Azure portal. The option is not required for deployments to the website root." + }, + { + "name": "AdditionalArguments", + "type": "string", + "label": "Additional Arguments", + "required": false, + "defaultValue": "", + "helpMarkDown": "Additional Web Deploy arguments that will be applied when deploying the Azure Web App like,-disableLink:AppPoolExtension -disableLink:ContentExtension." + }, + { + "name": "WebAppUri", + "type": "string", + "label": "Web App Hosted Url", + "required": false, + "defaultValue": "", + "groupName": "output", + "helpMarkDown": "Provide a name for the variable for the webapp hosted url. The variable can be used as $(variableName) to refer to the hosted url of webapp in subsequent tasks like in the PowerShell on Target Machines task." + } + ], + "dataSourceBindings": [ + { + "target": "WebAppName", + "endpointId": "$(ConnectedServiceName)", + "dataSourceName": "AzureRMWebAppNames" + }, + { + "target": "ResourceGroupName", + "endpointId": "$(ConnectedServiceName)", + "dataSourceName": "AzureRMWebAppResourceGroup", + "parameters": { + "WebAppName": "$(WebAppName)" + } + }, + { + "target": "SlotName", + "endpointId": "$(ConnectedServiceName)", + "dataSourceName": "AzureRMWebAppSlotsId", + "parameters": { + "WebAppName": "$(WebAppName)", + "ResourceGroupName": "$(ResourceGroupName)" + }, + "resultTemplate": "{{#extractResource slots}}" + } + ], + "instanceNameFormat": "Deploy AzureRM Web App: $(WebAppName)", + "execution": { + "PowerShell3": { + "target": "AzureRMWebAppDeployment.ps1" + } }, - { - "name": "TakeAppOfflineFlag", - "type": "boolean", - "label": "Take App Offline", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Select the option to take the AzureRM Web App offline by placing an app_offline.htm file in the root directory of the Web App before the sync operation begins. The file will be removed after the sync operation completes successfully." - }, - { - "name": "VirtualApplication", - "type": "string", - "label": "Virtual Application", - "defaultValue": "", - "required": false, - "helpMarkDown": "Specify the name of the Virtual Application that has been configured in the Azure portal. The option is not required for deployments to the website root." - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "required": false, - "defaultValue": "", - "helpMarkDown": "Additional Web Deploy arguments that will be applied when deploying the Azure Web App like,-disableLink:AppPoolExtension -disableLink:ContentExtension." - }, - { - "name": "WebAppUri", - "type": "string", - "label": "Web App Hosted Url", - "required": false, - "defaultValue": "", - "groupName": "output", - "helpMarkDown": "Provide a name for the variable for the webapp hosted url. The variable can be used as $(variableName) to refer to the hosted url of webapp in subsequent tasks like in the PowerShell on Target Machines task." - } - ], - "dataSourceBindings": [ - { - "target": "WebAppName", - "endpointId": "$(ConnectedServiceName)", - "dataSourceName": "AzureRMWebAppNames" - }, - { - "target": "ResourceGroupName", - "endpointId": "$(ConnectedServiceName)", - "dataSourceName": "AzureRMWebAppResourceGroup", - "parameters": { - "WebAppName": "$(WebAppName)" - } - }, - { - "target": "SlotName", - "endpointId": "$(ConnectedServiceName)", - "dataSourceName": "AzureRMWebAppSlotsId", - "parameters": { - "WebAppName": "$(WebAppName)", - "ResourceGroupName": "$(ResourceGroupName)" - }, - "resultTemplate": "{{#extractResource slots}}" - } - ], - "instanceNameFormat": "Deploy AzureRM Web App: $(WebAppName)", - "execution": { - "PowerShell3": { - "target": "AzureRMWebAppDeployment.ps1" + "messages": { + "Invalidwebapppackagepathprovided": "Invalid webapp package path provided", + "WebappsuccessfullypublishedatUrl0": "Webapp successfully published at Url : {0}", + "Unabletoretrievewebapppublishurlforwebapp0": "Unable to retrieve webapp publish url for webapp : '{0}'.", + "GettingconnectiondetailsforazureRMWebApp0underSlot1": "Getting connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", + "GotconnectiondetailsforazureRMWebApp0underSlot1": "Got connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", + "GettingconnectiondetailsforazureRMWebApp0underProductionSlot": "Getting connection details for azureRM WebApp:'{0}' under Production Slot.", + "WebApp0doesnotexist": "WebApp '{0}' does not exist.", + "GotconnectiondetailsforazureRMWebApp0underProductionSlot": "Got connection details for azureRM WebApp:'{0}' under Production Slot.", + "WebApp0notfound": "Web App: '{0}' not found.", + "Unabletofindwebapppublishprofiledetailsforwebapp0": "Unable to find webapp publish profile details for webapp {0}.", + "UsinglocalMSDeployexe": "Using local MSDeploy.exe", + "msdeployexeislocatedat0": "msdeploy.exe is located at '{0}'", + "Foundmorethanonefiletodeploywithsearchpattern0Therecanbeonlyone": "Found more than one file to deploy with search pattern {0}. There can be only one.", + "Nofileswerefoundtodeploywithsearchpattern0": "No files were found to deploy with search pattern {0}.", + "packageFileFindFilesSearchPattern0": "packageFile = Find-Files -SearchPattern {0}", + "packageFile0": "packageFile = {0}", + "Runningmsdeploycommand0": "Running msdeploy command: `n`t{0}", + "msdeploycommandransuccessfully": "msdeploy command ran successfully.", + "filePathFindFilesSearchPattern0": "filePath = Find-Files -SearchPattern {0}", + "filePath0":"filePath = {0}" } - }, - "messages": { - "Invalidwebapppackagepathprovided": "Invalid webapp package path provided", - "WebappsuccessfullypublishedatUrl0": "Webapp successfully published at Url : {0}", - "Unabletoretrievewebapppublishurlforwebapp0": "Unable to retrieve webapp publish url for webapp : '{0}'.", - "GettingconnectiondetailsforazureRMWebApp0underSlot1": "Getting connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", - "GotconnectiondetailsforazureRMWebApp0underSlot1": "Got connection details for azureRM WebApp:'{0}' under Slot:'{1}'.", - "GettingconnectiondetailsforazureRMWebApp0underProductionSlot": "Getting connection details for azureRM WebApp:'{0}' under Production Slot.", - "WebApp0doesnotexist": "WebApp '{0}' does not exist.", - "GotconnectiondetailsforazureRMWebApp0underProductionSlot": "Got connection details for azureRM WebApp:'{0}' under Production Slot.", - "WebApp0notfound": "Web App: '{0}' not found.", - "Unabletofindwebapppublishprofiledetailsforwebapp0": "Unable to find webapp publish profile details for webapp {0}.", - "UsinglocalMSDeployexe": "Using local MSDeploy.exe", - "msdeployexeislocatedat0": "msdeploy.exe is located at '{0}'", - "Foundmorethanonefiletodeploywithsearchpattern0Therecanbeonlyone": "Found more than one file to deploy with search pattern {0}. There can be only one.", - "Nofileswerefoundtodeploywithsearchpattern0": "No files were found to deploy with search pattern {0}.", - "packageFileFindFilesSearchPattern0": "packageFile = Find-Files -SearchPattern {0}", - "packageFile0": "packageFile = {0}", - "Runningmsdeploycommand0": "Running msdeploy command: `n`t{0}", - "msdeploycommandransuccessfully": "msdeploy command ran successfully.", - "filePathFindFilesSearchPattern0": "filePath = Find-Files -SearchPattern {0}", - "filePath0":"filePath = {0}" - } } \ No newline at end of file From 416de2a3c9b8d1919dfc467130c81bbaa7aa9033 Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Mon, 30 May 2016 18:19:50 +0530 Subject: [PATCH 04/12] Git hub review corrections --- .../AzureRmWebAppDeployment-Legacy.ps1 | 134 ++++++++++++++++++ .../AzureRmWebAppDeployment.ps1 | 57 ++------ .../AzureRmWebAppDeployment/AzureUtility.ps1 | 29 ++-- Tasks/AzureRmWebAppDeployment/task.json | 5 + Tasks/AzureRmWebAppDeployment/task.loc.json | 5 + Tasks/MSBuild/task.json | 14 +- common.json | 14 +- 7 files changed, 186 insertions(+), 72 deletions(-) create mode 100644 Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 diff --git a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 new file mode 100644 index 000000000000..4831cbd8c1ac --- /dev/null +++ b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 @@ -0,0 +1,134 @@ +param +( + [String] [Parameter(Mandatory = $true)] + $ConnectedServiceName, + + [String] [Parameter(Mandatory = $true)] + $WebAppName, + + [String] [Parameter(Mandatory = $true)] + $DeployToSlotFlag, + + [String] [Parameter(Mandatory = $false)] + $ResourceGroupName, + + [String] [Parameter(Mandatory = $false)] + $SlotName, + + [String] [Parameter(Mandatory = $true)] + $Package, + + [String] [Parameter(Mandatory = $false)] + $SetParametersFile, + + [String] [Parameter(Mandatory = $false)] + $RemoveAdditionalFilesFlag, + + [String] [Parameter(Mandatory = $false)] + $ExcludeFilesFromAppDataFlag, + + [String] [Parameter(Mandatory = $false)] + $TakeAppOfflineFlag, + + [String] [Parameter(Mandatory = $false)] + $VirtualApplication, + + [String] [Parameter(Mandatory = $false)] + [String] $AdditionalArguments, + + [String] [Parameter(Mandatory = $false)] + [string]$WebAppUri +) + +Write-Verbose "Starting AzureRM WebApp Deployment Task" + +Write-Verbose "ConnectedServiceName = $ConnectedServiceName" +Write-Verbose "WebAppName = $WebAppName" +Write-Verbose "DeployToSlotFlag = $DeployToSlotFlag" +Write-Verbose "ResourceGroupName = $ResourceGroupName" +Write-Verbose "SlotName = $SlotName" +Write-Verbose "Package = $Package" +Write-Verbose "SetParametersFile = $SetParametersFile" +Write-Verbose "RemoveAdditionalFilesFlag = $RemoveAdditionalFilesFlag" +Write-Verbose "ExcludeFilesFromAppDataFlag = $ExcludeFilesFromAppDataFlag" +Write-Verbose "TakeAppOfflineFlag = $TakeAppOfflineFlag" +Write-Verbose "VirtualApplication = $VirtualApplication" +Write-Verbose "AdditionalArguments = $AdditionalArguments" +Write-Verbose "WebAppUri = $WebAppUri" + +$WebAppUri = $WebAppUri.Trim() +$Package = $Package.Trim('"').Trim() + +if( [string]::IsNullOrEmpty($Package) ){ + Throw (Get-LocalizedString -Key "Invalid webapp package path provided") +} + +$SetParametersFile = $SetParametersFile.Trim('"').Trim() + +# Import all the dlls and modules which have cmdlets we need +Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal" +Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Common" + +# Load all dependent files for execution +Import-Module ./AzureUtility.ps1 -Force +Import-Module ./Utility.ps1 -Force +Import-Module ./FindInstalledMSDeploy.ps1 + + # Importing required version of azure cmdlets according to azureps installed on machine + $azureUtility = Get-AzureUtility + + Write-Verbose "Loading $azureUtility" + Import-Module ./$azureUtility -Force + +$ErrorActionPreference = 'Stop' + +#### MAIN EXECUTION OF AZURERM WEBAPP DEPLOYMENT TASK BEGINS HERE #### + +# Get msdeploy.exe path +$msDeployExePath = Get-MsDeployExePath + +# Ensure that at most a package (.zip) file is found +$packageFilePath = Get-SingleFilePath -file $Package + +# Since the SetParametersFile is optional, but it's a FilePath type, it will have the value System.DefaultWorkingDirectory when not specified +if( $SetParametersFile -eq $env:SYSTEM_DEFAULTWORKINGDIRECTORY -or $SetParametersFile -eq [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\") -or [string]::IsNullOrEmpty($SetParametersFile)){ + $setParametersFilePath = "" +} else { + $setParametersFilePath = Get-SingleFilePath -file $SetParametersFile +} + +# Get destination azureRM webApp connection details +$azureRMWebAppConnectionDetails = Get-AzureRMWebAppConnectionDetails -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` + -resourceGroupName $ResourceGroupName -slotName $SlotName + +# webApp Name to be used in msdeploy command +$webAppNameForMSDeployCmd = Get-WebAppNameForMSDeployCmd -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag -slotName $SlotName + +# Construct arguments for msdeploy command +$msDeployCmdArgs = Get-MsDeployCmdArgs -packageFile $packageFilePath -webAppNameForMSDeployCmd $webAppNameForMSDeployCmd -azureRMWebAppConnectionDetails $azureRMWebAppConnectionDetails -removeAdditionalFilesFlag $RemoveAdditionalFilesFlag ` + -excludeFilesFromAppDataFlag $ExcludeFilesFromAppDataFlag -takeAppOfflineFlag $TakeAppOfflineFlag -virtualApplication $VirtualApplication -AdditionalArguments $AdditionalArguments ` + -setParametersFile $setParametersFilePath + +# Deploy azureRM webApp using msdeploy Command +Run-MsDeployCommand -msDeployExePath $msDeployExePath -msDeployCmdArgs $msDeployCmdArgs + +# Get azure webapp hosted url +$azureWebsitePublishURL = Get-AzureRMWebAppPublishUrl -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` + -resourceGroupName $ResourceGroupName -slotName $SlotName + +# Publish azure webApp url +Write-Host (Get-LocalizedString -Key "Webapp successfully published at Url : {0}" -ArgumentList $azureWebsitePublishURL) + +# Set ouput vairable with azureWebsitePublishUrl +if(-not [string]::IsNullOrEmpty($WebAppUri)) +{ + + if( [string]::IsNullOrEmpty($azureWebsitePublishURL)) + { + Throw (Get-LocalizedString -Key "Unable to retrieve webapp publish url for webapp : '{0}'." -ArgumentList $webAppName) + } + + Write-Host "##vso[task.setvariable variable=$WebAppUri;]$azureWebsitePublishURL" +} + +Write-Verbose "Completed AzureRM WebApp Deployment Task" \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 index c9ba39709e92..7dcf39ee26ea 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 @@ -7,13 +7,13 @@ try{ # Get inputs. $WebAppName = Get-VstsInput -Name WebAppName -Require - $DeployToSlotFlag = Get-VstsInput -Name DeployToSlotFlag -Require + $DeployToSlotFlag = Get-VstsInput -Name DeployToSlotFlag -Require -AsBool $ResourceGroupName = Get-VstsInput -Name ResourceGroupName $SlotName = Get-VstsInput -Name SlotName $Package = Get-VstsInput -Name Package -Require - $RemoveAdditionalFilesFlag = Get-VstsInput -Name ScriptArgument - $ExcludeFilesFromAppDataFlag = Get-VstsInput -Name ExcludeFilesFromAppDataFlag - $TakeAppOfflineFlag = Get-VstsInput -Name TakeAppOfflineFlag + $RemoveAdditionalFilesFlag = Get-VstsInput -Name RemoveAdditionalFilesFlag -AsBool + $ExcludeFilesFromAppDataFlag = Get-VstsInput -Name ExcludeFilesFromAppDataFlag -AsBool + $TakeAppOfflineFlag = Get-VstsInput -Name TakeAppOfflineFlag -AsBool $VirtualApplication = Get-VstsInput -Name VirtualApplication $AdditionalArguments = Get-VstsInput -Name AdditionalArguments $WebAppUri = Get-VstsInput -Name WebAppUri @@ -27,57 +27,26 @@ try{ # Import the loc strings. Import-VstsLocStrings -LiteralPath $PSScriptRoot/Task.json - - Write-Verbose "Starting AzureRM WebApp Deployment Task" - - Write-Verbose "ConnectedServiceName = $ConnectedServiceName" - Write-Verbose "WebAppName = $WebAppName" - Write-Verbose "DeployToSlotFlag = $DeployToSlotFlag" - Write-Verbose "ResourceGroupName = $ResourceGroupName" - Write-Verbose "SlotName = $SlotName" - Write-Verbose "Package = $Package" - Write-Verbose "SetParametersFile = $SetParametersFile" - Write-Verbose "RemoveAdditionalFilesFlag = $RemoveAdditionalFilesFlag" - Write-Verbose "ExcludeFilesFromAppDataFlag = $ExcludeFilesFromAppDataFlag" - Write-Verbose "TakeAppOfflineFlag = $TakeAppOfflineFlag" - Write-Verbose "VirtualApplication = $VirtualApplication" - Write-Verbose "AdditionalArguments = $AdditionalArguments" - Write-Verbose "WebAppUri = $WebAppUri" - $WebAppUri = $WebAppUri.Trim() - $Package = $Package.Trim('"').Trim() + $Package = "$Package".Trim('"').Trim() if( [string]::IsNullOrEmpty($Package) ){ Throw (Get-VstsLocString -Key "Invalidwebapppackagepathprovided") } - if ($ExcludeFilesFromAppDataFlag -match '[\r\n]' -or [string]::IsNullOrEmpty($ExcludeFilesFromAppDataFlag)) { - $ExcludeFilesFromAppDataFlag = $false - } - - if ($TakeAppOfflineFlag -match '[\r\n]' -or [string]::IsNullOrEmpty($TakeAppOfflineFlag)) { - $TakeAppOfflineFlag = $false - } - - if ($RemoveAdditionalFilesFlag -match '[\r\n]' -or [string]::IsNullOrEmpty($RemoveAdditionalFilesFlag)) { - $RemoveAdditionalFilesFlag = $false - } - $SetParametersFile = $SetParametersFile.Trim('"').Trim() # Load all dependent files for execution - Import-Module ./AzureUtility.ps1 -Force - Import-Module ./Utility.ps1 -Force - Import-Module ./FindInstalledMSDeploy.ps1 - - # Importing required version of azure cmdlets according to azureps installed on machine - $azureUtility = Get-AzureUtility + . $PSScriptRoot/AzureUtility.ps1 -Force + . $PSScriptRoot/Utility.ps1 -Force + . $PSScriptRoot/FindInstalledMSDeploy.ps1 - Write-Verbose "Loading $azureUtility" - Import-Module ./$azureUtility -Force + # Importing required version of azure cmdlets according to azureps installed on machine + $azureUtility = Get-AzureUtility - $ErrorActionPreference = 'Stop' + Write-Verbose "Loading $azureUtility" + . $PSScriptRoot/$azureUtility -Force #### MAIN EXECUTION OF AZURERM WEBAPP DEPLOYMENT TASK BEGINS HERE #### @@ -129,7 +98,7 @@ try{ Throw (Get-VstsLocString -Key "Unabletoretrievewebapppublishurlforwebapp0" -ArgumentList $webAppName) } - Write-Host "##vso[task.setvariable variable=$WebAppUri;]$azureWebsitePublishURL" + Set-VstsTaskVariable -Name $WebAppUri -Value $azureWebsitePublishURL } Write-Verbose "Completed AzureRM WebApp Deployment Task" diff --git a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 index 51c16716206a..2fd44dfb9c68 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 @@ -2,24 +2,25 @@ $ErrorActionPreference = 'Stop' function Get-AzureUtility { - $currentVersion = Get-AzureCmdletsVersion + $currentVersion = (Get-Module -Name AzureRM.profile).Version Write-Verbose "Installed Azure PowerShell version: $currentVersion" $minimumAzureVersion = New-Object System.Version(0, 9, 9) - $versionCompatible = Get-AzureVersionComparison -AzureVersion $currentVersion -CompareVersion $minimumAzureVersion - - $azureUtilityOldVersion = "AzureUtilityLTE9.8.ps1" + + $azureUtilityOldVersion = "AzureUtilityLTE9.8.ps1" $azureUtilityNewVersion = "AzureUtilityGTE1.0.ps1" - - if(!$versionCompatible) - { - $azureUtilityRequiredVersion = $azureUtilityOldVersion - } - else - { - $azureUtilityRequiredVersion = $azureUtilityNewVersion - } - + + Write-Verbose "Current AzureRM.profile version : $currentVersion " + + if( !$versionCompatible -and $currentVersion -gt $minimumAzureVersion ) + { + $azureUtilityRequiredVersion = $azureUtilityNewVersion + } + else + { + $azureUtilityRequiredVersion = $azureUtilityOldVersion + } + Write-Verbose "Required AzureUtility: $azureUtilityRequiredVersion" return $azureUtilityRequiredVersion } diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index 95404091e30e..d00fb04de92b 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -168,6 +168,11 @@ ], "instanceNameFormat": "Deploy AzureRM Web App: $(WebAppName)", "execution": { + "AzurePowerShell": { + "target": "$(currentDirectory)\\AzureRmWebAppDeployment-Legacy.ps1", + "argumentFormat": "", + "workingDirectory": "$(currentDirectory)" + }, "PowerShell3": { "target": "AzureRMWebAppDeployment.ps1" } diff --git a/Tasks/AzureRmWebAppDeployment/task.loc.json b/Tasks/AzureRmWebAppDeployment/task.loc.json index c21b965f5d12..494e2983e9a3 100644 --- a/Tasks/AzureRmWebAppDeployment/task.loc.json +++ b/Tasks/AzureRmWebAppDeployment/task.loc.json @@ -168,6 +168,11 @@ ], "instanceNameFormat": "ms-resource:loc.instanceNameFormat", "execution": { + "AzurePowerShell": { + "target": "$(currentDirectory)\\AzureRmWebAppDeployment-Legacy.ps1", + "argumentFormat": "", + "workingDirectory": "$(currentDirectory)" + }, "PowerShell3": { "target": "AzureRMWebAppDeployment.ps1" } diff --git a/Tasks/MSBuild/task.json b/Tasks/MSBuild/task.json index 6a44919b8fd4..cb3a1127cdb0 100644 --- a/Tasks/MSBuild/task.json +++ b/Tasks/MSBuild/task.json @@ -1,11 +1,11 @@ { - "id": "C6C4C611-AA2E-4A33-B606-5EABA2196824", - "name": "MSBuild", - "friendlyName": "MSBuild", - "description": "Build with MSBuild", - "helpMarkDown": "[More Information](http://go.microsoft.com/fwlink/?LinkID=613724)", - "category": "Build", - "visibility": [ + "id": "C6C4C611-AA2E-4A33-B606-5EABA2196824", + "name": "MSBuild", + "friendlyName": "MSBuild", + "description": "Build with MSBuild", + "helpMarkDown": "[More Information](http://go.microsoft.com/fwlink/?LinkID=613724)", + "category": "Build", + "visibility": [ "Build" ], "author": "Microsoft Corporation", diff --git a/common.json b/common.json index 0820adc1925c..d3a3962b1c58 100644 --- a/common.json +++ b/common.json @@ -1,11 +1,11 @@ { - "AzurePowerShell": [ - { - "module": "VstsAzureHelpers_", - "dest": "ps_modules" - } - ], - "AzureRMWebAppDeployment": [ + "AzurePowerShell": [ + { + "module": "VstsAzureHelpers_", + "dest": "ps_modules" + } + ], + "AzureRMWebAppDeployment": [ { "module": "VstsAzureHelpers_", "dest": "ps_modules" From 933fb985a0ccfc2e09ffec19e4667406190a41a6 Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Mon, 30 May 2016 18:32:34 +0530 Subject: [PATCH 05/12] Removed method from helper class --- .../VstsAzureHelpers_/VstsAzureHelpers_.psm1 | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 index f774ed715bd4..db11a2b5c41b 100644 --- a/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 +++ b/Tasks/Common/VstsAzureHelpers_/VstsAzureHelpers_.psm1 @@ -51,41 +51,5 @@ function Initialize-Azure { } } -function Get-AzureCmdletsVersion -{ - $module = Get-Module -Name AzureRM* -ListAvailable | Select-Object -First 1 - if($module) - { - return ($module).Version - } - return (Get-Module Azure -ListAvailable).Version -} - -function Get-AzureVersionComparison -{ - param - ( - [System.Version] [Parameter(Mandatory = $true)] - $AzureVersion, - - [System.Version] [Parameter(Mandatory = $true)] - $CompareVersion - ) - - $result = $AzureVersion.CompareTo($CompareVersion) - - if ($result -lt 0) - { - #AzureVersion is before CompareVersion - return $false - } - else - { - return $true - } -} - # Export only the public function. -Export-ModuleMember -Function Get-AzureVersionComparison -Export-ModuleMember -Function Get-AzureCmdletsVersion Export-ModuleMember -Function Initialize-Azure \ No newline at end of file From b12469635a063f349ab9fb9d72d8d9f6028bff3d Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Mon, 30 May 2016 18:41:47 +0530 Subject: [PATCH 06/12] Review corrections --- Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson b/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson index a30e73c151a4..c481298f4509 100644 --- a/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson @@ -6,7 +6,7 @@ "loc.group.displayName.junitTestResults": "JUnit Test Results", "loc.group.displayName.codeCoverage": "Code Coverage", "loc.group.displayName.advanced": "Advanced", - "loc.group.displayName.CodeAnalysis": "Code Analysis", + "loc.group.displayName.SQAnalysis": "SonarQube Analysis", "loc.input.label.mavenPOMFile": "Maven POM file", "loc.input.help.mavenPOMFile": "Relative path from the repository root to the Maven POM file.", "loc.input.label.options": "Options", @@ -50,7 +50,7 @@ "loc.input.label.sqDbUsername": "Db Username", "loc.input.help.sqDbUsername": "SonarQube server 5.1 and lower only. Enter the username for the database user (i.e. sonar.jdbc.username).", "loc.input.label.sqDbPassword": "Db User Password", - "loc.input.help.sqDbPassword": "SonarQube server 5.1 and lower only. Enter the password for the database user i.e. sonar.jdbc.password", + "loc.input.help.sqDbPassword": "SonarQube server 5.1 and lower only. Enter the password for the database user i.e. sonar.jdbc.password" "loc.input.label.pmdAnalysisEnabled": "Run PMD Analysis", "loc.input.help.pmdAnalysisEnabled": "Use the PMD Java static analysis tool to look for bugs in the code.", "loc.messages.codeAnalysisBuildSummaryLine_SomeViolationsSomeFiles": "%s found %d violations in %d files.", From f26bdd011a659deafd34edfc88c4ce6f25164285 Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Mon, 30 May 2016 18:44:48 +0530 Subject: [PATCH 07/12] removed maven file changes --- .../Maven/Strings/resources.resjson/en-US/resources.resjson | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson b/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson index c481298f4509..d78ee6f36873 100644 --- a/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson @@ -51,10 +51,4 @@ "loc.input.help.sqDbUsername": "SonarQube server 5.1 and lower only. Enter the username for the database user (i.e. sonar.jdbc.username).", "loc.input.label.sqDbPassword": "Db User Password", "loc.input.help.sqDbPassword": "SonarQube server 5.1 and lower only. Enter the password for the database user i.e. sonar.jdbc.password" - "loc.input.label.pmdAnalysisEnabled": "Run PMD Analysis", - "loc.input.help.pmdAnalysisEnabled": "Use the PMD Java static analysis tool to look for bugs in the code.", - "loc.messages.codeAnalysisBuildSummaryLine_SomeViolationsSomeFiles": "%s found %d violations in %d files.", - "loc.messages.codeAnalysisBuildSummaryLine_SomeViolationsOneFile": "%s found %d violations in 1 file.", - "loc.messages.codeAnalysisBuildSummaryLine_OneViolationOneFile": "%s found 1 violation in 1 file.", - "loc.messages.codeAnalysisBuildSummaryLine_NoViolations": "%s found no violations." } \ No newline at end of file From 6340ebe6a1424323301575236616d5c3e359267a Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Wed, 1 Jun 2016 12:24:39 +0530 Subject: [PATCH 08/12] github review corrections --- .../AzureRmWebAppDeployment.ps1 | 6 +++--- .../AzureRmWebAppDeployment/AzureUtility.ps1 | 20 +++++++++---------- common.json | 14 ++++++------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 index 7dcf39ee26ea..c726c06e18e8 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 @@ -34,12 +34,12 @@ try{ Throw (Get-VstsLocString -Key "Invalidwebapppackagepathprovided") } - $SetParametersFile = $SetParametersFile.Trim('"').Trim() + $SetParametersFile = "$SetParametersFile".Trim('"').Trim() # Load all dependent files for execution - . $PSScriptRoot/AzureUtility.ps1 -Force - . $PSScriptRoot/Utility.ps1 -Force + . $PSScriptRoot/AzureUtility.ps1 + . $PSScriptRoot/Utility.ps1 . $PSScriptRoot/FindInstalledMSDeploy.ps1 # Importing required version of azure cmdlets according to azureps installed on machine diff --git a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 index 2fd44dfb9c68..4ea7f0eb7a92 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 @@ -7,19 +7,19 @@ function Get-AzureUtility $minimumAzureVersion = New-Object System.Version(0, 9, 9) - $azureUtilityOldVersion = "AzureUtilityLTE9.8.ps1" + $azureUtilityOldVersion = "AzureUtilityLTE9.8.ps1" $azureUtilityNewVersion = "AzureUtilityGTE1.0.ps1" - Write-Verbose "Current AzureRM.profile version : $currentVersion " + Write-Verbose "Current AzureRM.profile version : $currentVersion " - if( !$versionCompatible -and $currentVersion -gt $minimumAzureVersion ) - { - $azureUtilityRequiredVersion = $azureUtilityNewVersion - } - else - { - $azureUtilityRequiredVersion = $azureUtilityOldVersion - } + if( !$versionCompatible -and $currentVersion -gt $minimumAzureVersion ) + { + $azureUtilityRequiredVersion = $azureUtilityNewVersion + } + else + { + $azureUtilityRequiredVersion = $azureUtilityOldVersion + } Write-Verbose "Required AzureUtility: $azureUtilityRequiredVersion" return $azureUtilityRequiredVersion diff --git a/common.json b/common.json index d3a3962b1c58..2253ec878ee3 100644 --- a/common.json +++ b/common.json @@ -1,11 +1,11 @@ { - "AzurePowerShell": [ - { - "module": "VstsAzureHelpers_", - "dest": "ps_modules" - } - ], - "AzureRMWebAppDeployment": [ + "AzurePowerShell": [ + { + "module": "VstsAzureHelpers_", + "dest": "ps_modules" + } + ], + "AzureRMWebAppDeployment": [ { "module": "VstsAzureHelpers_", "dest": "ps_modules" From 6a253c17fbe703cee07d8afaf40b4a8b60bfe8dc Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Wed, 1 Jun 2016 15:12:32 +0530 Subject: [PATCH 09/12] Added legacy code for azure rm webapp task --- .../AzureRmWebAppDeployment-Legacy.ps1 | 8 +- .../AzureUtilityGTE1.0.ps1 | 4 +- .../AzureUtilityLTE9.8.ps1 | 4 +- .../LegacyUtils/AzureUtility-Legacy.ps1 | 126 ++++++++++++ .../LegacyUtils/AzureUtilityGTE1.0-Legacy.ps1 | 177 +++++++++++++++++ .../LegacyUtils/AzureUtilityLTE9.8-Legacy.ps1 | 129 ++++++++++++ .../LegacyUtils/Utility-Legacy.ps1 | 188 ++++++++++++++++++ .../resources.resjson/en-US/resources.resjson | 3 +- Tasks/AzureRmWebAppDeployment/task.json | 3 +- Tasks/AzureRmWebAppDeployment/task.loc.json | 3 +- 10 files changed, 634 insertions(+), 11 deletions(-) create mode 100644 Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtility-Legacy.ps1 create mode 100644 Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityGTE1.0-Legacy.ps1 create mode 100644 Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityLTE9.8-Legacy.ps1 create mode 100644 Tasks/AzureRmWebAppDeployment/LegacyUtils/Utility-Legacy.ps1 diff --git a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 index 4831cbd8c1ac..fe286d01478d 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment-Legacy.ps1 @@ -70,15 +70,15 @@ Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal" Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Common" # Load all dependent files for execution -Import-Module ./AzureUtility.ps1 -Force -Import-Module ./Utility.ps1 -Force -Import-Module ./FindInstalledMSDeploy.ps1 +. $PSScriptRoot/LegacyUtils/AzureUtility-Legacy.ps1 +. $PSScriptRoot/LegacyUtils/Utility-Legacy.ps1 +. $PSScriptRoot/FindInstalledMSDeploy.ps1 # Importing required version of azure cmdlets according to azureps installed on machine $azureUtility = Get-AzureUtility Write-Verbose "Loading $azureUtility" - Import-Module ./$azureUtility -Force + . $PSScriptRoot\LegacyUtils\$azureUtility $ErrorActionPreference = 'Stop' diff --git a/Tasks/AzureRmWebAppDeployment/AzureUtilityGTE1.0.ps1 b/Tasks/AzureRmWebAppDeployment/AzureUtilityGTE1.0.ps1 index 11e422372409..b3da08173dd8 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureUtilityGTE1.0.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureUtilityGTE1.0.ps1 @@ -10,7 +10,7 @@ function Get-AzureRMWebAppARM if( $azureWebApp.Count -eq 0 ) { - Throw (Get-LocalizedString -Key "Web App: '{0}' not found." -ArgumentList $Name) + Throw (Get-VstsLocString -Key "WebApp0notfound" -ArgumentList $Name) } return $azureWebApp @@ -39,7 +39,7 @@ function Get-AzureRMWebAppPublishUrlARM } if( $azureRMWebAppProfileDetails -eq $null ){ - Throw (Get-LocalizedString -Key "Unable to find webapp publish profile details for webapp {0}." -ArgumentList $webAppName) + Throw (Get-VstsLocString -Key "Unabletofindwebapppublishprofiledetailsforwebapp0" -ArgumentList $webAppName) } return $azureRMWebAppProfileDetails.destinationAppUrl diff --git a/Tasks/AzureRmWebAppDeployment/AzureUtilityLTE9.8.ps1 b/Tasks/AzureRmWebAppDeployment/AzureUtilityLTE9.8.ps1 index bae6ebbadfe2..33582f0d8b72 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureUtilityLTE9.8.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureUtilityLTE9.8.ps1 @@ -42,7 +42,7 @@ function Get-AzureRMWebAppPublishUrlARM $azureRMWebAppProfileDetails = $azureRMWebAppProfileDetails | Where-Object { $_.PublishMethod -eq 'MSDeploy'} if( $azureRMWebAppProfileDetails.Count -eq 0 -or $azureRMWebAppProfileDetails.DestinationAppUri -eq $null ){ - Throw (Get-LocalizedString -Key "Unable to find publish Url for WebApp '{0}'." -ArgumentList $webAppName) + Throw (Get-VstsLocString -Key "UnabletofindpublishUrlforWebApp0" -ArgumentList $webAppName) } return $azureRMWebAppProfileDetails.DestinationAppUri.OriginalString @@ -71,7 +71,7 @@ function Get-WebAppRGName { Write-Verbose "[Azure Call] Web App: $webAppName not found" - Throw (Get-LocalizedString -Key "Web App: '{0}' not found." -ArgumentList $webAppName) + Throw (Get-VstsLocString -Key "WebApp0notfound" -ArgumentList $webAppName) } } } diff --git a/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtility-Legacy.ps1 b/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtility-Legacy.ps1 new file mode 100644 index 000000000000..e6498f676fda --- /dev/null +++ b/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtility-Legacy.ps1 @@ -0,0 +1,126 @@ +$ErrorActionPreference = 'Stop' + +function Get-AzureUtility +{ + $currentVersion = Get-AzureCmdletsVersion + Write-Verbose "Installed Azure PowerShell version: $currentVersion" + + $minimumAzureVersion = New-Object System.Version(0, 9, 9) + $versionCompatible = Get-AzureVersionComparison -AzureVersion $currentVersion -CompareVersion $minimumAzureVersion + + $azureUtilityOldVersion = "AzureUtilityLTE9.8-Legacy.ps1" + $azureUtilityNewVersion = "AzureUtilityGTE1.0-Legacy.ps1" + + if(!$versionCompatible) + { + $azureUtilityRequiredVersion = $azureUtilityOldVersion + } + else + { + $azureUtilityRequiredVersion = $azureUtilityNewVersion + } + + Write-Verbose "Required AzureUtility: $azureUtilityRequiredVersion" + return $azureUtilityRequiredVersion +} + +function Get-AzureRMWebAppDetails +{ + param([String][Parameter(Mandatory=$true)] $webAppName) + + Write-Verbose "`t Getting azureRM WebApp:'$webAppName' details." + $azureRMWebAppDetails = Get-AzureRMWebAppARM -Name $webAppName + Write-Verbose "`t Got azureRM WebApp:'$webAppName' details." + + Write-Verbose ($azureRMWebAppDetails | Format-List | Out-String) + return $azureRMWebAppDetails +} + +function Get-AzureRMWebAppPublishUrl +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $deployToSlotFlag, + [String][Parameter(Mandatory=$false)] $resourceGroupName, + [String][Parameter(Mandatory=$false)] $slotName) + + Write-Verbose "`t Getting azureRM WebApp Url for web app :'$webAppName'." + $AzureRMWebAppPublishUrl = Get-AzureRMWebAppPublishUrlARM -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` + -resourceGroupName $ResourceGroupName -slotName $SlotName + Write-Verbose "`t Got azureRM azureRM WebApp Url for web app :'$webAppName'." + + Write-Verbose ($AzureRMWebAppPublishUrl | Format-List | Out-String) + return $AzureRMWebAppPublishUrl +} + +function Get-AzureRMWebAppConnectionDetailsWithSpecificSlot +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $resourceGroupName, + [String][Parameter(Mandatory=$true)] $slotName) + + Write-Host (Get-LocalizedString -Key "Getting connection details for azureRM WebApp:'{0}' under Slot:'{1}'." -ArgumentList $webAppName, $slotName) + + $kuduHostName = $webAppName + "-" + $slotName + ".scm.azurewebsites.net" + Write-Verbose "`t Using KuduHostName:'$kuduHostName' for azureRM WebApp:'$webAppName' under Slot:'$slotName'." + + # Get webApp publish profile Object for MSDeploy + $webAppProfileForMSDeploy = Get-AzureRMWebAppProfileForMSDeployWithSpecificSlot -webAppName $webAppName -resourceGroupName $resourceGroupName -slotName $slotName + + # construct object to store webApp connection details + $azureRMWebAppConnectionDetailsWithSpecificSlot = Construct-AzureWebAppConnectionObject -kuduHostName $kuduHostName -webAppProfileForMSDeploy $webAppProfileForMSDeploy + + Write-Host (Get-LocalizedString -Key "Got connection details for azureRM WebApp:'{0}' under Slot:'{1}'." -ArgumentList $webAppName, $slotName) + return $azureRMWebAppConnectionDetailsWithSpecificSlot +} + +function Get-AzureRMWebAppConnectionDetailsWithProductionSlot +{ + param([String][Parameter(Mandatory=$true)] $webAppName) + + Write-Host (Get-LocalizedString -Key "Getting connection details for azureRM WebApp:'{0}' under Production Slot." -ArgumentList $webAppName) + + $kuduHostName = $webAppName + ".scm.azurewebsites.net" + Write-Verbose "`t Using KuduHostName:'$kuduHostName' for azureRM WebApp:'$webAppName' under default Slot." + + # Get azurerm webApp details + $azureRMWebAppDetails = Get-AzureRMWebAppDetails -webAppName $webAppName + + if( $azureRMWebAppDetails.Count -eq 0 ){ + Throw (Get-LocalizedString -Key "WebApp '{0}' does not exist." -ArgumentList $webAppName) + } + + # Get resourcegroup name under which azure webApp exists + $azureRMWebAppId = $azureRMWebAppDetails.Id + Write-Verbose "azureRMWebApp Id = $azureRMWebAppId" + + $resourceGroupName = $azureRMWebAppId.Split('/')[4] + Write-Verbose "`t ResourceGroup name is:'$resourceGroupName' for azureRM WebApp:'$webAppName'." + + # Get webApp publish profile Object for MSDeploy + $webAppProfileForMSDeploy = Get-AzureRMWebAppProfileForMSDeployWithProductionSlot -webAppName $webAppName -resourceGroupName $resourceGroupName + + # construct object to store webApp connection details + $azureRMWebAppConnectionDetailsWithProductionSlot = Construct-AzureWebAppConnectionObject -kuduHostName $kuduHostName -webAppProfileForMSDeploy $webAppProfileForMSDeploy + + Write-Host (Get-LocalizedString -Key "Got connection details for azureRM WebApp:'{0}' under Production Slot." -ArgumentList $webAppName) + return $azureRMWebAppConnectionDetailsWithProductionSlot +} + +function Get-AzureRMWebAppConnectionDetails +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $deployToSlotFlag, + [String][Parameter(Mandatory=$false)] $resourceGroupName, + [String][Parameter(Mandatory=$false)] $slotName) + + if($deployToSlotFlag -eq "true") + { + $azureRMWebAppConnectionDetails = Get-AzureRMWebAppConnectionDetailsWithSpecificSlot -webAppName $webAppName -resourceGroupName $ResourceGroupName -slotName $SlotName + } + else + { + $azureRMWebAppConnectionDetails = Get-AzureRMWebAppConnectionDetailsWithProductionSlot -webAppName $webAppName + } + + return $azureRMWebAppConnectionDetails +} diff --git a/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityGTE1.0-Legacy.ps1 b/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityGTE1.0-Legacy.ps1 new file mode 100644 index 000000000000..93becd10d250 --- /dev/null +++ b/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityGTE1.0-Legacy.ps1 @@ -0,0 +1,177 @@ +# This file implements IAzureUtility for Azure PowerShell version >= 1.0.0 + +# returns azure webapp +function Get-AzureRMWebAppARM +{ + param([String] [Parameter(Mandatory = $true)] $Name) + + Write-Verbose "[Azure Call] Getting azure webapp details for webapp with name : $Name " + $azureWebApp = Get-AzureRMWebApp -Name $Name + + if( $azureWebApp.Count -eq 0 ) + { + Throw (Get-LocalizedString -Key "Web App: '{0}' not found." -ArgumentList $Name) + } + + return $azureWebApp + +} + +function Get-AzureRMWebAppPublishUrlARM +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $deployToSlotFlag, + [String][Parameter(Mandatory=$false)] $resourceGroupName, + [String][Parameter(Mandatory=$false)] $slotName) + + if( $deployToSlotFlag -eq $false ) + { + $resourceGroupName = Get-WebAppRGName -webAppName $webAppName + Write-Verbose "Getting azure webapp info for webapp with name : $Name " + $azureRMWebAppProfileDetails = Get-AzureRMWebAppProfileForMSDeployWithProductionSlot -webAppName $webAppName -resourceGroupName $resourceGroupName + Write-Verbose "Got azure webapp info for webapp with name : $Name " + } + else + { + Write-Verbose "Getting azure webapp slot info for webapp with name : $Name , slot : $slotName and resource group : $resourceGroupName" + $azureRMWebAppProfileDetails = Get-AzureRMWebAppProfileForMSDeployWithSpecificSlot -webAppName $webAppName -slotName $slotName -resourceGroupName $resourceGroupName + Write-Verbose "Got azure webapp slot info for webapp with name : $Name , slot : $slotName and resource group : $resourceGroupName" + } + + if( $azureRMWebAppProfileDetails -eq $null ){ + Throw (Get-LocalizedString -Key "Unable to find webapp publish profile details for webapp {0}." -ArgumentList $webAppName) + } + + return $azureRMWebAppProfileDetails.destinationAppUrl + +} + +function Get-WebAppRGName +{ + param([String] [Parameter(Mandatory = $true)] $webAppName) + + $ARMSqlServerResourceType = "Microsoft.Web/sites" + + try + { + Write-Verbose "[Azure Call] Getting resource details for webapp resource: $webAppName with resource type: $ARMSqlServerResourceType" + $azureWebAppResourceDetails = (Get-AzureRmResource -ErrorAction Stop) | Where-Object { $_.ResourceType -eq $ARMSqlServerResourceType -and $_.ResourceName -eq $webAppName} + Write-Verbose "[Azure Call] Retrieved resource details successfully for webapp resource: $webAppName with resource type: $ARMSqlServerResourceType" + + $azureResourceGroupName = $azureWebAppResourceDetails.ResourceGroupName + return $azureWebAppResourceDetails.ResourceGroupName + } + finally + { + if ([string]::IsNullOrEmpty($azureResourceGroupName)) + { + Write-Verbose "[Azure Call] Web App: $webAppName not found" + + Throw (Get-LocalizedString -Key "Web App: '{0}' not found." -ArgumentList $webAppName) + } + } +} + +# return azure webapp publish profile +function Get-AzureRMWebAppPublishingProfileARM +{ + param([String] [Parameter(Mandatory = $true)] $Name, + [String] [Parameter(Mandatory = $true)] $ResourceGroupName, + [String] [Parameter(Mandatory = $true)] $pubXmlFile) + + Write-Verbose "[Azure Call] Getting webapp publish profile for azureRM webapp : $Name " + $publishProfileContent = Get-AzureRMWebAppPublishingProfile -Name $Name -ResourceGroupName $resourceGroupName -OutputFile $pubXmlFile + return $publishProfileContent + +} + + +# return azure webapp slot publish profile +function Get-AzureRMWebAppSlotPublishingProfileARM +{ + param([String] [Parameter(Mandatory = $true)] $Name, + [String] [Parameter(Mandatory = $true)] $ResourceGroupName, + [String] [Parameter(Mandatory = $true)] $slotName, + [String] [Parameter(Mandatory = $true)] $pubXmlFile) + + Write-Verbose "[Azure Call] Getting publish profile file for azureRM WebApp:'$Name' for Slot:'$slotName'" + $publishProfileContent = Get-AzureRMWebAppSlotPublishingProfile -Name $Name -ResourceGroupName $resourceGroupName -Slot $slotName -OutputFile $pubXmlFile + return $publishProfileContent + +} + + + +function Construct-AzureWebAppConnectionObject +{ + param([String][Parameter(Mandatory=$true)] $kuduHostName, + [Object][Parameter(Mandatory=$true)] $webAppProfileForMSDeploy) + + # Get userName and userPassword to access kuduServer + $userName = $webAppProfileForMSDeploy.userName + $userPassword = $webAppProfileForMSDeploy.userPWD + Write-Verbose "`t Username is:'$userName' to access KuduHostName:'$kuduHostName'." + + $azureRMWebAppConnectionDetails = @{} + $azureRMWebAppConnectionDetails.KuduHostName = $kuduHostName + $azureRMWebAppConnectionDetails.UserName = $userName + $azureRMWebAppConnectionDetails.UserPassword = $userPassword + + return $azureRMWebAppConnectionDetails +} + +function Get-ProfileForMSDeployPublishMethod +{ + param([String][Parameter(Mandatory=$true)] $publishProfileContent) + + # Converting publish profile content into object + $publishProfileXML = [xml] $publishProfileContent + $publishProfileObject = $publishProfileXML.publishData.publishProfile + + # Getting profile for publish method 'MSDeploy' + $webAppProfileForMSDeploy = $publishProfileObject | Where-Object {$_.publishMethod -eq 'MSDeploy'} + + return $webAppProfileForMSDeploy +} + + +function Get-AzureRMWebAppProfileForMSDeployWithProductionSlot +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $resourceGroupName) + + $currentDir = (Get-Item -Path ".\").FullName + $tmpFileName = [guid]::NewGuid().ToString() + ".pubxml" + $pubXmlFile = Join-Path $currentDir $tmpFileName + + Write-Verbose "`t [Azure Call]Getting publish profile file for azureRM WebApp:'$webAppName' under Production Slot at location: '$pubXmlFile'." + $publishProfileContent = Get-AzureRMWebAppPublishingProfile -Name $webAppName -ResourceGroupName $resourceGroupName -OutputFile $pubXmlFile + Write-Verbose "`t [Azure Call]Got publish profile file for azureRM WebApp:'$webAppName' under Production Slot at location: '$pubXmlFile'." + + Remove-Item -Path $pubXmlFile -Force + Write-Verbose "`t Deleted publish profile file at location: '$pubXmlFile'" + + $webAppProfileForMSDeploy = Get-ProfileForMSDeployPublishMethod -publishProfileContent $publishProfileContent + return $webAppProfileForMSDeploy +} + +function Get-AzureRMWebAppProfileForMSDeployWithSpecificSlot +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $resourceGroupName, + [String][Parameter(Mandatory=$true)] $slotName) + + $currentDir = (Get-Item -Path ".\").FullName + $tmpFileName = [guid]::NewGuid().ToString() + ".pubxml" + $pubXmlFile = Join-Path $currentDir $tmpFileName + + Write-Verbose "`t [Azure Call]Getting publish profile file for azureRM WebApp:'$webAppName' under Slot:'$slotName' at location: '$pubXmlFile'." + $publishProfileContent = Get-AzureRMWebAppSlotPublishingProfile -Name $webAppName -ResourceGroupName $resourceGroupName -Slot $slotName -OutputFile $pubXmlFile + Write-Verbose "`t [Azure Call]Got publish profile file for azureRM WebApp:'$webAppName' under Slot:'$slotName' at location: '$pubXmlFile'." + + Remove-Item -Path $pubXmlFile -Force + Write-Verbose "`t Deleted publish profile file at location: '$pubXmlFile'" + + $webAppProfileForMSDeploy = Get-ProfileForMSDeployPublishMethod -publishProfileContent $publishProfileContent + return $webAppProfileForMSDeploy +} \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityLTE9.8-Legacy.ps1 b/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityLTE9.8-Legacy.ps1 new file mode 100644 index 000000000000..bae6ebbadfe2 --- /dev/null +++ b/Tasks/AzureRmWebAppDeployment/LegacyUtils/AzureUtilityLTE9.8-Legacy.ps1 @@ -0,0 +1,129 @@ +# This file implements IAzureUtility for Azure PowerShell version <= 0.9.8 + +# returns azure webapp +function Get-AzureRMWebAppARM +{ + param([String] [Parameter(Mandatory = $true)] $Name) + + Switch-AzureMode AzureResourceManager + + $resourceGroupName = Get-WebAppRGName -webAppName $Name + + Write-Verbose "[Azure Call] Getting azure webapp details for webapp with name : $Name and resource group $resourceGroupName " + $azureWebApp = Get-AzureWebApp -Name $Name -ResourceGroupName $resourceGroupName + return $azureWebApp + +} + +function Get-AzureRMWebAppPublishUrlARM +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $deployToSlotFlag, + [String][Parameter(Mandatory=$false)] $resourceGroupName, + [String][Parameter(Mandatory=$false)] $slotName) + + Switch-AzureMode AzureResourceManager + + $resourceGroupName = Get-WebAppRGName -webAppName $webAppName + + if( $deployToSlotFlag -eq $false ) + { + Write-Verbose "[Azure Call] Getting azure webapp publish profile info for webapp with name : $Name and resource group : $resourceGroupName" + $azureRMWebAppProfileDetails = Get-AzureWebAppPublishingProfile -Name $webAppName -ResourceGroupName $resourceGroupName + Write-Verbose "[Azure Call] Getting azure webapp publish profile info for webapp with name : $Name and resource group : $resourceGroupName" + } + else + { + Write-Verbose "[Azure Call] Getting azure webapp slot publish profile info for webapp with name : $Name , slot : $slotName and resource group : $resourceGroupName" + $azureRMWebAppProfileDetails = Get-AzureWebAppPublishingProfile -Name $webAppName -SlotName $slotName -ResourceGroupName $resourceGroupName + Write-Verbose "[Azure Call] Getting azure webapp slot publish profile info for webapp with name : $Name , slot : $slotName and resource group : $resourceGroupName" + } + + $azureRMWebAppProfileDetails = $azureRMWebAppProfileDetails | Where-Object { $_.PublishMethod -eq 'MSDeploy'} + + if( $azureRMWebAppProfileDetails.Count -eq 0 -or $azureRMWebAppProfileDetails.DestinationAppUri -eq $null ){ + Throw (Get-LocalizedString -Key "Unable to find publish Url for WebApp '{0}'." -ArgumentList $webAppName) + } + + return $azureRMWebAppProfileDetails.DestinationAppUri.OriginalString + +} + +function Get-WebAppRGName +{ + param([String] [Parameter(Mandatory = $true)] $webAppName) + + $ARMSqlServerResourceType = "Microsoft.Web/sites" + Switch-AzureMode AzureResourceManager + + try + { + Write-Verbose "[Azure Call] Getting resource details for webapp resource: $webAppName with resource type: $ARMSqlServerResourceType" + $azureWebAppResourceDetails = (Get-AzureResource -ResourceName $webAppName -ErrorAction Stop) | Where-Object { $_.ResourceType -eq $ARMSqlServerResourceType } + Write-Verbose "[Azure Call] Retrieved resource details successfully for webapp resource: $webAppName with resource type: $ARMSqlServerResourceType" + + $azureResourceGroupName = $azureWebAppResourceDetails.ResourceGroupName + return $azureWebAppResourceDetails.ResourceGroupName + } + finally + { + if ([string]::IsNullOrEmpty($azureResourceGroupName)) + { + Write-Verbose "[Azure Call] Web App: $webAppName not found" + + Throw (Get-LocalizedString -Key "Web App: '{0}' not found." -ArgumentList $webAppName) + } + } +} + + +function Construct-AzureWebAppConnectionObject +{ + param([String][Parameter(Mandatory=$true)] $kuduHostName, + [Object][Parameter(Mandatory=$true)] $webAppProfileForMSDeploy) + + # Get userName and userPassword to access kuduServer + $userName = $webAppProfileForMSDeploy.userName + $userPassword = $webAppProfileForMSDeploy.UserPassword + Write-Verbose "`t Username is:'$userName' to access KuduHostName:'$kuduHostName'." + + $azureRMWebAppConnectionDetails = @{} + $azureRMWebAppConnectionDetails.KuduHostName = $kuduHostName + $azureRMWebAppConnectionDetails.UserName = $userName + $azureRMWebAppConnectionDetails.UserPassword = $userPassword + + return $azureRMWebAppConnectionDetails +} + +function Get-AzureRMWebAppProfileForMSDeployWithProductionSlot +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $resourceGroupName) + + Switch-AzureMode AzureResourceManager + + Write-Verbose "`t [Azure Call]Getting publish profile file for azureRM WebApp:'$webAppName' under Production Slot." + $webAppProfiles = Get-AzureWebAppPublishingProfile -Name $webAppName -ResourceGroupName $resourceGroupName + Write-Verbose "`t [Azure Call]Got publish profile file for azureRM WebApp:'$webAppName' under Production Slot." + + $webAppProfileForMSDeploy = $webAppProfiles | Where-Object { $_.PublishMethod -eq 'MSDeploy'} + + return $webAppProfileForMSDeploy +} + +function Get-AzureRMWebAppProfileForMSDeployWithSpecificSlot +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $resourceGroupName, + [String][Parameter(Mandatory=$true)] $slotName) + + Switch-AzureMode AzureResourceManager + + Write-Verbose "`t [Azure Call]Getting publish profile file for azureRM WebApp:'$webAppName' under Slot:'$slotName'." + $webAppProfiles = Get-AzureWebAppPublishingProfile -Name $webAppName -ResourceGroupName $resourceGroupName -Slot $slotName + Write-Verbose "`t [Azure Call]Got publish profile file for azureRM WebApp:'$webAppName' under Slot:'$slotName'." + + $webAppProfileForMSDeploy = $webAppProfiles | Where-Object { $_.PublishMethod -eq 'MSDeploy'} + + return $webAppProfileForMSDeploy +} \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/LegacyUtils/Utility-Legacy.ps1 b/Tasks/AzureRmWebAppDeployment/LegacyUtils/Utility-Legacy.ps1 new file mode 100644 index 000000000000..a9c4fb0911c2 --- /dev/null +++ b/Tasks/AzureRmWebAppDeployment/LegacyUtils/Utility-Legacy.ps1 @@ -0,0 +1,188 @@ +$ErrorActionPreference = 'Stop' + +function Get-MsDeployExePath +{ + $MSDeployExePath = $null + try + { + $MSDeployExePath , $MSDeployVersion = Get-MSDeployOnTargetMachine + } + catch [System.Exception] + { + Write-Verbose ("MSDeploy is not installed in system." + $_.Exception.Message) + } + + if( $MSDeployExePath -ne $null -and $MSDeployVersion -lt 3 ){ + throw "Unsupported installed version : $MSDeployVersion found for MSDeploy,version should be alteast 3 or above" + } + + if( [string]::IsNullOrEmpty($MSDeployExePath) ) + { + + Write-Verbose (Get-LocalizedString -Key "Using local MSDeploy.exe") + $currentDir = (Get-Item -Path ".\").FullName + $msDeployExeDir = Join-Path $currentDir "MSDeploy3.6" + $MSDeployExePath = Join-Path $msDeployExeDir "msdeploy.exe" + + } + + Write-Host (Get-LocalizedString -Key "msdeploy.exe is located at '{0}'" -ArgumentList $MSDeployExePath) + + return $MSDeployExePath +} + +function Get-SingleFile +{ + param([String][Parameter(Mandatory=$true)] $files, + [String][Parameter(Mandatory=$true)] $pattern) + + if ($files -is [system.array]) + { + throw (Get-LocalizedString -Key "Found more than one file to deploy with search pattern {0}. There can be only one." -ArgumentList $pattern) + } + else + { + if (!$files) + { + throw (Get-LocalizedString -Key "No files were found to deploy with search pattern {0}." -ArgumentList $pattern) + } + + return $files + } +} + +function Get-SingleFilePath +{ + param([String][Parameter(Mandatory=$true)] $file) + + Write-Host (Get-LocalizedString -Key "filePath = Find-Files -SearchPattern {0}" -ArgumentList $file) + $filePath = Find-Files -SearchPattern $file + Write-Host (Get-LocalizedString -Key "filePath = {0}" -ArgumentList $filePath) + + $filePath = Get-SingleFile -files $filePath -pattern $file + return $filePath +} + +function Get-WebAppNameForMSDeployCmd +{ + param([String][Parameter(Mandatory=$true)] $webAppName, + [String][Parameter(Mandatory=$true)] $deployToSlotFlag, + [String][Parameter(Mandatory=$false)] $slotName) + + $webAppNameForMSDeployCmd = $webAppName + if($deployToSlotFlag -eq "true") + { + $webAppNameForMSDeployCmd += "(" + $SlotName + ")" + } + + Write-Verbose "WebApp Name to be used in msdeploy command is: '$webAppNameForMSDeployCmd'" + return $webAppNameForMSDeployCmd +} + + +function Get-MsDeployCmdArgs +{ + param([String][Parameter(Mandatory=$true)] $packageFile, + [String][Parameter(Mandatory=$true)] $webAppNameForMSDeployCmd, + [Object][Parameter(Mandatory=$true)] $azureRMWebAppConnectionDetails, + [String][Parameter(Mandatory=$true)] $removeAdditionalFilesFlag, + [String][Parameter(Mandatory=$true)] $excludeFilesFromAppDataFlag, + [String][Parameter(Mandatory=$true)] $takeAppOfflineFlag, + [String][Parameter(Mandatory=$false)] $virtualApplication, + [String][Parameter(Mandatory=$false)] $setParametersFile, + [String][Parameter(Mandatory=$false)] $AdditionalArguments) + + $msDeployCmdArgs = [String]::Empty + Write-Verbose "Constructing msdeploy command arguments to deploy to azureRM WebApp:'$webAppNameForMSDeployCmd' `nfrom source Wep App zip package:'$packageFile'." + + # msdeploy argument containing source and destination details to sync + $msDeployCmdArgs = [String]::Format('-verb:sync -source:package="{0}" -dest:auto,ComputerName="https://{1}/msdeploy.axd?site={2}",UserName="{3}",Password="{4}",AuthType="Basic"' ` + , $packageFile, $azureRMWebAppConnectionDetails.KuduHostName, $webAppNameForMSDeployCmd, $azureRMWebAppConnectionDetails.UserName, $azureRMWebAppConnectionDetails.UserPassword) + + # msdeploy argument to set destination IIS App Name for deploy + if($virtualApplication) + { + $msDeployCmdArgs += [String]::Format(' -setParam:name="IIS Web Application Name",value="{0}/{1}"', $webAppNameForMSDeployCmd, $virtualApplication) + } + else + { + $msDeployCmdArgs += [String]::Format(' -setParam:name="IIS Web Application Name",value="{0}"', $webAppNameForMSDeployCmd) + } + + # msdeploy argument to block deletion from happening + if($removeAdditionalFilesFlag -ne "true") + { + $msDeployCmdArgs += " -enableRule:DoNotDeleteRule" + } + + # msdeploy argument to take app offline + if($takeAppOfflineFlag -eq "true") + { + $msDeployCmdArgs += " -enableRule:AppOffline" + } + + # msdeploy argument to exclude files in App_Data folder + if($excludeFilesFromAppDataFlag -eq "true") + { + $msDeployCmdArgs += [String]::Format(' -skip:Directory="\\App_Data"') + } + + if( -not [String]::IsNullOrEmpty($setParametersFile)){ + $msDeployCmdArgs += [String]::Format(' -setParamFile:"{0}"', $setParametersFile) + } + + # msploy additional arguments + if( -not [String]::IsNullOrEmpty($AdditionalArguments)){ + $msDeployCmdArgs += ( " " + $AdditionalArguments) + } + + Write-Verbose "Constructed msdeploy command arguments to deploy to azureRM WebApp:'$webAppNameForMSDeployCmd' `nfrom source Wep App zip package:'$packageFile'." + return $msDeployCmdArgs +} + +function Run-Command +{ + param([String][Parameter(Mandatory=$true)] $command) + + try + { + if( $psversiontable.PSVersion.Major -le 4) + { + cmd.exe /c "`"$command`"" + } + else + { + cmd.exe /c "$command" + } + + } + catch [System.Exception] + { + throw $_.Exception.Message + } + +} + +function Get-MsDeployCmdForLogs +{ + param([String][Parameter(Mandatory=$true)] $msDeployCmd) + + $msDeployCmdSplitByComma = $msDeployCmd.Split(',') + $msDeployCmdHiddingSensitiveData = $msDeployCmdSplitByComma | ForEach-Object {if ($_.StartsWith("Password")) {$_.Replace($_, "Password=****")} else {$_}} + + $msDeployCmdForLogs = $msDeployCmdHiddingSensitiveData -join "," + return $msDeployCmdForLogs +} + +function Run-MsDeployCommand +{ + param([String][Parameter(Mandatory=$true)] $msDeployExePath, + [String][Parameter(Mandatory=$true)] $msDeployCmdArgs) + + $msDeployCmd = "`"$msDeployExePath`" $msDeployCmdArgs" + $msDeployCmdForLogs = Get-MsDeployCmdForLogs -msDeployCmd $msDeployCmd + + Write-Host (Get-LocalizedString -Key "Running msdeploy command: `n`t{0}" -ArgumentList $msDeployCmdForLogs) + Run-Command -command $msDeployCmd + Write-Host (Get-LocalizedString -Key "msdeploy command ran successfully.") +} \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson index 905eee3eee0a..c905812ee297 100644 --- a/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureRmWebAppDeployment/Strings/resources.resjson/en-US/resources.resjson @@ -49,5 +49,6 @@ "loc.messages.Runningmsdeploycommand0": "Running msdeploy command: `n`t{0}", "loc.messages.msdeploycommandransuccessfully": "msdeploy command ran successfully.", "loc.messages.filePathFindFilesSearchPattern0": "filePath = Find-Files -SearchPattern {0}", - "loc.messages.filePath0": "filePath = {0}" + "loc.messages.filePath0": "filePath = {0}", + "loc.messages.UnabletofindpublishUrlforWebApp0": "Unable to find publish Url for WebApp '{0}'." } \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index d00fb04de92b..2dcf7d5115d9 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -197,6 +197,7 @@ "Runningmsdeploycommand0": "Running msdeploy command: `n`t{0}", "msdeploycommandransuccessfully": "msdeploy command ran successfully.", "filePathFindFilesSearchPattern0": "filePath = Find-Files -SearchPattern {0}", - "filePath0":"filePath = {0}" + "filePath0":"filePath = {0}", + "UnabletofindpublishUrlforWebApp0":"Unable to find publish Url for WebApp '{0}'." } } \ No newline at end of file diff --git a/Tasks/AzureRmWebAppDeployment/task.loc.json b/Tasks/AzureRmWebAppDeployment/task.loc.json index 494e2983e9a3..d01b1574a963 100644 --- a/Tasks/AzureRmWebAppDeployment/task.loc.json +++ b/Tasks/AzureRmWebAppDeployment/task.loc.json @@ -197,6 +197,7 @@ "Runningmsdeploycommand0": "ms-resource:loc.messages.Runningmsdeploycommand0", "msdeploycommandransuccessfully": "ms-resource:loc.messages.msdeploycommandransuccessfully", "filePathFindFilesSearchPattern0": "ms-resource:loc.messages.filePathFindFilesSearchPattern0", - "filePath0": "ms-resource:loc.messages.filePath0" + "filePath0": "ms-resource:loc.messages.filePath0", + "UnabletofindpublishUrlforWebApp0": "ms-resource:loc.messages.UnabletofindpublishUrlforWebApp0" } } \ No newline at end of file From 793f3c3e9f9b59ae3b44c5f5363539f341bbd81f Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Tue, 7 Jun 2016 12:06:03 +0530 Subject: [PATCH 10/12] github review fix and patch version changed --- Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 | 3 +-- Tasks/AzureRmWebAppDeployment/task.json | 2 +- Tasks/AzureRmWebAppDeployment/task.loc.json | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 index 4ea7f0eb7a92..12f42d5f377f 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureUtility.ps1 @@ -10,9 +10,8 @@ function Get-AzureUtility $azureUtilityOldVersion = "AzureUtilityLTE9.8.ps1" $azureUtilityNewVersion = "AzureUtilityGTE1.0.ps1" - Write-Verbose "Current AzureRM.profile version : $currentVersion " - if( !$versionCompatible -and $currentVersion -gt $minimumAzureVersion ) + if( !$currentVersion -and $currentVersion -gt $minimumAzureVersion ) { $azureUtilityRequiredVersion = $azureUtilityNewVersion } diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index 2dcf7d5115d9..9e32182a3c9f 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 6 + "Patch": 7 }, "minimumAgentVersion": "1.99.0", "groups": [ diff --git a/Tasks/AzureRmWebAppDeployment/task.loc.json b/Tasks/AzureRmWebAppDeployment/task.loc.json index d01b1574a963..2cb56cab3735 100644 --- a/Tasks/AzureRmWebAppDeployment/task.loc.json +++ b/Tasks/AzureRmWebAppDeployment/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 6 + "Patch": 7 }, "minimumAgentVersion": "1.99.0", "groups": [ From f397d6ad07d93ead949495dc5157e8970512dd90 Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Tue, 7 Jun 2016 12:31:58 +0530 Subject: [PATCH 11/12] Resovled conflicts --- .../AzureRmWebAppDeployment.ps1 | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 index c726c06e18e8..acc3a98e7884 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 @@ -56,16 +56,12 @@ try{ # Ensure that at most a package (.zip) file is found $packageFilePath = Get-SingleFilePath -file $Package - Write-Verbose "Value of package file path : $SetParametersFile" -verbose - - # Since the SetParametersFile is optional, but it's a FilePath type, it will have the value System.DefaultWorkingDirectory when not specified - if( $SetParametersFile -eq $env:SYSTEM_DEFAULTWORKINGDIRECTORY -or $SetParametersFile -eq [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\" ) -or [string]::IsNullOrEmpty($SetParametersFile) ){ - Write-Verbose "Is empty" -verbose - $setParametersFilePath = "" - } else { - Write-Verbose "Is not empty" -verbose - $setParametersFilePath = Get-SingleFilePath -file $SetParametersFile - } +# Since the SetParametersFile is optional, but it's a FilePath type, it will have the value System.DefaultWorkingDirectory when not specified +if( $SetParametersFile -eq $env:SYSTEM_DEFAULTWORKINGDIRECTORY -or $SetParametersFile -eq [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\" ) -or [string]::IsNullOrEmpty($SetParametersFile) ){ + $setParametersFilePath = "" +} else { + $setParametersFilePath = Get-SingleFilePath -file $SetParametersFile +} # Get destination azureRM webApp connection details $azureRMWebAppConnectionDetails = Get-AzureRMWebAppConnectionDetails -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag ` From 45e4e2b91497afe21d591d507b1f134234630770 Mon Sep 17 00:00:00 2001 From: Ajay Yadav Date: Tue, 7 Jun 2016 12:34:45 +0530 Subject: [PATCH 12/12] Indentation correction --- .../AzureRmWebAppDeployment.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 index acc3a98e7884..f18db54f3fb9 100644 --- a/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 +++ b/Tasks/AzureRmWebAppDeployment/AzureRmWebAppDeployment.ps1 @@ -56,12 +56,12 @@ try{ # Ensure that at most a package (.zip) file is found $packageFilePath = Get-SingleFilePath -file $Package -# Since the SetParametersFile is optional, but it's a FilePath type, it will have the value System.DefaultWorkingDirectory when not specified -if( $SetParametersFile -eq $env:SYSTEM_DEFAULTWORKINGDIRECTORY -or $SetParametersFile -eq [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\" ) -or [string]::IsNullOrEmpty($SetParametersFile) ){ - $setParametersFilePath = "" -} else { - $setParametersFilePath = Get-SingleFilePath -file $SetParametersFile -} + # Since the SetParametersFile is optional, but it's a FilePath type, it will have the value System.DefaultWorkingDirectory when not specified + if( $SetParametersFile -eq $env:SYSTEM_DEFAULTWORKINGDIRECTORY -or $SetParametersFile -eq [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\" ) -or [string]::IsNullOrEmpty($SetParametersFile) ){ + $setParametersFilePath = "" + } else { + $setParametersFilePath = Get-SingleFilePath -file $SetParametersFile + } # Get destination azureRM webApp connection details $azureRMWebAppConnectionDetails = Get-AzureRMWebAppConnectionDetails -webAppName $WebAppName -deployToSlotFlag $DeployToSlotFlag `