text:
$ErrorActionPreference = 'Stop'
$azureStackEnvironment = "AzureStack"
$jobId = $env:SYSTEM_JOBID;

function Get-DeploymentModulePath
{
    Write-Output "$PSScriptRoot\DeploymentUtilities"
}

function Publish-Azure-Telemetry
 {
   param([object] $deploymentResponse, [string] $jobId)
    if($deploymentResponse){
       $jsonString = -join("{" ,
       "`"IsAzureVm`" : `"$($deploymentResponse.IsAzureVm)`"" ,
       "," ,
       "`"VmUuidHash`" : `"$($deploymentResponse.VmUuidHash)`"" ,
       "," ,
       "`"TelemetryError`" : `"$($deploymentResponse.TelemetryError)`"" ,
       "," ,
       "`"JobId`" : `"$jobId`"" ,
       "}")
    }

    $telemetryString ="##vso[telemetry.publish area=TaskHub;feature=AzureFileCopy]$jsonString"
    Write-Host $telemetryString
 }

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 Get-AzureUtility
{
    param([string][Parameter(Mandatory=$true)]$connectedServiceName)

    $currentVersion =  Get-AzureCmdletsVersion
    Write-Verbose "Installed Azure PowerShell version: $currentVersion"

    $AzureVersion099 = New-Object System.Version(0, 9, 9)
    $AzureVersion103 = New-Object System.Version(1, 0, 3)
    $AzureVersion132 = New-Object System.Version(1, 3, 2)

    $azureUtilityVersion098 = "AzureUtilityLTE9.8.ps1"
    $azureUtilityVersion100 = "AzureUtilityGTE1.0.ps1"
    $azureUtilityVersion110 = "AzureUtilityGTE1.1.0.ps1"
	$azureUtilityRest100 = "AzureUtilityRest.ps1"

    if(!(Get-AzureVersionComparison -AzureVersion $currentVersion -CompareVersion $AzureVersion099))
    {
		return $azureUtilityVersion098
    }

    if(!(Get-AzureVersionComparison -AzureVersion $currentVersion -CompareVersion $AzureVersion103))
    {
		return $azureUtilityVersion100
    }

	$connectionType = Get-TypeOfConnection $connectedServiceName
	if(!(Get-AzureVersionComparison -AzureVersion $currentVersion -CompareVersion $AzureVersion132) -or ($connectionType -eq "UserNamePassword"))
    {
        return $azureUtilityVersion110
    }

    return $azureUtilityRest100
}

function Get-TypeOfConnection
{
    param([string][Parameter(Mandatory=$true)]$connectedServiceName)

    $serviceEndpoint = Get-VstsEndpoint -Name "$connectedServiceName"
    $connectionType = $serviceEndpoint.Auth.Scheme

    Write-Verbose "Connection type used is $connectionType"
    return $connectionType
}

function Get-Endpoint
{
    param([String] [Parameter(Mandatory=$true)] $connectedServiceName)

    $serviceEndpoint = Get-VstsEndpoint -Name "$connectedServiceName"
    return $serviceEndpoint
}

function Validate-AzurePowershellVersion
{
    Write-Verbose "Validating minimum required azure powershell version is greater than or equal to 0.9.0"

    $currentVersion =  Get-AzureCmdletsVersion
    Write-Verbose "Installed Azure PowerShell version: $currentVersion"

    $minimumAzureVersion = New-Object System.Version(0, 9, 0)
    $versionCompatible = Get-AzureVersionComparison -AzureVersion $currentVersion -CompareVersion $minimumAzureVersion

    if(!$versionCompatible)
    {
        Write-Telemetry "Task_InternalError" "UnsupportedAzurePSVersion"
        Throw (Get-VstsLocString -Key "AFC_AzurePSNotInstalled" -ArgumentList $minimumAzureVersion)
    }

    Write-Verbose "Validated the required azure powershell version is greater than or equal to 0.9.0"
}

function Get-StorageKey
{
    param([string][Parameter(Mandatory=$true)]$storageAccountName,
          [string][Parameter(Mandatory=$true)]$connectionType,
          [string][Parameter(Mandatory=$true)]$connectedServiceName)

    $serviceEndpoint = Get-Endpoint $connectedServiceName
    $storageAccountName = $storageAccountName.Trim()
    if($connectionType -eq 'Certificate' -or $connectionType -eq 'UserNamePassword')
    {
        try
        {
            # getting storage key from RDFE
            $storageKey = Get-AzureStorageKeyFromRDFE -storageAccountName $storageAccountName -endpoint $serviceEndpoint
        }
        catch [Hyak.Common.CloudException]
        {
            $exceptionMessage = $_.Exception.Message.ToString()
            Write-Verbose "[Azure Call](RDFE) ExceptionMessage: $exceptionMessage"

            if($connectionType -eq 'Certificate')
            {
                Write-Telemetry "Task_InternalError" "ClassicStorageAccountNotFound"
                Throw (Get-VstsLocString -Key "AFC_ClassicStorageAccountNotFound" -ArgumentList $storageAccountName)
            }
            # Since authentication is UserNamePassword we will check whether storage is non-classic
            # Bug: We are validating azureps version to be atleast 0.9.0 though it is not required if user working on classic resources
            else
            {
                try
                {
                    # checking azure powershell version to make calls to ARM endpoint
                    Validate-AzurePowershellVersion

                    # getting storage account key from ARM endpoint
                    $storageKey = Get-AzureStorageKeyFromARM -storageAccountName $storageAccountName -serviceEndpoint $serviceEndpoint
                }
                catch
                {
                    #since authentication was UserNamePassword so we cant suggest user whether storage should be classic or non-classic
                    Write-Telemetry "Task_InternalError" "StorageAccountNotFound"
                    Throw (Get-VstsLocString -Key "AFC_GenericStorageAccountNotFound" -ArgumentList $storageAccountName)
                }
            }
        }
    }
    else
    {
        # checking azure powershell version to make calls to ARM endpoint
        Validate-AzurePowershellVersion

        # getting storage account key from ARM endpoint
        $storageKey = Get-AzureStorageKeyFromARM -storageAccountName $storageAccountName -serviceEndpoint $serviceEndpoint
    }

    return $storageKey
}

function Get-blobStorageEndpoint
{
    param([string][Parameter(Mandatory=$true)]$storageAccountName,
          [string][Parameter(Mandatory=$true)]$connectionType,
          [string][Parameter(Mandatory=$true)]$connectedServiceName)

    $endpoint = Get-Endpoint $connectedServiceName
    $storageAccountName = $storageAccountName.Trim()
    if($connectionType -eq 'Certificate' -or $connectionType -eq 'UserNamePassword')
    {
        try
        {
            # getting storage key from RDFE
            $blobStorageEndpoint = Get-AzureBlobStorageEndpointFromRDFE -storageAccountName $storageAccountName -endpoint $endpoint
        }
        catch [Hyak.Common.CloudException]
        {
            $exceptionMessage = $_.Exception.Message.ToString()
            Write-Verbose "[Azure Call](RDFE) ExceptionMessage: $exceptionMessage"
            Write-Telemetry "Task_InternalError" "StorageAccountNotFound"
            Throw (Get-VstsLocString -Key "AFC_BlobStorageNotFound" -ArgumentList $storageAccountName)
        }
    }
    else
    {
        # getting storage account key from ARM endpoint
        $blobStorageEndpoint = Get-AzureBlobStorageEndpointFromARM -storageAccountName $storageAccountName -endpoint $endpoint
    }

    return $blobStorageEndpoint
}

function Get-StorageAccountType
{
    param([string][Parameter(Mandatory=$true)]$storageAccountName,
          [string][Parameter(Mandatory=$true)]$connectionType,
          [string][Parameter(Mandatory=$true)]$connectedServiceName)

    $endpoint = Get-Endpoint $connectedServiceName
    $storageAccountName = $storageAccountName.Trim()
    if($connectionType -eq 'Certificate' -or $connectionType -eq 'UserNamePassword')
    {
        try
        {
            # getting storage account type from RDFE
            $storageAccountType = Get-AzureStorageAccountTypeFromRDFE -storageAccountName $storageAccountName -endpoint $endpoint
        }
        catch [Hyak.Common.CloudException]
        {
            $exceptionMessage = $_.Exception.Message.ToString()
            Write-Verbose "[Azure Call](RDFE) ExceptionMessage: $exceptionMessage"
            Write-Telemetry "Task_InternalError" "StorageAccountNotFound"
            Throw (Get-VstsLocString -Key "AFC_BlobStorageNotFound" -ArgumentList $storageAccountName)
        }
    }
    else
    {
        # getting storage account type from ARM endpoint
        $storageAccountType = Get-AzureStorageAccountTypeFromARM -storageAccountName $storageAccountName -endpoint $endpoint
    }

	if($storageAccountType -ne $null)
    {
        return $storageAccountType.ToString()
    }
}

function ThrowError
{
    param([string]$errorMessage)

    $readmelink = "https://aka.ms/azurefilecopyreadme"
    $helpMessage = (Get-VstsLocString -Key "AFC_AzureFileCopyMoreHelp" -ArgumentList $readmelink)
    throw "$errorMessage $helpMessage"
}

function Upload-FilesToAzureContainer
{
    param([string][Parameter(Mandatory=$true)]$sourcePath,
          [string][Parameter(Mandatory=$true)]$storageAccountName,
          [string][Parameter(Mandatory=$true)]$containerName,
          [string]$blobPrefix,
		  [string]$blobStorageEndpoint,
          [string][Parameter(Mandatory=$true)]$storageKey,
          [string][Parameter(Mandatory=$true)]$azCopyLocation,
          [string]$additionalArguments,
          [string][Parameter(Mandatory=$true)]$destinationType)

    $sourcePath = $sourcePath.Trim('"')
    $storageAccountName = $storageAccountName.Trim()
    try
    {
        Write-Output (Get-VstsLocString -Key "AFC_UploadFilesStorageAccount" -ArgumentList $sourcePath, $storageAccountName, $containerName, $blobPrefix)

        if(-not [string]::IsNullOrWhiteSpace($blobStorageEndpoint))
        {
            $blobStorageURI = $blobStorageEndpoint+$containerName+"/"+$blobPrefix
        }

        if([string]::IsNullOrWhiteSpace($additionalArguments))
        {
            $uploadResponse = Copy-FilesToAzureBlob -SourcePathLocation $sourcePath -StorageAccountName $storageAccountName -ContainerName $containerName -BlobPrefix $blobPrefix -StorageAccountKey  $storageKey -AzCopyLocation $azCopyLocation -BlobStorageURI $blobStorageURI
        }
        else
        {
            $uploadResponse = Copy-FilesToAzureBlob -SourcePathLocation $sourcePath -StorageAccountName $storageAccountName -ContainerName $containerName -BlobPrefix $blobPrefix -StorageAccountKey $storageKey -AzCopyLocation $azCopyLocation -AdditionalArguments $additionalArguments -BlobStorageURI $blobStorageURI
        }
    }
    catch
    {
        # deletes container only if we have created temporary container
        if ($destinationType -ne "AzureBlob")
        {
            Remove-AzureContainer -containerName $containerName -storageContext $storageContext
        }

        $exceptionMessage = $_.Exception.Message.ToString()
        Write-Verbose "ExceptionMessage: $exceptionMessage"

        $errorMessage = (Get-VstsLocString -Key "AFC_UploadContainerStorageAccount" -ArgumentList $containerName, $storageAccountName, $blobPrefix, $exceptionMessage)
        Write-Telemetry "Task_InternalError" "BlobUploadFailed"
        ThrowError -errorMessage $errorMessage
    }
    finally
    {
        if ($uploadResponse.Status -eq "Failed")
        {
            # deletes container only if we have created temporary container
            if ($destination -ne "AzureBlob")
            {
                Remove-AzureContainer -containerName $containerName -storageContext $storageContext
            }

            $uploadErrorMessage = $uploadResponse.Error
            Write-Verbose "UploadErrorMessage: $uploadErrorMessage"

            $uploadResponseLog = $uploadResponse.Log
            Write-Verbose "UploadResponseLog: $uploadResponseLog"

            $errorMessage = (Get-VstsLocString -Key "AFC_UploadContainerStorageAccount" -ArgumentList $containerName, $storageAccountName, $blobPrefix, $uploadErrorMessage)
             Write-Telemetry "Task_InternalError" "BlobUploadFailed"
            ThrowError -errorMessage $errorMessage
        }
        elseif ($uploadResponse.Status -eq "Succeeded")
        {
            Write-Output (Get-VstsLocString -Key "AFC_UploadFileSuccessful" -ArgumentList $sourcePath, $storageAccountName, $containerName, $blobPrefix)
        }
    }
}

function Does-AzureVMMatchTagFilterCriteria
{
    param([object]$azureVMResource,
          [string]$filter)

    if($azureVMResource)
    {
        # If no filters are provided, by default operations are performed on all azure resources
        if([string]::IsNullOrEmpty($filter))
        {
            return $true
        }

        $tagsFilterArray = $filter.Split(';').Trim()
        foreach($tag in $tagsFilterArray)
        {
            $tagKeyValue = $tag.Split(':').Trim()
            $tagKey =  $tagKeyValue[0]
            $tagValues = $tagKeyValue[1]

            if($tagKeyValue.Length -ne 2 -or [string]::IsNullOrWhiteSpace($tagKey) -or [string]::IsNullOrWhiteSpace($tagValues))
            {
                Write-Telemetry "Input_Validation" "FILTERING_IncorrectFormat"
                throw (Get-VstsLocString -Key "AFC_IncorrectTags")
            }

            $tagValueArray = $tagValues.Split(',').Trim()

            if($azureVMResource.Tags)
            {
                foreach($azureVMResourceTag in $azureVMResource.Tags.GetEnumerator())
                {
                    if($azureVMResourceTag.Key -contains $tagKey)
                    {
                        $azureVMTagValueArray = $azureVMResourceTag.Value.Split(",").Trim()
                        foreach($tagValue in $tagValueArray)
                        {
                            if($azureVMTagValueArray -contains $tagValue)
                            {
                                return $true
                            }
                        }
                    }
                }
            }
        }

        return $false
    }
}

function Get-TagBasedFilteredAzureVMs
{
    param([object]$azureVMResources,
          [string]$filter)

    if($azureVMResources)
    {
        $filteredAzureVMResources = @()
        foreach($azureVMResource in $azureVMResources)
        {
            if(Does-AzureVMMatchTagFilterCriteria -azureVMResource $azureVMResource -filter $filter)
            {
                Write-Verbose "azureVM with name: $($azureVMResource.Name) matches filter criteria"
                $filteredAzureVMResources += $azureVMResource
            }
        }

        return $filteredAzureVMResources
    }
}

function Get-MachineBasedFilteredAzureVMs
{
    param([object]$azureVMResources,
          [string]$filter)

    if($azureVMResources -and -not [string]::IsNullOrEmpty($filter))
    {
        $filteredAzureVMResources = @()

        $machineFilterArray = $filter.Split(',').Trim()
        $machineFilterArray = $machineFilterArray | % {$_.ToLower()} | Select -Uniq
        foreach($machine in $machineFilterArray)
        {
            $azureVMResource = $azureVMResources | Where-Object {$_.Name -contains $machine}
            if($azureVMResource)
            {
                $filteredAzureVMResources += $azureVMResource
            }
            else
            {
                $commaSeparatedMachinesNotPresentInRG += ($(if($commaSeparatedMachinesNotPresentInRG){", "}) + $machine)
            }

            if($commaSeparatedMachinesNotPresentInRG -ne $null)
            {
                Write-Telemetry "Input_Validation" "FILTERING_MachinesNotPresentInRG"
                throw (Get-VstsLocString -Key "AFC_MachineDoesNotExist" -ArgumentList $commaSeparatedMachinesNotPresentInRG)
            }
        }

        return $filteredAzureVMResources
    }
}

function Get-FilteredAzureVMsInResourceGroup
{
    param([object]$azureVMResources,
          [string]$resourceFilteringMethod,
          [string]$filter)

    if($azureVMResources -and -not [string]::IsNullOrEmpty($resourceFilteringMethod))
    {
        if($resourceFilteringMethod -eq "tags" -or [string]::IsNullOrEmpty($filter))
        {
            $filteredAzureVMResources = Get-TagBasedFilteredAzureVMs -azureVMResources $azureVMResources -filter $filter
        }
        else
        {
            $filteredAzureVMResources = Get-MachineBasedFilteredAzureVMs -azureVMResources $azureVMResources -filter $filter
        }

        return $filteredAzureVMResources
    }
}

function Get-FilteredAzureClassicVMsInResourceGroup
{
    param([object]$azureClassicVMResources,
          [string]$resourceFilteringMethod,
          [string]$filter)

    if($azureClassicVMResources -and -not [string]::IsNullOrEmpty($resourceFilteringMethod))
    {
        Write-Verbose "Filtering azureClassicVM resources with filtering option:'$resourceFilteringMethod' and filters:'$filter'"
        $filteredAzureClassicVMResources = Get-FilteredAzureVMsInResourceGroup -azureVMResources $azureClassicVMResources -resourceFilteringMethod $resourceFilteringMethod -filter $filter

        return $filteredAzureClassicVMResources
    }
}

function Get-FilteredAzureRMVMsInResourceGroup
{
    param([object]$azureRMVMResources,
          [string]$resourceFilteringMethod,
          [string]$filter)

    if($azureRMVMResources -and -not [string]::IsNullOrEmpty($resourceFilteringMethod))
    {
        Write-Verbose "Filtering azureRMVM resources with filtering option:$resourceFilteringMethod and filters:$filter"
        $filteredAzureRMVMResources = Get-FilteredAzureVMsInResourceGroup -azureVMResources $azureRMVMResources -resourceFilteringMethod $resourceFilteringMethod -filter $filter

        return $filteredAzureRMVMResources
    }
}

function Get-MachineNameFromId
{
    param([string]$resourceGroupName,
          [System.Collections.Hashtable]$map,
          [string]$mapParameter,
          [Object]$azureRMVMResources,
          [boolean]$throwOnTotalUnavailability,
          [string]$debugLogsFlag)

    if($map)
    {
        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "Map for $mapParameter : " -verbose
            Write-Verbose ($map | Format-List | Out-String) -verbose

            Write-Verbose "azureRMVMResources: " -verbose
            Write-Verbose ($azureRMVMResources | Format-List | Out-String) -verbose
        }

        Write-Verbose "throwOnTotalUnavailability: $throwOnTotalUnavailability"

        $errorCount = 0
        foreach($vm in $azureRMVMResources)
        {
            $value = $map[$vm.Id.ToLower()]
            $resourceName = $vm.Name
            if(-not [string]::IsNullOrEmpty($value))
            {
                Write-Verbose "$mapParameter value for resource $resourceName is $value"
                $map.Remove($vm.Id.ToLower())
                $map[$resourceName] = $value
            }
            else
            {
                $errorCount = $errorCount + 1
                Write-Verbose "Unable to find $mapParameter for resource $resourceName"
            }
        }

        if($throwOnTotalUnavailability -eq $true)
        {
            if($errorCount -eq $azureRMVMResources.Count -and $azureRMVMResources.Count -ne 0)
            {
                throw (Get-VstsLocString -Key "AFC_MachineNameFromIdErrorAllResources" -ArgumentList $mapParameter, $resourceGroupName)
            }
            else
            {
                if($errorCount -gt 0 -and $errorCount -ne $azureRMVMResources.Count)
                {
                    Write-Warning (Get-VstsLocString -Key "AFC_MachineNameFromIdError" -ArgumentList $mapParameter, $errorCount, $resourceGroupName)
                }
            }
        }

        return $map
    }
}

function Get-MachinesFqdnsForPublicIP
{
    param([string]$resourceGroupName,
          [Object]$publicIPAddressResources,
          [Object]$networkInterfaceResources,
          [Object]$azureRMVMResources,
          [System.Collections.Hashtable]$fqdnMap,
          [string]$debugLogsFlag)

    if(-not [string]::IsNullOrEmpty($resourceGroupName)-and $publicIPAddressResources -and $networkInterfaceResources)
    {
        Write-Verbose "Trying to get FQDN for the azureRM VM resources under public IP from resource Group $resourceGroupName"

        #Map the ipc to the fqdn
        foreach($publicIp in $publicIPAddressResources)
        {
            if(-not [string]::IsNullOrEmpty($publicIp.IpConfiguration.Id))
            {
                $publicIPKey = $publicIp.IpConfiguration.Id.ToLower()
                Write-Verbose "Adding entry to FQDN map with key $publicIPKey"

                if(-not [string]::IsNullOrEmpty($publicIP.DnsSettings.Fqdn))
                {
                    Write-Verbose "Inserting to FQDN map with value (FQDN) : $publicIPKey"
                    $fqdnMap[$publicIPKey] =  $publicIP.DnsSettings.Fqdn
                }
                elseif(-not [string]::IsNullOrEmpty($publicIP.IpAddress))
                {
                    Write-Verbose "Inserting to FQDN map with value (IP Address) : $publicIPKey"
                    $fqdnMap[$publicIPKey] =  $publicIP.IpAddress
                }
            }
        }

        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "fqdnMap for MachinesFqdnsForPublicIP after mapping ip configuration to fqdn: " -Verbose
            Write-Verbose ($fqdnMap | Format-List | Out-String) -Verbose
        }

        #Find out the NIC, and thus the VM corresponding to a given ipc
        foreach($nic in $networkInterfaceResources)
        {
            foreach($ipc in $nic.IpConfigurations)
            {
                $fqdn =  $fqdnMap[$ipc.Id.ToLower()]
                if(-not [string]::IsNullOrEmpty($fqdn))
                {
                    $fqdnMap.Remove($ipc.Id.ToLower())
                    if($nic.VirtualMachine)
                    {
                        $vmId = $nic.VirtualMachine.Id.ToLower()
                        Write-Verbose "Adding entry to FQDN map with key $vmId"
                        $fqdnMap[$vmId] = $fqdn
                    }
                }
            }
        }

        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "final fqdnMap for MachinesFqdnsForPublicIP after finding vm id corresponding to ip configuration: " -Verbose
            Write-Verbose ($fqdnMap | Format-List | Out-String) -Verbose
        }
    }

    Write-Verbose "Got FQDN for the azureRM VM resources under public IP from resource Group $resourceGroupName"

    return $fqdnMap
}

function Get-MachinesFqdnsForLB
{
    param([string]$resourceGroupName,
          [Object]$publicIPAddressResources,
          [Object]$networkInterfaceResources,
          [Object]$frontEndIPConfigs,
          [System.Collections.Hashtable]$fqdnMap,
          [string]$debugLogsFlag)

    if(-not [string]::IsNullOrEmpty($resourceGroupName) -and $publicIPAddressResources -and $networkInterfaceResources -and $frontEndIPConfigs)
    {
        Write-Verbose "Trying to get FQDN for the RM azureVM resources under load balancer from resource group: $resourceGroupName"

        #Map the public ip id to the fqdn
        foreach($publicIp in $publicIPAddressResources)
        {
            if(-not [string]::IsNullOrEmpty($publicIp.IpConfiguration.Id))
            {
                if(-not [string]::IsNullOrEmpty($publicIP.DnsSettings.Fqdn))
                {
                    $fqdnMap[$publicIp.Id.ToLower()] =  $publicIP.DnsSettings.Fqdn
                }
                elseif(-not [string]::IsNullOrEmpty($publicIP.IpAddress))
                {
                    $fqdnMap[$publicIp.Id.ToLower()] =  $publicIP.IpAddress
                }
            }
        }

        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "fqdnMap for MachinesFqdnsForLB after mapping ip configuration to fqdn: " -Verbose
            Write-Verbose ($fqdnMap | Format-List | Out-String) -Verbose
        }

        #Get the NAT rule for a given ip id
        foreach($config in $frontEndIPConfigs)
        {
            if(-not [string]::IsNullOrEmpty($config.PublicIpAddress.Id))
            {
                $fqdn = $fqdnMap[$config.PublicIpAddress.Id.ToLower()]
                if(-not [string]::IsNullOrEmpty($fqdn))
                {
                    $fqdnMap.Remove($config.PublicIpAddress.Id.ToLower())
                    foreach($rule in $config.InboundNatRules)
                    {
                        $fqdnMap[$rule.Id.ToLower()] =  $fqdn
                    }
                }
            }
        }

        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "fqdnMap for MachinesFqdnsForLB after getting NAT rule for given ip configuration: " -Verbose
            Write-Verbose ($fqdnMap | Format-List | Out-String) -Verbose
        }

        #Find out the NIC, and thus the corresponding machine to which the NAT rule belongs
        foreach($nic in $networkInterfaceResources)
        {
            foreach($ipc in $nic.IpConfigurations)
            {
                foreach($rule in $ipc.LoadBalancerInboundNatRules)
                {
                    $fqdn = $fqdnMap[$rule.Id.ToLower()]
                    if(-not [string]::IsNullOrEmpty($fqdn))
                    {
                        $fqdnMap.Remove($rule.Id.ToLower())
                        if($nic.VirtualMachine)
                        {
                            $fqdnMap[$nic.VirtualMachine.Id.ToLower()] = $fqdn
                        }
                    }
                }
            }
        }

        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "final fqdnMap for MachinesFqdnsForLB after getting vm id corresponding to NAT rule for given ip configuration: " -Verbose
            Write-Verbose ($fqdnMap | Format-List | Out-String) -Verbose
        }
    }

    Write-Verbose "Got FQDN for the RM azureVM resources under load balancer from resource Group $resourceGroupName"

    return $fqdnMap
}

function Get-FrontEndPorts
{
    param([string]$backEndPort,
          [System.Collections.Hashtable]$portList,
          [Object]$networkInterfaceResources,
          [Object]$inboundRules,
          [string]$debugLogsFlag)

    if(-not [string]::IsNullOrEmpty($backEndPort) -and $networkInterfaceResources -and $inboundRules)
    {
        Write-Verbose "Trying to get front end ports for $backEndPort"

        $filteredRules = $inboundRules | Where-Object {$_.BackendPort -eq $backEndPort}

        #Map front end port to back end ipc
        foreach($rule in $filteredRules)
        {
            if($rule.BackendIPConfiguration)
            {
                $portList[$rule.BackendIPConfiguration.Id.ToLower()] = $rule.FrontendPort
            }
        }

        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "portList for FrontEndPorts after mapping front end port to backend ip configuration: " -Verbose
            Write-Verbose ($portList | Format-List | Out-String) -Verbose
        }

        #Get the nic, and the corresponding machine id for a given back end ipc
        foreach($nic in $networkInterfaceResources)
        {
            foreach($ipConfig in $nic.IpConfigurations)
            {
                $frontEndPort = $portList[$ipConfig.Id.ToLower()]
                if(-not [string]::IsNullOrEmpty($frontEndPort))
                {
                    $portList.Remove($ipConfig.Id.ToLower())
                    if($nic.VirtualMachine)
                    {
                        $portList[$nic.VirtualMachine.Id.ToLower()] = $frontEndPort
                    }
                }
            }
        }

        if($debugLogsFlag -eq "true")
        {
            Write-Verbose "portList for FrontEndPorts after getting vm id corresponding to given backend ip configuration, after finding nic: " -Verbose
            Write-Verbose ($portList | Format-List | Out-String) -Verbose
        }
    }

    Write-Verbose "Got front end ports for $backEndPort"
    return $portList
}

function Get-AzureRMVMsConnectionDetailsInResourceGroup
{
    param([string]$resourceGroupName,
          [object]$azureRMVMResources,
          [string]$enableCopyPrerequisites,
          [string]$connectedServiceName)

    [hashtable]$fqdnMap = @{}
    $winRMHttpsPortMap = New-Object 'System.Collections.Generic.Dictionary[string, string]'
    [hashtable]$azureRMVMsDetails = @{}
    $debugLogsFlag= $env:system_debug

    # Getting endpoint used for the task
    if($connectedServiceName)
    {
        $endpoint = Get-Endpoint -connectedServiceName $connectedServiceName
    }

    $isAzureStackEnvironment = $false
    if($endpoint -and $endpoint.Data -and $endpoint.Data.Environment) {
        $environmentName = $Endpoint.Data.Environment
        if($environmentName -eq $azureStackEnvironment)
        {
            $isAzureStackEnvironment = $true
        }
    }

    if (-not [string]::IsNullOrEmpty($resourceGroupName) -and $azureRMVMResources)
    {

        if($isAzureStackEnvironment)
        {
            Write-Verbose "Fetching resource group resources details for Azure Stack environment."
            $azureRGResourcesDetails = Get-AzureRMResourceGroupResourcesDetailsForAzureStack -resourceGroupName $resourceGroupName -azureRMVMResources $azureRMVMResources -endpoint $endpoint
        }
        else
        {
            Write-Verbose "Fetching resource group resources details for Azure/National cloud environments."
            $azureRGResourcesDetails = Get-AzureRMResourceGroupResourcesDetails -resourceGroupName $resourceGroupName -azureRMVMResources $azureRMVMResources
        }

        $networkInterfaceResources = $azureRGResourcesDetails["networkInterfaceResources"]
        $publicIPAddressResources = $azureRGResourcesDetails["publicIPAddressResources"]
        $loadBalancerResources = $azureRGResourcesDetails["loadBalancerResources"]

        if($loadBalancerResources)
        {
            foreach($lbName in $loadBalancerResources.Keys)
            {
                $lbDetails = $loadBalancerResources[$lbName]
                $frontEndIPConfigs = $lbDetails["frontEndIPConfigs"]
                $inboundRules = $lbDetails["inboundRules"]

                $fqdnMap = Get-MachinesFqdnsForLB -resourceGroupName $resourceGroupName -publicIPAddressResources $publicIPAddressResources -networkInterfaceResources $networkInterfaceResources `
                                                  -frontEndIPConfigs $frontEndIPConfigs -fqdnMap $fqdnMap -debugLogsFlag $debugLogsFlag
                $winRMHttpsPortMap = Get-FrontEndPorts -BackEndPort "5986" -PortList $winRMHttpsPortMap -networkInterfaceResources $networkInterfaceResources `
                                                       -inboundRules $inboundRules -debugLogsFlag $debugLogsFlag
            }

            $winRMHttpsPortMap = Get-MachineNameFromId -Map $winRMHttpsPortMap -MapParameter "Front End port" -azureRMVMResources $azureRMVMResources `
                                                       -throwOnTotalUnavailability $false -debugLogsFlag $debugLogsFlag
        }

        $fqdnMap = Get-MachinesFqdnsForPublicIP -resourceGroupName $resourceGroupName -publicIPAddressResources $publicIPAddressResources -networkInterfaceResources $networkInterfaceResources `
                                                -azureRMVMResources $azureRMVMResources -fqdnMap $fqdnMap -debugLogsFlag $debugLogsFlag
        $fqdnMap = Get-MachineNameFromId -resourceGroupName $resourceGroupName -Map $fqdnMap -MapParameter "FQDN" -azureRMVMResources $azureRMVMResources `
                                         -throwOnTotalUnavailability $true -debugLogsFlag $debugLogsFlag

        foreach ($resource in $azureRMVMResources)
        {
            $resourceName = $resource.Name
            $resourceId = $resource.Id
            $resourceFQDN = $fqdnMap[$resourceName]
            $resourceWinRMHttpsPort = $winRMHttpsPortMap[$resourceName]
            if([string]::IsNullOrWhiteSpace($resourceWinRMHttpsPort))
            {
                Write-Verbose "Defaulting WinRmHttpsPort of $resourceName to 5986"
                $resourceWinRMHttpsPort = "5986"
            }

            $resourceProperties = @{}
            $resourceProperties.Name = $resourceName
            $resourceProperties.fqdn = $resourceFQDN
            $resourceProperties.winRMHttpsPort = $resourceWinRMHttpsPort

            $azureRMVMsDetails.Add($resourceName, $resourceProperties)

            if ($enableCopyPrerequisites -eq "true")
            {
                Write-Verbose "Enabling winrm for virtual machine $resourceName" -Verbose
                Add-AzureVMCustomScriptExtension -resourceGroupName $resourceGroupName -vmId $resourceId -vmName $resourceName -dnsName $resourceFQDN -location $resource.Location -connectedServiceName $connectedServiceName
            }
        }

        return $azureRMVMsDetails
    }
}

function Check-AzureCloudServiceExists
{
    param([string]$cloudServiceName,
          [string]$connectionType)

    if(-not [string]::IsNullOrEmpty($cloudServiceName) -and -not [string]::IsNullOrEmpty($connectionType))
    {
        try
        {
            $azureCloudService = Get-AzureCloudService -cloudServiceName $cloudServiceName
        }
        catch [Hyak.Common.CloudException]
        {
            $exceptionMessage = $_.Exception.Message.ToString()
            Write-Verbose "ExceptionMessage: $exceptionMessage" -Verbose

            # throwing only in case of Certificate authentication, Since userNamePassword authentication works with ARM resources also
            if($connectionType -eq 'Certificate')
            {
                Write-Telemetry "Input_Validation" "PREREQ_ResourceGroupNotFound"
                throw (Get-VstsLocString -Key "AFC_ResourceGroupNotFoundForSelectedConnection" -ArgumentList $connectionType, $cloudServiceName)
            }
        }
    }
}

function Get-AzureVMResourcesProperties
{
    param([string]$resourceGroupName,
          [string]$connectionType,
          [string]$resourceFilteringMethod,
          [string]$machineNames,
          [string]$enableCopyPrerequisites,
          [string]$connectedServiceName)

    $machineNames = $machineNames.Trim()
    if(-not [string]::IsNullOrEmpty($resourceGroupName) -and -not [string]::IsNullOrEmpty($connectionType))
    {
        if($connectionType -eq 'Certificate' -or $connectionType -eq 'UserNamePassword')
        {
            Check-AzureCloudServiceExists -cloudServiceName $resourceGroupName -connectionType $connectionType

            $azureClassicVMResources = Get-AzureClassicVMsInResourceGroup -resourceGroupName $resourceGroupName
            $filteredAzureClassicVMResources = Get-FilteredAzureClassicVMsInResourceGroup -azureClassicVMResources $azureClassicVMResources -resourceFilteringMethod $resourceFilteringMethod -filter $machineNames
            $azureVMsDetails = Get-AzureClassicVMsConnectionDetailsInResourceGroup -resourceGroupName $resourceGroupName -azureClassicVMResources $filteredAzureClassicVMResources

            # since authentication is userNamePassword, we will check whether resource group has RM resources
            if($connectionType -eq 'UserNamePassword' -and $azureVMsDetails.Count -eq 0)
            {
                Write-Verbose "Trying to find RM resources since there are no classic resources in resource group: $resourceGroupName"

                $azureRMVMResources = Get-AzureRMVMsInResourceGroup -resourceGroupName  $resourceGroupName
                $filteredAzureRMVMResources = Get-FilteredAzureRMVMsInResourceGroup -azureRMVMResources $azureRMVMResources -resourceFilteringMethod $resourceFilteringMethod -filter $machineNames
                $azureVMsDetails = Get-AzureRMVMsConnectionDetailsInResourceGroup -resourceGroupName $resourceGroupName -azureRMVMResources $filteredAzureRMVMResources -enableCopyPrerequisites $enableCopyPrerequisites -connectedServiceName $connectedServiceName
            }
        }
        else
        {
            $azureRMVMResources = Get-AzureRMVMsInResourceGroup -resourceGroupName  $resourceGroupName
            $filteredAzureRMVMResources = Get-FilteredAzureRMVMsInResourceGroup -azureRMVMResources $azureRMVMResources -resourceFilteringMethod $resourceFilteringMethod -filter $machineNames
            $azureVMsDetails = Get-AzureRMVMsConnectionDetailsInResourceGroup -resourceGroupName $resourceGroupName -azureRMVMResources $filteredAzureRMVMResources -enableCopyPrerequisites $enableCopyPrerequisites -connectedServiceName $connectedServiceName
        }

        # throw if no azure VMs found in resource group or due to filtering
        if($azureVMsDetails.Count -eq 0)
        {
            if([string]::IsNullOrEmpty($machineNames) -or ($azureClassicVMResources.Count -eq 0 -and $azureRMVMResources.Count -eq 0))
            {
                if($connectionType -eq 'Certificate')
                {
                    Write-Telemetry "Input_Validation" "PREREQ_NoClassicVMResources"
                    throw (Get-VstsLocString -Key "AFC_NoClassicVMResources" -ArgumentList $resourceGroupName, $connectionType)
                }
                elseif($connectionType -eq 'ServicePrincipal')
                {
                    Write-Telemetry "Input_Validation" "PREREQ_NoRMVMResources"
                    throw (Get-VstsLocString -Key "AFC_NoARMVMResources" -ArgumentList $resourceGroupName, $connectionType)
                }
                else
                {
                     Write-Telemetry "Input_Validation" "PREREQ_NoVMResources"
                     throw (Get-VstsLocString -Key "AFC_NoGenericVMResources" -ArgumentList $resourceGroupName)
                }
            }
            else
            {
                Write-Telemetry "Input_Validation" "FILTERING_NoVMResources"
                throw (Get-VstsLocString -Key "AFC_FilteringNoVMResources" -ArgumentList $resourceGroupName, $resourceFilteringMethod, $machineNames)
            }
        }

        return $azureVMsDetails
    }
}

function Get-SkipCACheckOption
{
    param([string]$skipCACheck)

    $doSkipCACheckOption = '-SkipCACheck'
    $doNotSkipCACheckOption = ''

    if(-not [string]::IsNullOrEmpty($skipCACheck))
    {
        if ($skipCACheck -eq "false")
        {
            Write-Verbose "Not skipping CA Check"
            return $doNotSkipCACheckOption
        }

        Write-Verbose "Skipping CA Check"
        return $doSkipCACheckOption
    }
}

function Get-AzureVMsCredentials
{
    param([string][Parameter(Mandatory=$true)]$vmsAdminUserName,
          [string][Parameter(Mandatory=$true)]$vmsAdminPassword)

    Write-Verbose "Azure VMs Admin Username: $vmsAdminUserName"
    $azureVmsCredentials = New-Object 'System.Net.NetworkCredential' -ArgumentList $vmsAdminUserName, $vmsAdminPassword

    return $azureVmsCredentials
}

function Copy-FilesSequentiallyToAzureVMs
{
    param([string][Parameter(Mandatory=$true)]$storageAccountName,
          [string][Parameter(Mandatory=$true)]$containerName,
          [string][Parameter(Mandatory=$true)]$containerSasToken,
		  [string]$blobStorageEndpoint,
          [string][Parameter(Mandatory=$true)]$targetPath,
          [string][Parameter(Mandatory=$true)]$azCopyLocation,
          [object][Parameter(Mandatory=$true)]$azureVMResourcesProperties,
          [object][Parameter(Mandatory=$true)]$azureVMsCredentials,
          [string][Parameter(Mandatory=$true)]$cleanTargetBeforeCopy,
          [string]$communicationProtocol,
          [string]$skipCACheckOption,
          [string][Parameter(Mandatory=$true)]$enableDetailedLoggingString,
          [string]$additionalArguments,
          [string][Parameter(Mandatory=$true)]$connectionType)

    foreach ($resource in $azureVMResourcesProperties.Keys)
    {
        $resourceProperties = $azureVMResourcesProperties[$resource]
        $resourceFQDN = $resourceProperties.fqdn
        $resourceName = $resourceProperties.Name
        $resourceWinRMHttpsPort = $resourceProperties.winRMHttpsPort

        Write-Output (Get-VstsLocString -Key "AFC_CopyStarted" -ArgumentList $resourceName)

        $deploymentUtilitiesLocation = Get-DeploymentModulePath
        $copyResponse = Invoke-Command -ScriptBlock $AzureFileCopyJob -ArgumentList `
                            $deploymentutilitieslocation, $resourceFQDN, $storageAccountName, $containerName, $containerSasToken, $blobStorageEndpoint, $azCopyLocation, $targetPath, $azureVMsCredentials, `
                            $cleanTargetBeforeCopy, $resourceWinRMHttpsPort, $communicationProtocol, $skipCACheckOption, $enableDetailedLoggingString, $additionalArguments

        $status = $copyResponse.Status

        Write-ResponseLogs -operationName 'AzureFileCopy' -fqdn $resourceName -deploymentResponse $copyResponse
        Write-Output (Get-VstsLocString -Key "AFC_CopyCompleted" -ArgumentList $resourceName, $status)
        Publish-Azure-Telemetry -deploymentResponse $copyResponse -jobId $jobId
        if ($status -ne "Passed")
        {
            $winrmHelpMsg = Get-VstsLocString -Key "AFC_WinRMHelpMessage"
            $copyErrorMessage =  $copyResponse.Error.Message
            if($connectionType -eq 'ServicePrincipal')
            {
                $copyErrorMessage = $copyErrorMessage + $winrmHelpMsg
            }

            Write-Verbose "CopyErrorMessage: $copyErrorMessage" -Verbose

            Write-Telemetry "DTLSDK_Error" $copyResponse.DeploymentSummary
            ThrowError -errorMessage $copyErrorMessage
        }
    }
}

function Copy-FilesParallellyToAzureVMs
{
    param([string][Parameter(Mandatory=$true)]$storageAccountName,
          [string][Parameter(Mandatory=$true)]$containerName,
          [string][Parameter(Mandatory=$true)]$containerSasToken,
		  [string]$blobStorageEndpoint,
          [string][Parameter(Mandatory=$true)]$targetPath,
          [string][Parameter(Mandatory=$true)]$azCopyLocation,
          [object][Parameter(Mandatory=$true)]$azureVMResourcesProperties,
          [object][Parameter(Mandatory=$true)]$azureVMsCredentials,
          [string][Parameter(Mandatory=$true)]$cleanTargetBeforeCopy,
          [string]$communicationProtocol,
          [string]$skipCACheckOption,
          [string][Parameter(Mandatory=$true)]$enableDetailedLoggingString,
          [string]$additionalArguments,
          [string][Parameter(Mandatory=$true)]$connectionType)

    [hashtable]$Jobs = @{}
    $dtlsdkErrors = @()
    $deploymentUtilitiesLocation = Get-DeploymentModulePath
    foreach ($resource in $azureVMResourcesProperties.Keys)
    {
        $resourceProperties = $azureVMResourcesProperties[$resource]
        $resourceFQDN = $resourceProperties.fqdn
        $resourceName = $resourceProperties.Name
        $resourceWinRMHttpsPort = $resourceProperties.winRMHttpsPort

        Write-Output (Get-VstsLocString -Key "AFC_CopyStarted" -ArgumentList $resourceName)

        $job = Start-Job -ScriptBlock $AzureFileCopyJob -ArgumentList `
                   $deploymentutilitieslocation, $resourceFQDN, $storageAccountName, $containerName, $containerSasToken, $blobStorageEndpoint, $azCopyLocation, $targetPath, $azureVmsCredentials, `
                   $cleanTargetBeforeCopy, $resourceWinRMHttpsPort, $communicationProtocol, $skipCACheckOption, $enableDetailedLoggingString, $additionalArguments

        $Jobs.Add($job.Id, $resourceProperties)
    }

    While ($Jobs.Count -gt 0)
    {
        Start-Sleep 10
        foreach ($job in Get-Job)
        {
            if ($Jobs.ContainsKey($job.Id) -and $job.State -ne "Running")
            {
                $output = Receive-Job -Id $job.Id
                Remove-Job $Job

                $status = $output.Status
                $resourceName = $Jobs.Item($job.Id).Name

                Write-ResponseLogs -operationName 'AzureFileCopy' -fqdn $resourceName -deploymentResponse $output
                Write-Output (Get-VstsLocString -Key "AFC_CopyCompleted" -ArgumentList $resourceName, $status)
                Publish-Azure-Telemetry -deploymentResponse $output -jobId $jobId
                if ($status -ne "Passed")
                {
                    $parallelOperationStatus = "Failed"
                    $errorMessage = ""
                    if($output.Error -ne $null)
                    {
                        $winrmHelpMsg = Get-VstsLocString -Key "AFC_WinRMHelpMessage"
                        $errorMessage = $output.Error.Message
                        if($connectionType -eq 'ServicePrincipal')
                        {
                            $errorMessage = $errorMessage + $winrmHelpMsg
                        }
                    }
                    $dtlsdkErrors += $output.DeploymentSummary

                    Write-Output (Get-VstsLocString -Key "AFC_CopyFailed" -ArgumentList $resourceName, $errorMessage)
                }
                $Jobs.Remove($job.Id)
            }
        }
    }

    # While copying parallelly, if copy failed on one or more azure VMs then throw
    if ($parallelOperationStatus -eq "Failed")
    {
        foreach ($error in $dtlsdkErrors) {
            Write-Telemetry "DTLSDK_Error" $error
        }
        $errorMessage = (Get-VstsLocString -Key "AFC_ParallelCopyFailed")
        ThrowError -errorMessage $errorMessage
    }
}

function Copy-FilesToAzureVMsFromStorageContainer
{
    param([string][Parameter(Mandatory=$true)]$storageAccountName,
          [string][Parameter(Mandatory=$true)]$containerName,
          [string][Parameter(Mandatory=$true)]$containerSasToken,
		  [string]$blobStorageEndpoint,
          [string][Parameter(Mandatory=$true)]$targetPath,
          [string][Parameter(Mandatory=$true)]$azCopyLocation,
          [string][Parameter(Mandatory=$true)]$resourceGroupName,
          [object][Parameter(Mandatory=$true)]$azureVMResourcesProperties,
          [object][Parameter(Mandatory=$true)]$azureVMsCredentials,
          [string][Parameter(Mandatory=$true)]$cleanTargetBeforeCopy,
          [string]$communicationProtocol,
          [string]$skipCACheckOption,
          [string][Parameter(Mandatory=$true)]$enableDetailedLoggingString,
          [string]$additionalArguments,
          [string][Parameter(Mandatory=$true)]$copyFilesInParallel,
          [string][Parameter(Mandatory=$true)]$connectionType)

    # copies files sequentially
    if ($copyFilesInParallel -eq "false" -or ( $azureVMResourcesProperties.Count -eq 1 ))
    {

        Copy-FilesSequentiallyToAzureVMs `
                -storageAccountName $storageAccountName -containerName $containerName -containerSasToken $containerSasToken `
                -blobStorageEndpoint $blobStorageEndpoint -targetPath $targetPath -azCopyLocation $azCopyLocation `
                -azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials `
                -cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $communicationProtocol -skipCACheckOption $skipCACheckOption `
                -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType
    }
    # copies files parallelly
    else
    {
        Copy-FilesParallellyToAzureVMs `
                -storageAccountName $storageAccountName -containerName $containerName -containerSasToken $containerSasToken `
                -blobStorageEndpoint $blobStorageEndpoint -targetPath $targetPath -azCopyLocation $azCopyLocation `
                -azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials `
                -cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $communicationProtocol -skipCACheckOption $skipCACheckOption `
                -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType
    }

    # if no error thrown, copy successfully succeeded
    Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $resourceGroupName)
}

function Validate-CustomScriptExecutionStatus
{
    param([string]$resourceGroupName,
          [string]$vmName,
          [string]$extensionName,
          [object]$endpoint)

    Write-Verbose "Validating the winrm configuration custom script extension status"

    $isScriptExecutionPassed = $true
    try
    {
        $status = Get-AzureMachineStatus -resourceGroupName $resourceGroupName -Name $vmName

        # For AzurePS < 1.0.4 $_.ExtensionType is applicable.
        $customScriptExtension = $status.Extensions | Where-Object { ($_.ExtensionType -eq "Microsoft.Compute.CustomScriptExtension" -or $_.Type -eq "Microsoft.Compute.CustomScriptExtension") -and $_.Name -eq $extensionName }

        if($customScriptExtension)
        {
            $subStatuses = $customScriptExtension.SubStatuses
            $subStatusesStr = $subStatuses | Out-String

            Write-Verbose "Custom script extension execution statuses: $subStatusesStr"

            if($subStatuses)
            {
                foreach($subStatus in $subStatuses)
                {
                    if($subStatus.Code.Contains("ComponentStatus/StdErr") -and (-not [string]::IsNullOrEmpty($subStatus.Message)))
                    {
                        $isScriptExecutionPassed = $false
                        $errMessage = $subStatus.Message
                        break
                    }
                }
            }
            else
            {
                $isScriptExecutionPassed = $false
                $errMessage = "No execution status exists for the custom script extension '$extensionName'"
            }
        }
        else
        {
            $isScriptExecutionPassed = $false
            $errMessage = "No custom script extension '$extensionName' exists"
        }
    }
    catch
    {
        $isScriptExecutionPassed = $false
        $errMessage = $_.Exception.Message
    }

    if(-not $isScriptExecutionPassed)
    {
        $response = Remove-AzureMachineCustomScriptExtension -resourceGroupName $resourceGroupName -vmName $vmName -name $extensionName -endpoint $endpoint
        throw (Get-VstsLocString -Key "AFC_SetCustomScriptExtensionFailed" -ArgumentList $extensionName, $vmName, $errMessage)
    }

    Write-Verbose "Validated the script execution successfully"
}

function Is-WinRMCustomScriptExtensionExists
{
    param([string]$resourceGroupName,
          [string]$vmName,
          [string]$extensionName,
          [string]$connectedServiceName)

    $isExtensionExists = $true
    $removeExtension = $false

    try
    {
        $serviceEndpoint=Get-Endpoint $connectedServiceName
        $customScriptExtension = Get-AzureMachineCustomScriptExtension -resourceGroupName $resourceGroupName -vmName $vmName -name $extensionName -endpoint $serviceEndpoint

        if($customScriptExtension)
        {
            if($customScriptExtension.ProvisioningState -ne "Succeeded")
            {
                $removeExtension = $true
            }
            else
            {
                try
                {
                    Validate-CustomScriptExecutionStatus -resourceGroupName $resourceGroupName -vmName $vmName -extensionName $extensionName -endpoint $serviceEndpoint
                }
                catch
                {
                    $isExtensionExists = $false
                }
            }
        }
        else
        {
            $isExtensionExists = $false
        }
    }
    catch
    {
        $isExtensionExists = $false
    }

    if($removeExtension)
    {
        $response = Remove-AzureMachineCustomScriptExtension -resourceGroupName $resourceGroupName -vmName $vmName -name $extensionName -endpoint $serviceEndpoint
        $isExtensionExists = $false
    }

    $isExtensionExists
}

function Get-TargetUriFromFwdLink {
    param(
        [string]$fwdLink
    )
    Write-Verbose "Trying to get the target uri from the fwdLink: $fwdLink"
    $proxy = Get-VstsWebProxy
    Add-Type -AssemblyName System.Net.Http
    $validHttpRedirectCodes = @(
        [System.Net.HttpStatusCode]::Moved,
        [System.Net.HttpStatusCode]::MovedPermanently,
        [System.Net.HttpStatusCode]::Found,
        [System.Net.HttpStatusCode]::Redirect,
        [System.Net.HttpStatusCode]::RedirectKeepVerb,
        [System.Net.HttpStatusCode]::TemporaryRedirect
    )
    $HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
    $HttpClientHandler.Proxy = $proxy
    $HttpClientHandler.AllowAutoRedirect = $false
    $HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
    $response = $HttpClient.GetAsync($fwdLink)
    $response.Wait()
    if($validHttpRedirectCodes.IndexOf($response.Result.StatusCode) -eq -1) {
        Write-Verbose "The http response code: $([int]$response.Result.StatusCode) is not a valid redirect response code."
        throw (Get-VstsLocString -Key "AFC_RedirectResponseInvalidStatusCode" -ArgumentList $([int]$response.Result.StatusCode))
    }
    $targetUri =  $response.Result.Headers.Location.AbsoluteUri
    if([string]::IsNullOrEmpty($targetUri)) {
        Write-Verbose "The target uri is null"
        throw (Get-VstsLocString -Key "AFC_RedirectResponseLocationHeaderIsNull")
    }
    Write-Verbose "The target uri is: $targetUri"
    return $targetUri
}

function Add-WinRMHttpsNetworkSecurityRuleConfig
{
    param([string]$resourceGroupName,
          [string]$vmId,
          [string]$ruleName,
          [string]$rulePriotity,
          [string]$winrmHttpsPort)

    Write-Verbose "Trying to add a network security group rule"

    try
    {
        $securityGroups = Get-NetworkSecurityGroups -resourceGroupName $resourceGroupName -vmId $vmId

        if($securityGroups.Count -gt 0)
        {
            Add-NetworkSecurityRuleConfig -resourceGroupName $resourceGroupName -securityGroups $securityGroups -ruleName $ruleName -rulePriotity $rulePriotity -winrmHttpsPort $winrmHttpsPort
        }
    }
    catch
    {
        Write-Telemetry "Task_InternalError" "NetworkSecurityRuleConfigFailed"
        Write-Warning (Get-VstsLocString -Key "AFC_AddNetworkSecurityRuleFailed" -ArgumentList $_.exception.message)
    }
}

function Add-AzureVMCustomScriptExtension
{
    param([string]$resourceGroupName,
          [string]$vmId,
          [string]$vmName,
          [string]$dnsName,
          [string]$location,
          [string]$connectedServiceName)

    $configWinRMScriptFileFwdLink ="https://aka.ms/vstsconfigurewinrm"
    $makeCertFileFwdLink ="https://aka.ms/vstsmakecertexe"
    $scriptToRun="ConfigureWinRM.ps1"
    $extensionName="WinRMCustomScriptExtension"
    $ruleName = "VSO-Custom-WinRM-Https-Port"
    $rulePriotity="3986"
    $winrmHttpsPort = "5986"

    Write-Verbose "Adding custom script extension '$extensionName' for virtual machine '$vmName'"
    Write-Verbose "VM Location : $location"
    Write-Verbose "VM DNS : $dnsName"

    try
    {
        $endpoint = Get-Endpoint $connectedServiceName
        $isExtensionExists = Is-WinRMCustomScriptExtensionExists -resourceGroupName $resourceGroupName -vmName $vmName -extensionName $extensionName -connectedServiceName $connectedServiceName
        Write-Verbose -Verbose "IsExtensionExists: $isExtensionExists"

        if($isExtensionExists)
        {
            Add-WinRMHttpsNetworkSecurityRuleConfig -resourceGroupName $resourceGroupName -vmId $vmId -ruleName $ruleName -rulePriotity $rulePriotity -winrmHttpsPort $winrmHttpsPort

            Write-Verbose "Skipping the addition of custom script extension '$extensionName' as it already exists"
            return
        }

        $configWinRMScriptFile = Get-TargetUriFromFwdLink -fwdLink $configWinRMScriptFileFwdLink
        $makeCertFile = Get-TargetUriFromFwdLink -fwdLink $makeCertFileFwdLink

        $result = Set-AzureMachineCustomScriptExtension -resourceGroupName $resourceGroupName -vmName $vmName -name $extensionName -fileUri $configWinRMScriptFile, $makeCertFile  -run $scriptToRun -argument $dnsName -location $location
        $resultDetails = $result | ConvertTo-Json
        Write-Verbose "Set-AzureMachineCustomScriptExtension completed with response : $resultDetails"

        if($result.Status -ne "Succeeded")
        {
            Write-Telemetry "Task_InternalError" "ProvisionVmCustomScriptFailed"

            $response = Remove-AzureMachineCustomScriptExtension -resourceGroupName $resourceGroupName -vmName $vmName -name $extensionName -endpoint $endpoint
            throw (Get-VstsLocString -Key "AFC_UnableToSetCustomScriptExtension" -ArgumentList $extensionName, $vmName, $result.Error.Message)
        }

        Validate-CustomScriptExecutionStatus -resourceGroupName $resourceGroupName -vmName $vmName -extensionName $extensionName -endpoint $endpoint
        Add-WinRMHttpsNetworkSecurityRuleConfig -resourceGroupName $resourceGroupName -vmId $vmId -ruleName $ruleName -rulePriotity $rulePriotity -winrmHttpsPort $winrmHttpsPort
    }
    catch
    {
         Write-Telemetry "Task_InternalError" "ExecutionOfVmCustomScriptFailed"
         throw (Get-VstsLocString -Key "AFC_CopyPrereqsFailed" -ArgumentList $_.exception.message)
    }

    Write-Verbose "Successfully added the custom script extension '$extensionName' for virtual machine '$vmName'"
}

function Check-ContainerNameAndArgs
{
    param([string]$containerName,
          [string]$additionalArguments)

    $additionalArguments = ' ' + $additionalArguments + ' '
    if($containerName -eq '$root' -and $additionalArguments -like '* /S *')
    {
        Write-Warning (Get-vstsLocString -Key "AFC_RootContainerAndDirectory")
    }
}


This program is an interactive and fun time of Bible study geared toward kids of all ages. This program is high-energy and Bible-based teaching.
All ages are invited to participate in a time of fun and learning. These classes are split into age-appropriate groups for maximized learning potential. Our teachers are experienced at helping young people to learn the truths of God's Word and application of them into their lives.
This program is for all kids K-6th grade who have attended at least one of our Bible classes during the week. We have crafts, outside activities, and homework help. We also offer a snack.


text:
Fennagh, local name Fenagh () is a village in County Carlow, Ireland. It lies on the R724 regional road between Bagenalstown (Muine Bheag) and Myshall.

Amenities
Fenagh village contains two public houses, The Hunter's Rest or "Joe's" and Kearney's, two shops, The Black Cat and Kearney's, a church, a community hall, and a creche.

Sport
The local Gaelic football club, Fenagh GAA (Fiodhnach CLG in Irish) has teams from under 8s up to Senior level. The club, nicknamed the "Moll Bennetts", has won three Carlow Intermediate Football Championships and plays at J.J. Hogan Memorial Park.

People
Richie Kavanagh - entertainer

See also
 List of towns and villages in Ireland

References

Towns and villages in County Carlow

redpajama_set_name: RedPajamaWikipedia


Final Concept Video for the Plear App.
Plear is the product of a start-up company. Rafael Schneider and my part was the concept developement and the design of the user experience for the mobile application and the platform.


text:
EU and GB approval changes – October-December 2022
Posted by: Zuzana Majeska
Category: ACP EN, News
EU and GB approval changes Following the UK departure from the EU, COLEACP's Regulation Monitoring now covers both EU and GB approval changes, enabling us to keep COLEACP members and partner-beneficiaries up-to-date on both regulatory frameworks.The European Commission (EC) has recently published changes to plant protection product (PPP) approvals within the European Union (EU). These include: Renewal of approval of Fish oil and Heptamaloxyloglucan as low-risk active substances Renewal of approval of active substance Pythium oligandrum strain M1 Notification to… +
EU and GB MRL changes in 2022 – July – September 2022
Posted by: Mohamed Ndiaye
Changes to EU and GB pesticide maximum residue levels Following the departure of the United Kingdom from the European Union (EU), COLEACP's monitoring of pesticide regulations now covers MRL changes in both the EU and Great Britan (GB), enabling us to keep COLEACP members and partner-beneficiaries up-to-date. Note that EU MRLs still apply in Northern Ireland (GB covers only England, Scotland and Wales). During the period July-September 2022, we have been highlighting significant changes to EU MRLs that affect 50… +
Update on EU MRL changes – April 2022
Changes to EU pesticide maximum residue levels Since the start of 2022, we have been highlighting significant changes to EU MRLs that affect 23 active substances, 9 of which are important for ACP export horticulture. The European Commission has also recently notified the World Trade Organization (WTO) of some additional proposed changes involving a further 5 substances, including 1 that is key for ACP horticulture (hexythiazox). How will ACP producers/exporters be affected? Changes to EU Maximum Residue Limits (MRLs) also… +
Update on EU MRL changes
Category: Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, Argentina, Armenia, Aruba, Australia, Austria, Azerbaijan, Bahamas, Bangladesh, Barbados, Belarus, Belgium, Belize, Benin, Bermuda, Bhutan, Bolivia, Bosnia and Herzegovina, Botswana, Brazil, Bulgaria, Burkina Faso, Burundi, Cambodia, Cameroon, Canada, Cape Verde, Central African Republic, Chad, Chile, China, Colombia, Comoros, Cook Islands, Costa Rica, Côte d'Ivoire, Croatia, Cuba, Cyprus, Czech Republic, Democratic Republic Of The Congo, Denmark, Djibouti, Dominica, Dominican Republic, Ecuador, Egypt, El Salvador, Equatorial Guinea, Eritrea, Estonia, Eswatini, Ethiopia, Faroe Islands, Federated States of Micronesia, Fiji, Finland, France, French Guiana, French Polynesia, Gabon, Gambia, Georgia, Germany, Ghana, Greece, Greenland, Grenada, Guadeloupe, Guam, Guatemala, Guinea, Guinea-Bissau, Guyana, Haiti, Headline, Honduras, Hong Kong, Hungary, Iceland, India, Indonesia, Iran, Iraq, Ireland, Israel, Italy, Jamaica, Japan, Jordan, Kazakhstan, Kenya, Kiribati, Kuwait, Kyrgyzstan, Latvia, Lebanon, Lesotho, Liberia, Liechtenstein, Lithuania, Luxembourg, Macao, Madagascar, Malawi, Malaysia, Maldives, Mali, Malta, Marshall Islands, Martinique, Mauritania, Mauritius, Mayotte, Mexico, Monaco, Mongolia, Montserrat, Morocco, Mozambique, Myanmar, Namibia, Nauru, Nepal, Netherlands, New Caledonia, New Zealand, News, Nicaragua, Niger, Nigeria, Niue, Northern Mariana Islands, Norway, Oman, Pakistan, Palau, Panama, Papua New Guinea, Paraguay, Peru, Philippines, Poland, Portugal, Puerto Rico, Qatar, Republic of Korea, Republic of the Congo, Réunion, Romania, Russian Federation, Rwanda, Saint Helena, Saint Kitts and Nevis, Saint Lucia, Saint Vincent and the Grenadines, Samoa, San Marino, Sao Tome and Principe, Saudi Arabia, Senegal, Serbia and Montenegro, Seychelles, Sierra Leone, Singapore, Slovakia, Slovenia, Solomon Islands, Somalia, South Africa, Spain, Sri Lanka, Sudan, Suriname, Sweden, Switzerland, Syria, Taiwan, Tajikistan, Tanzania, Thailand, Timor-Leste, Togo, Tokelau, Tonga, Trinidad and Tobago, Tunisia, Turkey, Turkmenistan, Tuvalu, Uganda, Ukraine, United Arab Emirates, United Kingdom, United States, Uruguay, Uzbekistan, Vanuatu, Venezuela, Vietnam, Yemen, Zambia, Zimbabwe
Key points Since our latest news in December 2021, we are highlighting some significant changes affecting five active substances (acequinocyl, Bacillus subtilis strain IAB/BS03, emamectin, flutolanil, and imazamox) used in crop protection (Reg. (EU) 2021/2202). In particular, emamectin is important and widely used in ACP horticulture. The latest changes involve an increase in MRLs for peaches and kiwi fruits. The new Maximum Residue Limit (MRL) for peaches is 0.15 mg/kg (previously 0.03 mg/kg) and for kiwis the new MRL is… +
Category: Africa, Angola, Antigua and Barbuda, Australia, Bahamas, Barbados, Belgium, Belize, Benin, Botswana, Burkina Faso, Burundi, Cameroon, Cape Verde, Caribbean, Central African Republic, Chad, Comoros, Cook Islands, Côte d'Ivoire, Country, Democratic Republic Of The Congo, Djibouti, Dominica, Dominican Republic, Equatorial Guinea, Eritrea, Eswatini, Ethiopia, Faroe Islands, Federated States of Micronesia, Fiji, France, Gabon, Gambia, Germany, Ghana, Greece, Grenada, Guinea, Guinea-Bissau, Guyana, Haiti, Hungary, Ireland, Italy, Jamaica, Kenya, Kiribati, Liberia, Luxembourg, Madagascar, Malawi, Mali, Marshall Islands, Mauritania, Mauritius, Mozambique, Namibia, Nauru, Netherlands, News, Niger, Nigeria, Niue, Pacific, Papua New Guinea, Poland, Portugal, Republic of the Congo, Rwanda, Saint Kitts and Nevis, Saint Lucia, Saint Vincent and the Grenadines, Samoa, Sao Tome and Principe, Senegal, Seychelles, Sierra Leone, Solomon Islands, Somalia, Spain, Suriname, Tanzania, Timor-Leste, Togo, Tonga, Trinidad and Tobago, Tuvalu, Uganda, Vanuatu, Zambia, Zimbabwe
Key points Since the start of 2021, European Union (EU) maximum residue level (MRL) changes concerned 83 plant protection products (PPPs; 59 in 2020). These changes refer to modifications compared to the previous regulation, and can be either an increase or lowering of the MRLs for certain foods.COLEACP identified 27 key substances used in African, Caribbean and Pacific (ACP) horticulture that are affected by these changes. For 10 of the substances (ametoctradin, bupirimate, chlorothalonil, dimethoate, ethoprophos, myclobutanil, propiconazole, pyraclostrobin spinetoram,… +

redpajama_set_name: RedPajamaCommonCrawl


text:
package eu.monnetproject.kap.laif;

import eu.monnetproject.lang.Language;
import java.net.URI;
import java.util.Set;

/**
 *
 * @author John McCrae
 */
public interface LAIFController {

    LAIFLocalizationLexicon getLexicon(String appKey);

    void updateRules(String appKey, Language lang, LAIFRuleSet rules);

    Set<URI> getLexicaURIs(String appKey);

    @Deprecated
    Set<URI> getForms(String appKey, URI lexicaURI);
}

redpajama_set_name: RedPajamaGithub


Top 40 Hits • Pop Rock • Classic Ballads • 80's Hits • 70's Rock • Funk • Pop Latin • Pop Disco • Pop Jazz • Alternative • New Country • Classical Favorites …and of course, Your Personal Requests!
It's been said that variety is the spice of life; which is undoubtedly something you'll discover in VANITY FAIR, given the diverse artists available to entertain you. These talented and energetic musicians are just one of the reasons that you'll want VANITY FAIR to be the band for your most important event. Simply select from our variety of music, an ever-growing repertoire, covering every genre of the best Hits of the past to the present as originally performed by the established artists you hear on your iPod or radio.
Clearly, you and your guests will have the time of your lives with VANITY FAIR as your band. But, then again, who on earth could resist gettin' their party on with VANITY FAIR – The Band as your Best choice for Live Music entertainment at your upcoming Gala Wedding, Corporate Event or VIP Private Party!


Liverpool reside after last week's Premier League matchday on the first place, having a two points advantage over Chelsea and four over City. Provided they manage to do well in all their remaining fixtures, the bookies do give them a solid chance of winning. Both Brendan Rodgers and the Liverpool fans want to win this title for their captain and hope to do so before he retires.
Liverpool have a winning streak of eight consecutive matches, have been undefeated in their last 11 and managed to score at least three goals in all of them. Their latest result is a 4-0 win over Tottenham, and it is wonderful to observe this team that last year was falling apart on all accounts. Their killer duo is on the first place in Premier League, so betting on goals and clean sheets is where it would be wiser to back.
West Ham are on the 11th place in the table, have 37 points and have been defeated in 15 matches this season. Andy Carroll is the name where tipsters head to when betting on the goals for West Ham, as he is one of those who can put Liverpool's title hopes to rest. They were also sporting three consecutive defeats before managing to win against Hull City and Sunderland.
Everybody expect something from Liverpool, and they have to keep capitalizing on their current form and win this. Among the most popular betting markets is the goals one: Liverpool to score in both halves is at 1.82 with Betfair, an outright Liverpool win is at 1.39, West Ham at 7.95 and a draw at 4.90. Luis Suarez as the first goalscorer is at 3.40, Daniel Sturridge at 4.20 and Coutinho at 8.50. We are going to bet 8 units on over 3.5 goals per match at 2.13 with Betfair.


In the foreground, we see Jim Caviezel (Jesus Christ), covered in blood. This contrasts to the very grey and almost boring background and makes the character stand out and appear to be of great importance. This shows that the character is important and also suggests that there is great conflict and differences between the character and the "norm" as even the colours don't mix.
The emptiness of the shot shows how isolated the character may have felt at the time.
The use of the colour red in the form of blood on the character illustrates the harsh treatment of the character and also suggests how powerful this character is as red is associated with power and war.
The use of chiaroscuros techniques shows how pure the character is as the rest of the shot is greyed out and only the character is in colour/ the light. This shows how morally correct the character is despite the harsh environment that he is in.
The audience's expectations of a historical drama is gratified through the use of costumes and props synonymous with the story of the crucifixion of Jesus Christ in the Bible.
The use of juxtaposition between the grey, bland cloudy background and the vibrant red character makes the audience focus more on the character and try and imagine what they felt like, a level of focus with the characters that dramas love to achieve.
There is much empty space in the shot, this creates a sense of loneliness and allows the audience to feel immersed in the scene as it gives a insightful look into the time with the slightly low angle shot.
The key themes of the film are the battle, both mental and physical, between the character and the rest of the world as this weak looking character is being brutally punished. This suggests that this character must be very strong or influential due to the fact that he has been treated in this barbaric manner.
The audience may empathise for the character as he is being brutally punished; the contrast in colour makes the red blood stand out. This makes the audience wonder why the character is being treated like this and whether or not he truly deserves it.
The audience may also be questioning as they are not able to tell is the character is dead or alive, this may make the audience worried or intrigued.


Will Human Dreams of Immortality Come True Through Jellyfish Research? Biological and life science studies of immortal and ephemeral jellyfishes.
After the publication of a paper announcing the first ever achievement of ten consecutive rejuvenations of the Jellyfish species Turritopsis spp. in laboratory conditions, various subsequent biological studies were carried out. These included further successful records of rejuvenation, as well as a public exhibition of the jellyfish at Kyoto University's Shirahama Aquarium. It is anticipated that the jellyfish's ability to rejuvenate will be further explored, mainly through genetic and molecular approaches, and that in the future, the results of those studies could be applied to make the long-held human dream of rejuvenation a possibility. In contrast, a special research project is being undertaken for genetic and molecular studies on the parallel evolution of a very short-lived species of jellyfish, the bivalve-inhabiting hydrozoan Eugymnanthea japonica Kubota, found in the Pacific and Atlantic Oceans. If life science studies comparing these two tiny jellyfish could provide the key to human immortality, it would be the greatest revolution in the evolutionary history of the Earth, heralding a complete, and highly beneficial, change in our way of life and social communities.


Book Function Rooms in Melbourne at The Terminus Hotel! We are offering beautiful and spacious function venues for wide range of party celebrations. Be it a Christmas party, engagement party, cocktail function or a wedding reception, we can help you to organize every party with lavishness. Visit us at The Terminus Hotel and have fun!! For more information call us on: 0394270615 or send us on: Info@theterminushotel.com.au.


Four people including two children were taken to hospital after a fire at a flat in Fishponds Road last night.
Firefighters arrived to find found a man and woman in their 20s, and two young children already outside. The man was suffering from burns to his hand and all four were given oxygen after breathing in smoke.
They were all taken to hospital as a precaution.
Two firefighters wearing breathing apparatus entered the flat and extinguished a fire in a bedroom.
It is believed the blaze started after a tumble drier overheated. The room was damaged by fire and smoke.


to be only an outpost.
brought from; and the savage "not interested in going."
had disappeared below the north-west horizon.
balls of cotton, and sending him away again.
will give them of everything which they have."
must do our best to sympathise.
if there had been any, I could not have missed seeing some."
enchanted world to which he had come.
of parrots obscure the sun."
Diego had been appointed a page.
making them presents of beads and toys for which he would take no return.
along towards the west he entered the river which he called Rio de Mares.
Cathay. Columbus for once found himself in agreement with Martin Alonso.
in the Rio de Mares.
when they caught a man they beheaded him and drank his blood" . . .
inland to the great and rich city came back again with their report.
received with great solemnity; and all the men "as well as the women"
"No, but they thought there was a great deal of it to the south-east."
the first known discovery of tobacco by Europeans.
they saw potatoes also, although they did not know what they were.
sand with candles at night, and afterwards made bars of it with a hammer.
Admiral's facility in interpreting signs in favour of his own beliefs.
they did continually, greatly to the edification of the crew.
children kidnapped, came and offered to go with them of his own accord.
for which he would have been sure to punish them.
to me if he wished." But he did not wish, and he did not come.
to come if he wishes; but Martin Alonso has wishes quite other than that.
the Admiral called Santa Catalina, and which is now called Cayo de Moa.
woods; and so he remained instead, beating about in the open sea.
that he christens it Espanola.
to be round the next headland or, at the farthest, in the next island.
be taught to wear clothing and observe our customs."
clothing and observe our customs.
been before; and some of the sailors went fishing with the natives.
did, made him shake his head when this piece of news was brought to him.
Our Lord was about to show him where the gold originates."
of his visit is preserved in Columbus's own words.
him, and with great respect.
and making them presents and behaving very graciously and kindly to them.
say that they know it."
coast with a light land breeze, he decided to lie down to get some sleep.
direction of the Nina, which was lying a mile and a half to windward.
no use, for the ship's seams had opened and she was filling.
has for so long been his shelter and sanctuary.
greedy for gold, he had a pious purpose for its employment.
scarlet cloak and a silver ring.
bad example to the Indians and show the infamy of the Christians."
Allard and William in the sunshine and silence of Espanola.
some verdant headland come upon the mines and jewels that he longed for.
not) an ingratiating smile upon his face he comes up over the side.
was inhabited only by women.
Admiral releasing them immediately and sending them back to their homes.
cutlass they took to flight and escaped from the anger of the Spaniards.
miles a day in a direction between north-by-east and north-north-east.
land is seen, it will be known who has calculated the surest."
sea, which the crew took to be some pious act of sacrifice or devotion.
lived through the tempest that had been raging for the last fortnight.
so much more accurate than that of the pilots.
and asked the Portuguese messenger to send a priest to say Mass for them.
caravel back to the harbour by command of the Governor of the island.
"as the weather and wind were very unfavourable for anything else."
were of little use in a tempest but to draw lots and vow pilgrimages.
and the anchor and cables he had lost there.
temperate place, would believe anything.
from the Indies, and not from any of the forbidden regions of Guinea.
The next day brought a visit from no less a person than Bartholomew Diaz.
privilege which should be accorded to each.
the royal flag displayed, without molestation.
there or any large city.
as fresh and flourishing as those of Spain in the month of May.
states, according to their nature.
various other trees, fruits, and herbs. The pines of this island .
there are many spices, and large mines of gold and other metals.
and of which there is abundance in their country.
with sixty or eighty men in them, and each with a paddle.
which they are very well disposed.
they keeping order among themselves.
and of this and the others I have Indians with me to witness.
hearsay than by anything else.
becoming Christians, and which last may shortly be accomplished.
bad weather that I have been detained beating about in this sea.
was, and where he was received with great honour.
tide and dropped his anchor again in the mud of the river by Palos.
island infinitely far over the western horizon.
familiar music under her bowsprit.
storm, now has made her native port on the very same day as the Nina.
for not waiting for his commander and forbidding him to come to Court.
reported some of Martin's doings to them.
undisturbed by any more accusations or reproaches.


Stylage S Lidocaine is specifically designed to improve the appearance of superficial lines in the superficial to mid-dermis. Use Stylage S Lidocaine for correction of fine lines and superficial wrinkles (crow's feet, glabellar frown lines, perioral lines) and tear trough area treatment under the eye. Contains lidocaine, a powerful anaesthetic for comfort injection.
STYLAGE S lidocaine 0.8 ml is used for filling and smoothing fine lines and wrinkles. It is completely biogradable and of non-animal origin. It has been specifically designed for the correction of superficial lines and wrinkels. Contains 0.3% lidocaine which is an anesthetic, allowing more comfortable treatments.STYLAGE S is the first monophasic antioxidant cross-linked hyaluronic acid based gel sterile, completely biogradable, of non-animal origin, specifically designed for the natural correction of superficial lines and wrinkels.


text:
HomeLynk & Co01NewsSpy photos
Lynk & Co 01 Coupe crossover spied testing in Germany
Lynk & Co 01 Coupe crossover spied testing in Germany product 2019-03-27 18:40:00 https://uk.motor1.com/news/315626/lynk-co-coupe-crossover-spied/ Lynk & Co 01 Spy photos
By: Christopher Smith
There's still quite a bit we don't know about this new model.
Chinese automaker Lynk & Co appears ready and willing to step beyond its home market in more ways than one. This is the second time we've seen the company's slope-roofed SUV testing, and spy photographers caught up with this one in Germany. It bears a resemblance to Lynk & Co's existing 01 full-size SUV, and with much of the heavy camo pulled away, it's very easy to see this prototype's coupe-crossover shape.
More SUV news from Lynk & Co:
Seven-seat Lynk & Co 01 spied stretching out in the snow
European Lynk & Co SUVs will be hybrid and built in Belgium
Our sources don't have much information on this vehicle other than it's likely a crossover version of the 01 SUV. The heavier camo coverings on the front still reveal many similarities to the people mover, and the big side-view mirrors scream 01 as well. Moving further back we see a curious resemblance to the Mercedes-Benz GLC Coupe, though the camo wrap conceals any potential side glass that could mimic the Merc's profile.
Gallery: Lynk & Co Coupe crossover spy photos
Lynk & Co certainly isn't letting any grass grow in its development and testing group. In addition to this model, we recently caught a seven-passenger version of the 01 SUV testing. The production 01 utilises Volvo's compact modular Architecture platform, and if these machines are indeed variants of that SUV, there should be Swedish bones beneath the camouflage.
For that matter, this fastback crossover could also have ties to Lotus. Almost a year ago to the day, former Lotus CEO Jean-Marc Gales said the company was planning a Volvo-based SUV. Lotus is owned by Chinese group Geely, which also owns Lynk & Co. Ah what a tangled web we weave.
In any case, Lynk & Co is definitely interested in selling vehicles outside of the Chinese market. It's 01 SUV is the fastest-selling vehicle in China, blowing through the automaker's 6,000 pre-sale units in just 26 minutes. Should the company hope to enter the U.S. arena it would make sense to have an arsenal of SUV offerings ready to cover the bases. A five-passenger 01 with a seven-passenger variant and coupe model would certainly fit such a plan.
Source: Automedia
Lynk & Co 01


size reduction equipment raw coal. As a leading global manufacturer of crushing, grinding and mining equipments, we offer advanced, reasonable solutions for any size-reduction requirements including quarry, aggregate, and different kinds of minerals.
size reduction equipment raw coal - diebold-bau.eu. size reduction equipment raw coal - csdpmapeu. size reduction equipment raw coal Rock Crusher Mill-Rock, size reduction equipment raw coal is a leading global manufacturer of crushing and milling equipment .
Size Reduction Equipment Raw Coal. size reduction coal processsize reduction collider mill. Raymond Mill; LM Vertical Grinding . size reduction coal process. size reduction equipment in coal industry . size reduction equipment raw coal SCM is a leading .
Gulin machine in iron ore processing plant, size reduction equipment raw coal. Gulin provide the size reduction equipment raw coal solution case for you.
size reduction equipment raw coal XSM is a leading global manufacturer of crushing and milling equipment (size reduction equipment raw coal),XSM also supply individual (size reduction equipment raw coal...) crushers and mills as well as spare parts of them.
Solid Particle Size Reduction Equipment | Quadro Mill ... Quadro Solids Division is a leader in technological engineering and manufacturing of products such as conical mills, process and size reduction equipment.
Size Reduction Equipment For Raw Coal. Eriez Products. The most popular Eriez products are now ready for fast shipment through the Eriez Quick Ship program. .


text:
About Team Proof BLOG Contact
AboutTeamProofBLOGContact
Consumer Control
Third-Party Data
Zero-Party Data
RETAIL DIVE: Which data sources should be driving personalization?
"Somewhat controversially, 37.7 percent of retailers indicated they are using third-party data for personalization, well above marketers in other sectors. The practice of using third-party data has drawn wide attention amid a sea of data breaches, with many calling for more transparency and regulations."
CHAIN STORE AGE: When does personalization become creepy?
"Despite these misgivings, 90% of consumers are willing to provide behavioral data for a better shopping experience. And 72% of respondents only engage with messages tailored to their interests, meaning almost three-quarters of consumers expect some level of behavioral tracking from marketers."
eMARKETER: Do People Actually Want Personalized Ads?
"Adlucent found that seven in 10 consumers yearn for personalized ads. IAB presentations state that consumers want fewer, but more personalized ads. Epsilon found that four-fifths of consumers are more likely to make purchases when a brand gives them a personalized experience."
TECH TARGET: Personalization Technology Can Both Help, Hurt CX Strategy
"Customers are looking for consent when dealing with personalized marketing. When customers initiate interactions and transfer data to your organization in order to market to them more effectively, then no problem. But no one likes to be blindsided by ads so well-targeted that they start to wonder whether a company is spying on them."
AD AGE: Facebook Fact-Checking Operation Faces New Setback
"According to reports, fact-checkers are also concerned the program can't keep up with the volume of misinformation. In October, The Wall Street Journal reported that some fact-checkers say they only handle one claim a day. The limited workload has led to claims that Facebook is not serious about purging disinformation."
AD AGE: A Guide to Apple's Disabling of Facebook's Consumer Research App
"On the other hand, it's hard to tell if Facebook adhered to the strictest standards of disclosure, and how well-informed participants were. And Facebook already has been under a microscope for privacy and data-sharing issues, most notably the Cambridge Analytica scandal. There have also been questions raised about how Facebook handled user privacy and data, especially in its early days."
WIRED: Hackers Are Passing Around Megaleak of 2.2 Billion Records
"But the leak is still significant for its quantity of privacy violation, if not its quality. WIRED asked Rouland to search for more than a dozen people's email addresses; all but a couple turned up at least one password they had used for an online service that had been hacked in recent years."
TIME: The Most Disturbing Thing About Facebook's Controversial Data Research Program
"But the most alarming element of Facebook's research program was its inherently exploitative nature. By offering as paltry a sum as $20 to see nearly everything we're doing on our smartphones, Facebook is, whether consciously or not, targeting the most desperate among us. Facebook users who make a comfortable wage are unlikely to see that deal as worth the trade-off.
FORTUNE: Google and Ad Industry Accused of "Massive" Abuse of Intimate Personal Data
"Last September, a coalition of privacy activists and browser-makers targeted Google and the advertising technology industry with complaints about "a massive and ongoing data breach that affects virtually every user on the web" — the broadcasting of people's personal data to dozens of companies, without proper security."
eMARKETER: A 10% Discount? Sure, What Do You Want to Know?
"Roughly seven in 10 internet users surveyed by Blis said that if Amazon offered them a discount, they would share their buying habits from a competitor, such as Target. Consumers may be willing to trade information about their shopping habits for a deal offered by a retailer or brand, but they're more wary of third-party deals."
NAKED SECURITY: Some Android apps are secretly sharing your data with Facebook
"Android apps have been secretly sharing usage data with Facebook, even when users are logged out of the social network – or don't have an account at all. The investigators found that 61% of the apps tested automatically tell Facebook that a user has opened them.
LINUX JOURNAL: If Your Privacy Is in the Hands of Others Alone, You Don't Have Any
"If you think regulations are going to protect your privacy, you're wrong. In fact they can make things worse, especially if they start with the assumption that your privacy is provided only by other parties, most of whom are incentivized to violate it."
AD AGE: 2019 Industry Predictions
"Attribution" will be the most overused phrase in TV advertising. In an effort to compete with the FAANG guys (Facebook, Apple, Amazon, Netflix and Google), TV sellers will aggressively try to prove that commercials drive specific business results, like test-driving a car, or the ultimate holy grail—making a purchase.
FINANCIAL TIMES: Data brokers: regulators try to rein in the 'privacy deathstars'
"Over the past five years, the data broker industry expanded aggressively in what amounted to a virtual regulatory vacuum. The rise of internet-connected devices has fuelled an enhanced industry of "cross-device tracking" that matches people's data collected from across their smartphones, tablets, televisions and other connected devices. It can also connect people's behaviours in the real world with what they are doing online."
FORTUNE: Beware Big Tech's Data Privacy Doublespeak
"Is it any wonder the world is undergoing a crisis of trust? Data privacy disclosures ought to be crystal clear. There should be no uncertainty about how one's data are being used or where they're flowing. During her talk in Brussels, [IBM CEO Ginni] Rometty told the audience that consumers "have very little power against the dominant internet platform companies." In the absence of informed consent, she's right."
LOS ANGELES TIMES: L.A. is suing IBM for illegally gathering and selling user data through its Weather Channel app
The suit cited an investigation by the New York Times last month that found at least 75 companies that collected precise location data via smartphone apps — in one case pinging a user's location 14,000 times in one day — then used it to fuel consumer insight research and the $21-billion location-based advertising industry.
WAYIN: Scott McNealy on the Zero-Party Data Economy
"Zero-party data is the next step in building genuine connections with consumers. It is data your customer has willingly shared with you, like purchase desires and preferences to improve personalization and help build up a more complete picture of who they are."
NEW YORK MAGAZINE: How Much of the Internet Is Fake? Turns Out, a Lot of It, Actually.
"Fake people with fake cookies and fake social-media accounts, fake-moving their fake cursors, fake-clicking on fake websites — the fraudsters had essentially created a simulacrum of the internet, where the only real things were the ads."
NEW YORK TIMES: Sharing Data for Deals? More Like Watching It Go With a Sigh
"The more we know about you, the argument goes, the more we can show you products you actually want instead of ads that just annoy you. Consumers, they say, are happily trading very specific information about their lives in order to receive this kind of personalized advertising and marketing — relevant ads, as the industry calls them."
WALL STREET JOURNAL: Advertisers' Top Trade Group Pushes for Federal Data Privacy Regulation
"Mr. Jaffe said reasonable practices might include the collection and use of many kinds of sales data, but not "sensitive" data that is protected under existing laws, such as those protecting children and personal health information. Reasonable practices also would provide consumers with transparency and choice around how their data can be used, according to the ANA's comments."
We respect your privacy and you can opt out at anytime.