diff --git a/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.0.ps1 b/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.0.ps1 index 04e28eaffbc9..a426d6d967c4 100644 --- a/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.0.ps1 +++ b/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.0.ps1 @@ -22,7 +22,7 @@ function Create-AzureResourceGroupIfNotExist { Write-Verbose "[Azure Resource Manager]Creating resource group $resourceGroupName in $location" $azureResourceGroup = New-AzureRMResourceGroup -Name $resourceGroupName -Location $location -Verbose -ErrorAction Stop - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Created resource group '{0}'" -ArgumentList $resourceGroupName) + Write-Host (Get-VstsLocString -Key "ARG_CreatedResourceGroup" -ArgumentList $resourceGroupName) } return $azureResourceGroup } @@ -86,9 +86,9 @@ function Start-Machine if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Starting machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StartingMachine" -ArgumentList $machineName) $response = Start-AzureRMVM -Name $machineName -ResourceGroupName $resourceGroupName -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Started machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StartedMachine" -ArgumentList $machineName) } return $response } @@ -100,9 +100,9 @@ function Stop-Machine if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Stopping machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StoppingMachine" -ArgumentList $machineName) $response = Stop-AzureRMVM -Name $machineName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Stopped machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StoppedMachine" -ArgumentList $machineName) } return $response } @@ -114,9 +114,9 @@ function Delete-Machine if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleting machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_DeletingMachine" -ArgumentList $machineName) $response = Remove-AzureRMVM -Name $machineName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleted machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_DeletedMachine" -ArgumentList $machineName) } return $response } @@ -127,9 +127,9 @@ function Delete-ResourceGroup if(-not [string]::IsNullOrEmpty($resourceGroupName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleting resource group '{0}'" -ArgumentList $resourceGroupName) + Write-Host (Get-VstsLocString -Key "ARG_DeletingResourceGroup" -ArgumentList $resourceGroupName) Remove-AzureRMResourceGroup -Name $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleted resource group '{0}'" -ArgumentList $resourceGroupName) + Write-Host (Get-VstsLocString -Key "ARG_DeletedResourceGroup" -ArgumentList $resourceGroupName) } } @@ -148,7 +148,7 @@ function Get-AzureRMVMsInResourceGroup catch [Microsoft.WindowsAzure.Commands.Common.ComputeCloudException],[System.MissingMethodException], [System.Management.Automation.PSInvalidOperationException], [Hyak.Common.CloudException] { Write-Verbose $_.Exception.Message - throw (Get-LocalizedString -Key "Ensure resource group '{0}' exists and has at least one virtual machine in it" -ArgumentList $resourceGroupName) + throw (Get-VstsLocString -Key "ARG_EnsureResourceGroupWithMachine" -ArgumentList $resourceGroupName) } catch { @@ -276,9 +276,9 @@ function Get-AzureMachineStatus if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($name)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Getting the status for vm '{0}'" -ArgumentList $name) + Write-Host (Get-VstsLocString -Key "ARG_GettingVmStatus" -ArgumentList $name) $status = Get-AzureRmVM -ResourceGroupName $resourceGroupName -Name $name -Status -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Got the status for vm '{0}'" -ArgumentList $name) + Write-Host (Get-VstsLocString -Key "ARG_GotVmStatus" -ArgumentList $name) } return $status @@ -292,9 +292,9 @@ function Get-AzureMachineCustomScriptExtension if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($vmName)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Getting the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_GettingExtensionStatus" -ArgumentList $name, $vmName) $customScriptExtension = Get-AzureRmVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Got the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_GotExtensionStatus" -ArgumentList $name, $vmName) } return $customScriptExtension @@ -312,9 +312,9 @@ function Set-AzureMachineCustomScriptExtension if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($vmName) -and -not [string]::IsNullOrEmpty($name)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Setting the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_SettingExtension" -ArgumentList $name, $vmName) $result = Set-AzureRmVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -FileUri $fileUri -Run $run -Argument $argument -Location $location -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Set the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_SetExtension" -ArgumentList $name, $vmName) } return $result @@ -328,9 +328,9 @@ function Remove-AzureMachineCustomScriptExtension if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($vmName) -and -not [string]::IsNullOrEmpty($name)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Removing the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_RemovingExtension" -ArgumentList $name, $vmName) $response = Remove-AzureRmVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -Force -ErrorAction SilentlyContinue -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Removed the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_RemovedExtension" -ArgumentList $name, $vmName) } return $response @@ -377,12 +377,12 @@ function Get-NetworkSecurityGroups } else { - throw (Get-LocalizedString -Key "[Azure Call]No network interface found with virtual machine id {0} under resource group {1}" -ArgumentList $vmid , $resourceGroupName) + throw (Get-VstsLocString -Key "ARG_NetworkInterfaceNotFound" -ArgumentList $vmid , $resourceGroupName) } } else { - throw (Get-LocalizedString -Key "[Azure Call]Resource group name and virtual machine ID should not be null or empty") + throw (Get-VstsLocString -Key "ARG_EmptyRGName") } return $securityGroups @@ -470,4 +470,4 @@ function Remove-NetworkSecurityRuleConfig $result = Remove-AzureRmNetworkSecurityRuleConfig -NetworkSecurityGroup $securityGroup -Name $ruleName | Set-AzureRmNetworkSecurityGroup Write-Verbose "[Azure Call]Removed the Rule $ruleName" } -} \ No newline at end of file +} diff --git a/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.1.0.ps1 b/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.1.0.ps1 index 7c8628ab35a3..9ed790f896d1 100644 --- a/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.1.0.ps1 +++ b/Tasks/DeployAzureResourceGroup/AzureUtilityGTE1.1.0.ps1 @@ -1,6 +1,6 @@ # This file implements IAzureUtility for Azure PowerShell version >= 1.1.0 -Import-Module ./AzureUtilityGTE1.0.ps1 -Force +. "$PSScriptRoot\AzureUtilityGTE1.0.ps1" function Get-AzureRMVMsInResourceGroup { @@ -17,7 +17,7 @@ function Get-AzureRMVMsInResourceGroup catch [Microsoft.WindowsAzure.Commands.Common.ComputeCloudException],[System.MissingMethodException], [System.Management.Automation.PSInvalidOperationException], [Hyak.Common.CloudException], [Microsoft.Rest.Azure.CloudException] { Write-Verbose $_.Exception.Message - throw (Get-LocalizedString -Key "Ensure resource group '{0}' exists and has at least one virtual machine in it" -ArgumentList $resourceGroupName) + throw (Get-VstsLocString -Key "ARG_EnsureResourceGroupWithMachine" -ArgumentList $resourceGroupName) } catch { @@ -35,9 +35,9 @@ function Start-Machine if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Starting machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StartingMachine" -ArgumentList $machineName) $response = Start-AzureRMVM -Name $machineName -ResourceGroupName $resourceGroupName -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Started machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StartedMachine" -ArgumentList $machineName) if($response.IsSuccessStatusCode -eq $true) { $responseJObject = [Newtonsoft.Json.Linq.JObject]::Parse(($response | ConvertTo-Json)) @@ -55,9 +55,9 @@ function Stop-Machine if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Stopping machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StoppingMachine" -ArgumentList $machineName) $response = Stop-AzureRMVM -Name $machineName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Stopped machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StoppedMachine" -ArgumentList $machineName) if($response.IsSuccessStatusCode -eq $true) { $responseJObject = [Newtonsoft.Json.Linq.JObject]::Parse(($response | ConvertTo-Json)) @@ -75,9 +75,9 @@ function Delete-Machine if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleting machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_DeletingMachine" -ArgumentList $machineName) $response = Remove-AzureRMVM -Name $machineName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleted machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_DeletedMachine" -ArgumentList $machineName) if($response.IsSuccessStatusCode -eq $true) { $responseJObject = [Newtonsoft.Json.Linq.JObject]::Parse(($response | ConvertTo-Json)) @@ -101,10 +101,10 @@ function Set-AzureMachineCustomScriptExtension if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($vmName) -and -not [string]::IsNullOrEmpty($name)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Setting the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_SettingExtension" -ArgumentList $name, $vmName) Write-Verbose "Set-AzureRmVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -FileUri $fileUri -Run $run -Argument $argument -Location $location -ErrorAction Stop -Verbose" $result = Set-AzureRmVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -FileUri $fileUri -Run $run -Argument $argument -Location $location -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Set the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_SetExtension" -ArgumentList $name, $vmName) if($result.IsSuccessStatusCode -eq $true) { $responseJObject = [Newtonsoft.Json.Linq.JObject]::Parse(($result | ConvertTo-Json)) @@ -116,4 +116,4 @@ function Set-AzureMachineCustomScriptExtension } return $result -} \ No newline at end of file +} diff --git a/Tasks/DeployAzureResourceGroup/AzureUtilityLTE9.8.ps1 b/Tasks/DeployAzureResourceGroup/AzureUtilityLTE9.8.ps1 index 77fc5df8f66a..40cb78430d4f 100644 --- a/Tasks/DeployAzureResourceGroup/AzureUtilityLTE9.8.ps1 +++ b/Tasks/DeployAzureResourceGroup/AzureUtilityLTE9.8.ps1 @@ -23,7 +23,7 @@ function Create-AzureResourceGroupIfNotExist { Write-Verbose "[Azure Resource Manager]Creating resource group $resourceGroupName in $location" $azureResourceGroup = New-AzureResourceGroup -Name $resourceGroupName -Location $location -Verbose -ErrorAction Stop - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Created resource group '{0}'" -ArgumentList $resourceGroupName) + Write-Host (Get-VstsLocString -Key "ARG_CreatedResourceGroup" -ArgumentList $resourceGroupName) } return $azureResourceGroup } @@ -93,9 +93,9 @@ function Start-Machine Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Starting machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StartingMachine" -ArgumentList $machineName) $response = Start-AzureVM -Name $machineName -ResourceGroupName $resourceGroupName -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Started machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StartedMachine" -ArgumentList $machineName) } return $response } @@ -108,9 +108,9 @@ function Stop-Machine Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Stopping machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StoppingMachine" -ArgumentList $machineName) $response = Stop-AzureVM -Name $machineName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Stopped machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_StoppedMachine" -ArgumentList $machineName) } return $response } @@ -123,9 +123,9 @@ function Delete-Machine Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($machineName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleting machine '{0}'" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_DeletingMachine" -ArgumentList $machineName) $response = Remove-AzureVM -Name $machineName -ResourceGroupName $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleted machine '{0}' from Azure provider" -ArgumentList $machineName) + Write-Host (Get-VstsLocString -Key "ARG_DeletedMachine" -ArgumentList $machineName) } return $response } @@ -137,9 +137,9 @@ function Delete-ResourceGroup Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName)) { - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleting resource group '{0}'" -ArgumentList $resourceGroupName) + Write-Host (Get-VstsLocString -Key "ARG_DeletingResourceGroup" -ArgumentList $resourceGroupName) Remove-AzureResourceGroup -Name $resourceGroupName -Force -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Resource Manager]Deleted resource group '{0}'" -ArgumentList $resourceGroupName) + Write-Host (Get-VstsLocString -Key "ARG_DeletedResourceGroup" -ArgumentList $resourceGroupName) } } @@ -159,7 +159,7 @@ function Get-AzureRMVMsInResourceGroup catch [Microsoft.WindowsAzure.Commands.Common.ComputeCloudException],[System.MissingMethodException], [System.Management.Automation.PSInvalidOperationException], [Hyak.Common.CloudException] { Write-Verbose $_.Exception.Message - throw (Get-LocalizedString -Key "Ensure resource group '{0}' exists and has at least one virtual machine in it" -ArgumentList $resourceGroupName) + throw (Get-VstsLocString -Key "ARG_EnsureResourceGroupWithMachine" -ArgumentList $resourceGroupName) } catch { @@ -292,9 +292,9 @@ function Get-AzureMachineStatus Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($name)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Getting the status for vm '{0}'" -ArgumentList $name) + Write-Host (Get-VstsLocString -Key "ARG_GettingVmStatus" -ArgumentList $name) $status = Get-AzureVM -ResourceGroupName $resourceGroupName -Name $name -Status -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Got the status for vm '{0}'" -ArgumentList $name) + Write-Host (Get-VstsLocString -Key "ARG_GotVmStatus" -ArgumentList $name) } return $status @@ -309,9 +309,9 @@ function Get-AzureMachineCustomScriptExtension Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($vmName)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Getting the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_GettingExtensionStatus" -ArgumentList $name, $vmName) $customScriptExtension = Get-AzureVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Got the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_GotExtensionStatus" -ArgumentList $name, $vmName) } return $customScriptExtension @@ -330,9 +330,9 @@ function Set-AzureMachineCustomScriptExtension Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($vmName) -and -not [string]::IsNullOrEmpty($name)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Setting the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_SettingExtension" -ArgumentList $name, $vmName) $result = Set-AzureVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -FileUri $fileUri -Run $run -Argument $argument -Location $location -ErrorAction Stop -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Set the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_SetExtension" -ArgumentList $name, $vmName) } return $result @@ -347,9 +347,9 @@ function Remove-AzureMachineCustomScriptExtension Switch-AzureMode AzureResourceManager if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($vmName) -and -not [string]::IsNullOrEmpty($name)) { - Write-Host (Get-LocalizedString -Key "[Azure Call]Removing the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_RemovingExtension" -ArgumentList $name, $vmName) $response = Remove-AzureVMCustomScriptExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $name -Force -ErrorAction SilentlyContinue -Verbose - Write-Host (Get-LocalizedString -Key "[Azure Call]Removed the custom script extension '{0}' for vm '{1}'" -ArgumentList $name, $vmName) + Write-Host (Get-VstsLocString -Key "ARG_RemovedExtension" -ArgumentList $name, $vmName) } return $response @@ -397,12 +397,12 @@ function Get-NetworkSecurityGroups } else { - throw (Get-LocalizedString -Key "[Azure Call]No network interface found with virtual machine id {0} under resource group {1}" -ArgumentList $vmid , $resourceGroupName) + throw (Get-VstsLocString -Key "ARG_NetworkInterfaceNotFound" -ArgumentList $vmid , $resourceGroupName) } } else { - throw (Get-LocalizedString -Key "[Azure Call]Resource group name and virtual machine ID should not be null or empty") + throw (Get-VstsLocString -Key "ARG_EmptyRGName") } return $securityGroups @@ -492,4 +492,4 @@ function Remove-NetworkSecurityRuleConfig $result = Remove-AzureNetworkSecurityRuleConfig -NetworkSecurityGroup $securityGroup -Name $ruleName | Set-AzureNetworkSecurityGroup Write-Verbose "[Azure Call]Removed the Rule $ruleName" } -} \ No newline at end of file +} diff --git a/Tasks/DeployAzureResourceGroup/DeployAzureResourceGroup.ps1 b/Tasks/DeployAzureResourceGroup/DeployAzureResourceGroup.ps1 index 586fa020c0e3..4041f76ecb31 100644 --- a/Tasks/DeployAzureResourceGroup/DeployAzureResourceGroup.ps1 +++ b/Tasks/DeployAzureResourceGroup/DeployAzureResourceGroup.ps1 @@ -1,42 +1,23 @@ -param( - [string][Parameter(Mandatory=$true)]$connectedServiceNameSelector, - [string]$connectedServiceName, - [string]$connectedServiceNameClassic, - [string]$action, - [string]$actionClassic, - [string]$resourceGroupName, - [string]$cloudService, - [string]$location, - [string]$csmFile, - [string]$csmParametersFile, - [string]$overrideParameters, - # for preventing compat break scenarios passing below parameters also, - # though we don't require them in current implementation of task - [string]$dscDeployment, - [string]$moduleUrlParameterNames, - [string]$sasTokenParameterNames, - [string]$vmCreds, - [string]$vmUserName, - [string]$vmPassword, - [string]$skipCACheck, - [string]$outputVariable, - [string]$enableDeploymentPrerequisitesForCreate, - [string]$enableDeploymentPrerequisitesForSelect -) - -Write-Verbose "Starting Azure Resource Group Deployment Task" -Write-Verbose "ConnectedServiceNameSelector = $connectedServiceNameSelector" -Write-Verbose "ConnectedServiceName = $ConnectedServiceName" -Write-Verbose "ConnectedServiceNameClassic = $connectedServiceNameClassic" -Write-Verbose "Action = $action" -Write-Verbose "ActionClassic = $actionClassic" -Write-Verbose "ResourceGroupName = $resourceGroupName" -Write-Verbose "CloudService = $cloudService" -Write-Verbose "Location = $location" -Write-Verbose "OverrideParameters = $overrideParameters" -Write-Verbose "OutputVariable = $outputVariable" -Write-Verbose "enableDeploymentPrerequisitesForCreate = $enableDeploymentPrerequisitesForCreate" -Write-Verbose "enableDeploymentPrerequisitesForSelect = $enableDeploymentPrerequisitesForSelect" +[CmdletBinding()] +param() + +Trace-VstsEnteringInvocation $MyInvocation + +# Get inputs for the task +$connectedServiceNameSelector = Get-VstsInput -Name "connectedServiceNameSelector" -Require +$connectedServiceName = Get-VstsInput -Name "connectedServiceName" +$connectedServiceNameClassic = Get-VstsInput -Name "connectedServiceNameClassic" +$action = Get-VstsInput -Name "action" +$actionClassic = Get-VstsInput -Name "actionClassic" +$resourceGroupName = Get-VstsInput -Name "resourceGroupName" +$cloudService = Get-VstsInput -Name "cloudService" +$location = Get-VstsInput -Name "location" +$csmFile = Get-VstsInput -Name "csmFile" +$csmParametersFile = Get-VstsInput -Name "csmParametersFile" +$overrideParameters = Get-VstsInput -Name "overrideParameters" +$outputVariable = Get-VstsInput -Name "outputVariable" +$enableDeploymentPrerequisitesForCreate = Get-VstsInput -Name "enableDeploymentPrerequisitesForCreate" -AsBool +$enableDeploymentPrerequisitesForSelect = Get-VstsInput -Name "enableDeploymentPrerequisitesForSelect" -AsBool if($connectedServiceNameSelector -eq "ConnectedServiceNameClassic") { @@ -52,23 +33,29 @@ $csmParametersFile = $csmParametersFile.Trim('"', ' ') $overrideParameters = $overrideParameters.Trim() $outputVariable = $outputVariable.Trim() $telemetrySet = $false + $ErrorActionPreference = "Stop" +# Initialize Azure. +Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ +Initialize-Azure + +# Import the loc strings. +Import-VstsLocStrings -LiteralPath $PSScriptRoot/Task.json + # 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" -Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.DevTestLabs" -Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal" +Import-Module "$PSScriptRoot\DeploymentUtilities\Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal" +Import-Module "$PSScriptRoot\DeploymentUtilities\Microsoft.TeamFoundation.DistributedTask.Task.DevTestLabs.dll" # Load all dependent files for execution -Import-Module ./Utility.ps1 -Force +. "$PSScriptRoot\Utility.ps1" function Handle-SelectResourceGroupAction { if([string]::IsNullOrEmpty($outputVariable)) { Write-TaskSpecificTelemetry "PREREQ_NoOutputVariableForSelectActionInAzureRG" - throw (Get-LocalizedString -Key "Please provide the output variable name since you have specified the 'Select Resource Group' option.") + throw (Get-VstsLocString -Key "ARG_ProvideOutputVariable") } Instantiate-Environment -resourceGroupName $resourceGroupName -outputVariable $outputVariable -enableDeploymentPrerequisites $enableDeploymentPrerequisitesForSelect @@ -76,11 +63,11 @@ function Handle-SelectResourceGroupAction function Handle-ResourceGroupLifeCycleOperations { - $serviceEndpoint = Get-ServiceEndpoint -Name "$ConnectedServiceName" -Context $distributedTaskContext - if ($serviceEndpoint.Authorization.Scheme -eq 'Certificate') + $serviceEndpoint = Get-VstsEndpoint -Name "$ConnectedServiceName" + if ($serviceEndpoint.Auth.Scheme -eq 'Certificate') { Write-TaskSpecificTelemetry "PREREQ_InvalidServiceConnectionType" - throw (Get-LocalizedString -Key "Certificate based authentication only works with the 'Select Resource Group' action. Please select an Azure subscription with either Credential or SPN based authentication.") + throw (Get-VstsLocString -Key "ARG_UseSpnAuth") } if( $action -eq "Create Or Update Resource Group" ) @@ -108,7 +95,7 @@ try $azureUtility = Get-AzureUtility Write-Verbose "Loading $azureUtility" - Import-Module ./$azureUtility -Force + . "$PSScriptRoot\$azureUtility" switch ($action) { diff --git a/Tasks/DeployAzureResourceGroup/Strings/resources.resjson/en-US/resources.resjson b/Tasks/DeployAzureResourceGroup/Strings/resources.resjson/en-US/resources.resjson index ea6fdeebb098..a888dbb5d20b 100644 --- a/Tasks/DeployAzureResourceGroup/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/DeployAzureResourceGroup/Strings/resources.resjson/en-US/resources.resjson @@ -30,5 +30,45 @@ "loc.input.label.enableDeploymentPrerequisitesForSelect": "Enable Deployment Prerequisites", "loc.input.help.enableDeploymentPrerequisitesForSelect": "Enabling this option configures Windows Remote Management (WinRM) listener over HTTPS protocol on port 5986, using a self-signed certificate. This configuration is required for performing deployment operation on Azure machines. If the target Virtual Machines are backed by a Load balancer, ensure Inbound NAT rules are configured for target port (5986).", "loc.input.label.outputVariable": "Resource Group", - "loc.input.help.outputVariable": "Provide a name for the variable for the resource group. The variable can be used as $(variableName) to refer to the resource group in subsequent tasks like in the PowerShell on Target Machines task for deploying applications.
Valid only when the selected action is Create, Update or Select, and required when an existing resource group is selected." + "loc.input.help.outputVariable": "Provide a name for the variable for the resource group. The variable can be used as $(variableName) to refer to the resource group in subsequent tasks like in the PowerShell on Target Machines task for deploying applications.
Valid only when the selected action is Create, Update or Select, and required when an existing resource group is selected.", + "loc.messages.ARG_CreatedResourceGroup": "[Azure Resource Manager]Created resource group '{0}'", + "loc.messages.ARG_StartingMachine": "[Azure Resource Manager]Starting machine '{0}'", + "loc.messages.ARG_StartedMachine": "[Azure Resource Manager]Started machine '{0}' from Azure provider", + "loc.messages.ARG_StoppingMachine": "[Azure Resource Manager]Stopping machine '{0}'", + "loc.messages.ARG_StoppedMachine": "{0}' from Azure provider", + "loc.messages.ARG_DeletingMachine": "[Azure Resource Manager]Deleting machine '{0}'", + "loc.messages.ARG_DeletedMachine": "[Azure Resource Manager]Deleted machine '{0}' from Azure provider", + "loc.messages.ARG_DeletingResourceGroup": "[Azure Resource Manager]Deleting resource group '{0}'", + "loc.messages.ARG_DeletedResourceGroup": "[Azure Resource Manager]Deleted resource group '{0}'", + "loc.messages.ARG_EnsureResourceGroupWithMachine": "Ensure resource group '{0}' exists and has at least one virtual machine in it", + "loc.messages.ARG_GettingVmStatus": "[Azure Call]Getting the status for vm '{0}'", + "loc.messages.ARG_GotVmStatus": "[Azure Call]Got the status for vm '{0}'", + "loc.messages.ARG_GettingExtensionStatus": "[Azure Call]Getting the custom script extension '{0}' for vm '{1}'", + "loc.messages.ARG_GotExtensionStatus": "[Azure Call]Got the custom script extension '{0}' for vm '{1}'", + "loc.messages.ARG_SettingExtension": "[Azure Call]Setting the custom script extension '{0}' for vm '{1}'", + "loc.messages.ARG_SetExtension": "[Azure Call]Set the custom script extension '{0}' for vm '{1}'", + "loc.messages.ARG_RemovingExtension": "[Azure Call]Removing the custom script extension '{0}' for vm '{1}'", + "loc.messages.ARG_RemovedExtension": "[Azure Call]Removed the custom script extension '{0}' for vm '{1}'", + "loc.messages.ARG_NetworkInterfaceNotFound": "[Azure Call]No network interface found with virtual machine id {0} under resource group {1}", + "loc.messages.ARG_EmptyRGName": "[Azure Call]Resource group name and virtual machine ID should not be null or empty", + "loc.messages.ARG_UseSpnAuth": "Certificate based authentication only works with the 'Select Resource Group' action. Please select an Azure subscription with either Credential or SPN based authentication.", + "loc.messages.ARG_ProvideOutputVariable": "Please provide the output variable name since you have specified the 'Select Resource Group' option.", + "loc.messages.ARG_UnsupportedAzurePSVersion": "The required minimum version {0} of the Azure Powershell Cmdlets are not installed. You can follow the instructions at {1} to get the latest Azure powershell", + "loc.messages.ARG_AzureRMModuleNotFound": "The required AzureRM Powershell module is not installed. You can follow the instructions at {0} to get the latest Azure powershell", + "loc.messages.ARG_DeploymentFailed": "Resource group deployment '{0}' failed", + "loc.messages.ARG_DeploymentSucceeded": "Successfully created resource group deployment with name '{0}'", + "loc.messages.ARG_InvalidFilePath": "Found more than one file to deploy with search pattern '{0}'. There can be only one", + "loc.messages.ARG_FileNotFound": "No files were found to deploy with search pattern '{0}'", + "loc.messages.ARG_SpecifyValidTemplatePath": "Please specify a complete and a valid template file path", + "loc.messages.ARG_SpecifyValidParametersPath": "Please specify a complete and a valid template parameters file path", + "loc.messages.ARG_ActionNotSupported": "Action '{0}' is not supported on the provider '{1}'", + "loc.messages.ARG_OperationFailedOnMachine": "Operation '{0}' failed on the machine '{1}'", + "loc.messages.ARG_InvokeInvalidOperation": "Tried to invoke an invalid operation: '{0}'", + "loc.messages.ARG_NoVmsFound": "No VMs found in resource group: '{0}'. Could not register environment in the output variable: '{1}'", + "loc.messages.ARG_AllResourceNotFound": "Unable to get {0} for all resources in ResourceGroup : '{1}'", + "loc.messages.ARG_ResourceNotFound": "Unable to get {0} for '{1}' resources in ResourceGroup : '{2}'", + "loc.messages.ARG_SetExtensionFailed": "Setting the custom script extension '{0}' for virtual machine '{1}' failed with error : {2}", + "loc.messages.ARG_NetworkSecurityConfigFailed": "Failed to add the network security rule: {0}", + "loc.messages.ARG_SetExtensionFailedForVm": "Unable to set the custom script extension '{0}' for virtual machine '{1}': {2}", + "loc.messages.ARG_DeploymentPrereqFailed": "Failed to enable deployment prerequisites. {0}" } \ No newline at end of file diff --git a/Tasks/DeployAzureResourceGroup/Utility.ps1 b/Tasks/DeployAzureResourceGroup/Utility.ps1 index a6443864c269..9122353b7be3 100644 --- a/Tasks/DeployAzureResourceGroup/Utility.ps1 +++ b/Tasks/DeployAzureResourceGroup/Utility.ps1 @@ -58,6 +58,22 @@ function Write-TaskSpecificTelemetry Write-Telemetry "$codeKey" "94A74903-F93F-4075-884F-DC11F34058B4" } +function Get-AzureCmdletsVersion +{ + $module = Get-Module AzureRM -ListAvailable + if($module) + { + return ($module).Version + } + return (Get-Module Azure -ListAvailable).Version +} + +function Get-AzureVersionComparison($azureVersion, $compareVersion) +{ + Write-Verbose "Compare azure versions: $azureVersion, $compareVersion" + return ($azureVersion -and $azureVersion -gt $compareVersion) +} + function Validate-AzurePowerShellVersion { $currentVersion = Get-AzureCmdletsVersion @@ -67,7 +83,7 @@ function Validate-AzurePowerShellVersion if(!$versionCompatible) { Write-TaskSpecificTelemetry "PREREQ_UnsupportedAzurePSVersion" - Throw (Get-LocalizedString -Key "The required minimum version {0} of the Azure Powershell Cmdlets are not installed. You can follow the instructions at {1} to get the latest Azure powershell" -ArgumentList $minimumAzureVersion, "https://aka.ms/azps") + Throw (Get-VstsLocString -Key "ARG_UnsupportedAzurePSVersion" -ArgumentList $minimumAzureVersion, "https://aka.ms/azps") } Write-Verbose "Validated the required azure powershell version" @@ -78,7 +94,7 @@ function Check-AzureRMInstalled if(!(Get-Module -Name "AzureRM*" -ListAvailable)) { Write-TaskSpecificTelemetry "PREREQ_AzureRMModuleNotFound" - throw (Get-LocalizedString -Key "The required AzureRM Powershell module is not installed. You can follow the instructions at {0} to get the latest Azure powershell" -ArgumentList "https://aka.ms/azps") + throw (Get-VstsLocString -Key "ARG_AzureRMModuleNotFound" -ArgumentList "https://aka.ms/azps") } } @@ -152,11 +168,11 @@ function Create-AzureResourceGroup Write-Error $error -ErrorAction Continue } - throw (Get-LocalizedString -Key "Resource group deployment '{0}' failed" -ArgumentList $resourceGroupName) + throw (Get-VstsLocString -Key "ARG_DeploymentFailed" -ArgumentList $resourceGroupName) } else { - Write-Host (Get-LocalizedString -Key "Successfully created resource group deployment with name '{0}'" -ArgumentList $resourceGroupName) + Write-Host (Get-VstsLocString -Key "ARG_DeploymentSucceeded" -ArgumentList $resourceGroupName) } Write-Verbose "End of resource group deployment logs" @@ -222,14 +238,14 @@ function Get-SingleFile($files, $pattern) if ($files -is [system.array]) { Write-TaskSpecificTelemetry "PREREQ_InvalidFilePath" - 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 "ARG_InvalidFilePath" -ArgumentList $pattern) } else { if (!$files) { Write-TaskSpecificTelemetry "PREREQ_InvalidFilePath" - throw (Get-LocalizedString -Key "No files were found to deploy with search pattern '{0}'" -ArgumentList $pattern) + throw (Get-VstsLocString -Key "ARG_FileNotFound" -ArgumentList $pattern) } return $files @@ -240,7 +256,7 @@ function Get-File($pattern) { #Find the File based on pattern Write-Verbose "Finding files based on $pattern" - $filesMatchingPattern = Find-Files -SearchPattern "$pattern" + $filesMatchingPattern = Find-VstsFiles -LegacyPattern "$pattern" Write-Verbose "Files Matching Pattern: $filesMatchingPattern" @@ -258,13 +274,13 @@ function Validate-DeploymentFileAndParameters if (!(Test-Path -LiteralPath $csmFile -PathType Leaf)) { Write-TaskSpecificTelemetry "PREREQ_InvalidFilePath" - throw (Get-LocalizedString -Key "Please specify a complete and a valid template file path") + throw (Get-VstsLocString -Key "ARG_SpecifyValidTemplatePath") } if ($csmParametersFile -ne $env:SYSTEM_DEFAULTWORKINGDIRECTORY -and $csmParametersFile -ne [String]::Concat($env:SYSTEM_DEFAULTWORKINGDIRECTORY, "\") -and !(Test-Path -LiteralPath $csmParametersFile -PathType Leaf)) { Write-TaskSpecificTelemetry "PREREQ_InvalidFilePath" - throw (Get-LocalizedString -Key "Please specify a complete and a valid template parameters file path") + throw (Get-VstsLocString -Key "ARG_SpecifyValidParametersPath") } } @@ -329,7 +345,7 @@ function Perform-Action default { Write-TaskSpecificTelemetry "PREREQ_InvalidActionProvided" - throw (Get-LocalizedString -Key "Action '{0}' is not supported on the provider '{1}'" -ArgumentList $action, "Azure") + throw (Get-VstsLocString -Key "ARG_ActionNotSupported" -ArgumentList $action, "Azure") } } } @@ -357,7 +373,7 @@ function Invoke-OperationOnResourceGroup if($response.Status -ne "Succeeded") { Write-TaskSpecificTelemetry "DEPLOYMENT_PerformActionFailed" - Write-Error (Get-LocalizedString -Key "Operation '{0}' failed on the machine '{1}'" -ArgumentList $operationName, $machine.Name) + Write-Error (Get-VstsLocString -Key "ARG_OperationFailedOnMachine" -ArgumentList $operationName, $machine.Name) throw $response.Error } else @@ -401,7 +417,7 @@ function Invoke-OperationOnMachine default { Write-TaskSpecificTelemetry "PREREQ_InvalidActionProvided" - throw (Get-LocalizedString -Key "Tried to invoke an invalid operation: '{0}'" -ArgumentList $operationName) + throw (Get-VstsLocString -Key "ARG_InvokeInvalidOperation" -ArgumentList $operationName) } } @@ -414,8 +430,6 @@ function Instantiate-Environment [string]$outputVariable, [string]$enableDeploymentPrerequisites) - $connection = Get-VssConnection -TaskContext $distributedTaskContext - $azureVMResources = Get-AzureClassicVMsInResourceGroup -resourceGroupName $resourceGroupName $azureVMsDetails = Get-AzureClassicVMsConnectionDetailsInResourceGroup -resourceGroupName $resourceGroupName -azureClassicVMResources $azureVMResources if($azureVMsDetails.Count -eq 0) @@ -428,7 +442,7 @@ function Instantiate-Environment if ($azureVMsDetails.Count -eq 0) { Write-TaskSpecificTelemetry "PREREQ_NoVMResources" - throw (Get-LocalizedString -Key "No VMs found in resource group: '{0}'. Could not register environment in the output variable: '{1}'" -ArgumentList $resourceGroupName, $outputVariable) + throw (Get-VstsLocString -Key "ARG_NoVmsFound" -ArgumentList $resourceGroupName, $outputVariable) } $resources = @() @@ -448,19 +462,10 @@ function Instantiate-Environment $machineSpecification = $resources -join "," Write-Verbose "Starting Register-Environment cmdlet call for resource group : $resourceGroupName" - if((gcm Register-Environment).Parameters.ContainsKey("Persist")) - { - $environment = Register-Environment -EnvironmentName $outputVariable -EnvironmentSpecification $machineSpecification -WinRmProtocol "HTTPS" -Connection $connection -TaskContext $distributedTaskContext -TagsList $tagsList -Persist - Write-Verbose "Completed Register-Environment for : $resourceGroupName, adding environment $outputVariable to output variables" - Set-TaskVariable -Variable $outputVariable -Value $outputVariable - } - else - { - $environment = Register-Environment -EnvironmentName $outputVariable -EnvironmentSpecification $machineSpecification -WinRmProtocol "HTTPS" -Connection $connection -TaskContext $distributedTaskContext -TagsList $tagsList - Write-Verbose "Completed Register-Environment for : $resourceGroupName, converting environment as json and setting as output variable" -verbose - $envStr = $environment.ToString() -replace "`n|`r" - write-host "##vso[task.setvariable variable=$outputVariable;issecret=true;]$envStr" - } + $environment = Register-Environment -EnvironmentName $outputVariable -EnvironmentSpecification $machineSpecification -WinRmProtocol "HTTPS" -TagsList $tagsList + Write-Verbose "Completed Register-Environment for : $resourceGroupName, converting environment as json and setting as output variable" -verbose + $envStr = $environment.ToString() -replace "`n|`r" + Write-Host "##vso[task.setvariable variable=$outputVariable;issecret=true;]$envStr" Write-Verbose "Added the environment $outputVariable to output variable" } @@ -682,13 +687,13 @@ function Get-MachineNameFromId { if($errorCount -eq $azureRMVMResources.Count -and $azureRMVMResources.Count -ne 0) { - throw (Get-LocalizedString -Key "Unable to get {0} for all resources in ResourceGroup : '{1}'" -ArgumentList $mapParameter, $resourceGroupName) + throw (Get-VstsLocString -Key "ARG_AllResourceNotFound" -ArgumentList $mapParameter, $resourceGroupName) } else { if($errorCount -gt 0 -and $errorCount -ne $azureRMVMResources.Count) { - Write-Warning (Get-LocalizedString -Key "Unable to get {0} for '{1}' resources in ResourceGroup : '{2}'" -ArgumentList $mapParameter, $errorCount, $resourceGroupName) + Write-Warning (Get-VstsLocString -Key "ARG_ResourceNotFound" -ArgumentList $mapParameter, $errorCount, $resourceGroupName) } } } @@ -889,7 +894,7 @@ function Validate-CustomScriptExecutionStatus if(-not $isScriptExecutionPassed) { $response = Remove-AzureMachineCustomScriptExtension -resourceGroupName $resourceGroupName -vmName $vmName -name $extensionName - throw (Get-LocalizedString -Key "Setting the custom script extension '{0}' for virtual machine '{1}' failed with error : {2}" -ArgumentList $extensionName, $vmName, $errMessage) + throw (Get-VstsLocString -Key "ARG_SetExtensionFailed" -ArgumentList $extensionName, $vmName, $errMessage) } Write-Verbose "Validated the script execution successfully" @@ -966,7 +971,7 @@ function Add-WinRMHttpsNetworkSecurityRuleConfig catch { Write-TaskSpecificTelemetry "ADDWINRM_NetworkSecurityRuleConfigFailed" - Write-Warning (Get-LocalizedString -Key "Failed to add the network security rule: {0}" -ArgumentList $_.exception.message) + Write-Warning (Get-VstsLocString -Key "ARG_NetworkSecurityConfigFailed" -ArgumentList $_.exception.message) } } @@ -1013,7 +1018,7 @@ function Add-AzureVMCustomScriptExtension Write-TaskSpecificTelemetry "ENABLEWINRM_ProvisionVmCustomScriptFailed" $response = Remove-AzureMachineCustomScriptExtension -resourceGroupName $resourceGroupName -vmName $vmName -name $extensionName - throw (Get-LocalizedString -Key "Unable to set the custom script extension '{0}' for virtual machine '{1}': {2}" -ArgumentList $extensionName, $vmName, $result.Error.Message) + throw (Get-VstsLocString -Key "ARG_SetExtensionFailedForVm" -ArgumentList $extensionName, $vmName, $result.Error.Message) } Validate-CustomScriptExecutionStatus -resourceGroupName $resourceGroupName -vmName $vmName -extensionName $extensionName @@ -1022,7 +1027,7 @@ function Add-AzureVMCustomScriptExtension catch { Write-TaskSpecificTelemetry "ENABLEWINRM_ExecutionOfVmCustomScriptFailed" - throw (Get-LocalizedString -Key "Failed to enable deployment prerequisites. {0}" -ArgumentList $_.exception.message) + throw (Get-VstsLocString -Key "ARG_DeploymentPrereqFailed" -ArgumentList $_.exception.message) } Write-Verbose "Successfully added the custom script extension '$extensionName' for virtual machine '$vmName'" diff --git a/Tasks/DeployAzureResourceGroup/externals.json b/Tasks/DeployAzureResourceGroup/externals.json new file mode 100644 index 000000000000..15ec77e29759 --- /dev/null +++ b/Tasks/DeployAzureResourceGroup/externals.json @@ -0,0 +1,28 @@ +{ + "archivePackages": [ + { + "archiveName": "DeploymentUtilities.zip", + "url": "https://krishadiblob.blob.core.windows.net/tools/DeploymentUtilities/1.3/DeploymentUtilities.zip", + "dest": "./", + "files": [ + "DeploymentUtilities/Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal", + "DeploymentUtilities/Microsoft.TeamFoundation.DistributedTask.Task.DevTestLabs.dll", + "DeploymentUtilities/Microsoft.VisualStudio.Services.Common.dll", + "DeploymentUtilities/Microsoft.VisualStudio.Services.DevTestLabs.Client.dll", + "DeploymentUtilities/Microsoft.VisualStudio.Services.DevTestLabs.Common.dll", + "DeploymentUtilities/Microsoft.VisualStudio.Services.DevTestLabs.Definition.dll", + "DeploymentUtilities/Microsoft.VisualStudio.Services.DevTestLabs.Deployment.dll", + "DeploymentUtilities/Microsoft.VisualStudio.Services.WebApi.dll", + "DeploymentUtilities/Newtonsoft.Json.dll", + "DeploymentUtilities/VisualStudioRemoteDeployer.exe", + "DeploymentUtilities/VisualStudioRemoteDeployer.exe.config", + "DeploymentUtilities/Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal/Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal.psm1", + "DeploymentUtilities/Modules/Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Chef.psm1", + "DeploymentUtilities/Modules/Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal.psm1", + "DeploymentUtilities/Modules/Microsoft.TeamFoundation.DistributedTask.Task.Deployment.RemoteDeployment.psm1", + "DeploymentUtilities/Modules/Microsoft.TeamFoundation.DistributedTask.Task.DevTestLabs.psm1", + "DeploymentUtilities/Scripts/Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Sql.ps1" + ] + } + ] +} diff --git a/Tasks/DeployAzureResourceGroup/task.json b/Tasks/DeployAzureResourceGroup/task.json index 5988767c5567..54eca1272189 100644 --- a/Tasks/DeployAzureResourceGroup/task.json +++ b/Tasks/DeployAzureResourceGroup/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 81 + "Patch": 82 }, "demands": [ "azureps" @@ -207,10 +207,50 @@ ], "instanceNameFormat": "Azure Deployment:$(action) action on $(resourceGroupName)", "execution": { - "AzurePowerShell": { - "target": "$(currentDirectory)\\DeployAzureResourceGroup.ps1", - "argumentFormat": "", - "workingDirectory": "$(currentDirectory)" + "PowerShell3": { + "target": "DeployAzureResourceGroup.ps1" } + }, + "messages": { + "ARG_CreatedResourceGroup": "[Azure Resource Manager]Created resource group '{0}'", + "ARG_StartingMachine": "[Azure Resource Manager]Starting machine '{0}'", + "ARG_StartedMachine": "[Azure Resource Manager]Started machine '{0}' from Azure provider", + "ARG_StoppingMachine": "[Azure Resource Manager]Stopping machine '{0}'", + "ARG_StoppedMachine": "{0}' from Azure provider", + "ARG_DeletingMachine": "[Azure Resource Manager]Deleting machine '{0}'", + "ARG_DeletedMachine": "[Azure Resource Manager]Deleted machine '{0}' from Azure provider", + "ARG_DeletingResourceGroup": "[Azure Resource Manager]Deleting resource group '{0}'", + "ARG_DeletedResourceGroup": "[Azure Resource Manager]Deleted resource group '{0}'", + "ARG_EnsureResourceGroupWithMachine": "Ensure resource group '{0}' exists and has at least one virtual machine in it", + "ARG_GettingVmStatus": "[Azure Call]Getting the status for vm '{0}'", + "ARG_GotVmStatus": "[Azure Call]Got the status for vm '{0}'", + "ARG_GettingExtensionStatus": "[Azure Call]Getting the custom script extension '{0}' for vm '{1}'", + "ARG_GotExtensionStatus": "[Azure Call]Got the custom script extension '{0}' for vm '{1}'", + "ARG_SettingExtension": "[Azure Call]Setting the custom script extension '{0}' for vm '{1}'", + "ARG_SetExtension": "[Azure Call]Set the custom script extension '{0}' for vm '{1}'", + "ARG_RemovingExtension": "[Azure Call]Removing the custom script extension '{0}' for vm '{1}'", + "ARG_RemovedExtension": "[Azure Call]Removed the custom script extension '{0}' for vm '{1}'", + "ARG_NetworkInterfaceNotFound": "[Azure Call]No network interface found with virtual machine id {0} under resource group {1}", + "ARG_EmptyRGName": "[Azure Call]Resource group name and virtual machine ID should not be null or empty", + "ARG_UseSpnAuth": "Certificate based authentication only works with the 'Select Resource Group' action. Please select an Azure subscription with either Credential or SPN based authentication.", + "ARG_ProvideOutputVariable": "Please provide the output variable name since you have specified the 'Select Resource Group' option.", + "ARG_UnsupportedAzurePSVersion": "The required minimum version {0} of the Azure Powershell Cmdlets are not installed. You can follow the instructions at {1} to get the latest Azure powershell", + "ARG_AzureRMModuleNotFound": "The required AzureRM Powershell module is not installed. You can follow the instructions at {0} to get the latest Azure powershell", + "ARG_DeploymentFailed": "Resource group deployment '{0}' failed", + "ARG_DeploymentSucceeded": "Successfully created resource group deployment with name '{0}'", + "ARG_InvalidFilePath": "Found more than one file to deploy with search pattern '{0}'. There can be only one", + "ARG_FileNotFound": "No files were found to deploy with search pattern '{0}'", + "ARG_SpecifyValidTemplatePath": "Please specify a complete and a valid template file path", + "ARG_SpecifyValidParametersPath": "Please specify a complete and a valid template parameters file path", + "ARG_ActionNotSupported": "Action '{0}' is not supported on the provider '{1}'", + "ARG_OperationFailedOnMachine": "Operation '{0}' failed on the machine '{1}'", + "ARG_InvokeInvalidOperation": "Tried to invoke an invalid operation: '{0}'", + "ARG_NoVmsFound": "No VMs found in resource group: '{0}'. Could not register environment in the output variable: '{1}'", + "ARG_AllResourceNotFound": "Unable to get {0} for all resources in ResourceGroup : '{1}'", + "ARG_ResourceNotFound": "Unable to get {0} for '{1}' resources in ResourceGroup : '{2}'", + "ARG_SetExtensionFailed": "Setting the custom script extension '{0}' for virtual machine '{1}' failed with error : {2}", + "ARG_NetworkSecurityConfigFailed": "Failed to add the network security rule: {0}", + "ARG_SetExtensionFailedForVm": "Unable to set the custom script extension '{0}' for virtual machine '{1}': {2}", + "ARG_DeploymentPrereqFailed": "Failed to enable deployment prerequisites. {0}" } } diff --git a/Tasks/DeployAzureResourceGroup/task.loc.json b/Tasks/DeployAzureResourceGroup/task.loc.json index ea4b49f275f8..08975d02193a 100644 --- a/Tasks/DeployAzureResourceGroup/task.loc.json +++ b/Tasks/DeployAzureResourceGroup/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 81 + "Patch": 82 }, "demands": [ "azureps" @@ -207,10 +207,50 @@ ], "instanceNameFormat": "ms-resource:loc.instanceNameFormat", "execution": { - "AzurePowerShell": { - "target": "$(currentDirectory)\\DeployAzureResourceGroup.ps1", - "argumentFormat": "", - "workingDirectory": "$(currentDirectory)" + "PowerShell3": { + "target": "DeployAzureResourceGroup.ps1" } + }, + "messages": { + "ARG_CreatedResourceGroup": "ms-resource:loc.messages.ARG_CreatedResourceGroup", + "ARG_StartingMachine": "ms-resource:loc.messages.ARG_StartingMachine", + "ARG_StartedMachine": "ms-resource:loc.messages.ARG_StartedMachine", + "ARG_StoppingMachine": "ms-resource:loc.messages.ARG_StoppingMachine", + "ARG_StoppedMachine": "ms-resource:loc.messages.ARG_StoppedMachine", + "ARG_DeletingMachine": "ms-resource:loc.messages.ARG_DeletingMachine", + "ARG_DeletedMachine": "ms-resource:loc.messages.ARG_DeletedMachine", + "ARG_DeletingResourceGroup": "ms-resource:loc.messages.ARG_DeletingResourceGroup", + "ARG_DeletedResourceGroup": "ms-resource:loc.messages.ARG_DeletedResourceGroup", + "ARG_EnsureResourceGroupWithMachine": "ms-resource:loc.messages.ARG_EnsureResourceGroupWithMachine", + "ARG_GettingVmStatus": "ms-resource:loc.messages.ARG_GettingVmStatus", + "ARG_GotVmStatus": "ms-resource:loc.messages.ARG_GotVmStatus", + "ARG_GettingExtensionStatus": "ms-resource:loc.messages.ARG_GettingExtensionStatus", + "ARG_GotExtensionStatus": "ms-resource:loc.messages.ARG_GotExtensionStatus", + "ARG_SettingExtension": "ms-resource:loc.messages.ARG_SettingExtension", + "ARG_SetExtension": "ms-resource:loc.messages.ARG_SetExtension", + "ARG_RemovingExtension": "ms-resource:loc.messages.ARG_RemovingExtension", + "ARG_RemovedExtension": "ms-resource:loc.messages.ARG_RemovedExtension", + "ARG_NetworkInterfaceNotFound": "ms-resource:loc.messages.ARG_NetworkInterfaceNotFound", + "ARG_EmptyRGName": "ms-resource:loc.messages.ARG_EmptyRGName", + "ARG_UseSpnAuth": "ms-resource:loc.messages.ARG_UseSpnAuth", + "ARG_ProvideOutputVariable": "ms-resource:loc.messages.ARG_ProvideOutputVariable", + "ARG_UnsupportedAzurePSVersion": "ms-resource:loc.messages.ARG_UnsupportedAzurePSVersion", + "ARG_AzureRMModuleNotFound": "ms-resource:loc.messages.ARG_AzureRMModuleNotFound", + "ARG_DeploymentFailed": "ms-resource:loc.messages.ARG_DeploymentFailed", + "ARG_DeploymentSucceeded": "ms-resource:loc.messages.ARG_DeploymentSucceeded", + "ARG_InvalidFilePath": "ms-resource:loc.messages.ARG_InvalidFilePath", + "ARG_FileNotFound": "ms-resource:loc.messages.ARG_FileNotFound", + "ARG_SpecifyValidTemplatePath": "ms-resource:loc.messages.ARG_SpecifyValidTemplatePath", + "ARG_SpecifyValidParametersPath": "ms-resource:loc.messages.ARG_SpecifyValidParametersPath", + "ARG_ActionNotSupported": "ms-resource:loc.messages.ARG_ActionNotSupported", + "ARG_OperationFailedOnMachine": "ms-resource:loc.messages.ARG_OperationFailedOnMachine", + "ARG_InvokeInvalidOperation": "ms-resource:loc.messages.ARG_InvokeInvalidOperation", + "ARG_NoVmsFound": "ms-resource:loc.messages.ARG_NoVmsFound", + "ARG_AllResourceNotFound": "ms-resource:loc.messages.ARG_AllResourceNotFound", + "ARG_ResourceNotFound": "ms-resource:loc.messages.ARG_ResourceNotFound", + "ARG_SetExtensionFailed": "ms-resource:loc.messages.ARG_SetExtensionFailed", + "ARG_NetworkSecurityConfigFailed": "ms-resource:loc.messages.ARG_NetworkSecurityConfigFailed", + "ARG_SetExtensionFailedForVm": "ms-resource:loc.messages.ARG_SetExtensionFailedForVm", + "ARG_DeploymentPrereqFailed": "ms-resource:loc.messages.ARG_DeploymentPrereqFailed" } } \ No newline at end of file diff --git a/common.json b/common.json index c421e1afbe7b..5fc7e16c2909 100644 --- a/common.json +++ b/common.json @@ -11,6 +11,12 @@ "dest": "ps_modules" } ], + "AzureResourceGroupDeployment": [ + { + "module": "VstsAzureHelpers_", + "dest": "ps_modules" + } + ], "AzureRMWebAppDeployment": [ { "module": "VstsAzureHelpers_",