title: Run Functional Tests - Unable to get teamfoundation Collection Uri
body: <p>I am getting the following error with the "Run Functional Tests" task during a RELEASE task.</p>
  
  <p>I am trying to run a unit test dll using the builtin VS .net test framework written in .Net 4.6.1 C# (VS2015.Update2)</p>
  
  <p>The reason for running the tests on a VM is for scenarios that don't work on the 
  Hosted Test agent</p>
  
  <p><strong>Scenario</strong></p>
  
  <p>Azure VM
  UnitTests dll</p>
  
  <p><strong>RELEASE Tasks</strong></p>
  
  <p>Visual Studio Test Agent Deployment (Success)</p>
  
  <p>Azure File Copy (Succes)</p>
  
  <p>Run Functional Tests (Fails)</p>
  
  <p><strong>LOG</strong></p>
  
  <pre><code>&gt; 2016-04-14T01:42:49.2222367Z Executing the powershell script:
  &gt; C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.97.1\tasks\RunVisualStudioTestsusingTestAgent\1.0.32\RunDistributedTests.ps1
  &gt; 2016-04-14T01:42:50.5719493Z ##[debug]Entering script
  &gt; RunDistributedTests.ps1 2016-04-14T01:42:50.5749473Z
  &gt; ##[debug]TestMachineGroup = xxxx.australiaeast.cloudapp.azure.com
  &gt; 2016-04-14T01:42:50.5759489Z ##[debug]Test Drop Location =
  &gt; C:\AcceptanceTests\SampleWebApiE2ERelease 2016-04-14T01:42:50.5759489Z
  &gt; ##[debug]Source Filter = bin\Release\AcceptanceTest.dll 2016-04-14T01:42:50.5769483Z ##[debug]Test Filter Criteria = 
  &gt; 2016-04-14T01:42:50.5779473Z ##[debug]RunSettings File =
  &gt; C:\a\2c16ad4c2\CI Build\drop\AcceptanceTest\AcceptanceTest.runsettings
  &gt; 2016-04-14T01:42:50.5779473Z ##[debug]Build Platform = 
  &gt; 2016-04-14T01:42:50.5789483Z ##[debug]Build Configuration = 
  &gt; 2016-04-14T01:42:50.5789483Z ##[debug]CodeCoverage Enabled = false
  &gt; 2016-04-14T01:42:50.5799482Z ##[debug]TestRun Parameters to override =
  &gt; 2016-04-14T01:42:50.5799482Z ##[debug]TestConfiguration = 
  &gt; 2016-04-14T01:42:50.5829484Z ##[debug]Application Under Test Machine
  &gt; Group =  2016-04-14T01:42:50.6079488Z ##[debug]Loading module from
  &gt; path
  &gt; 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.97.1\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.dll'.
  &gt; 2016-04-14T01:42:50.6479489Z ##[debug]Importing cmdlet
  &gt; 'Complete-Task'. 2016-04-14T01:42:50.6489487Z ##[debug]Importing
  &gt; cmdlet 'Get-LocalizedString'. 2016-04-14T01:42:50.6499484Z
  &gt; ##[debug]Importing cmdlet 'Set-TaskVariable'. 2016-04-14T01:42:50.6499484Z ##[debug]Importing cmdlet
  &gt; 'Set-TaskProgress'. 2016-04-14T01:42:50.6509481Z ##[debug]Importing
  &gt; cmdlet 'Add-TaskIssue'. 2016-04-14T01:42:50.6509481Z
  &gt; ##[debug]Importing cmdlet 'Write-TaskDetail'. 2016-04-14T01:42:50.6519486Z ##[debug]Importing cmdlet 'Find-Files'.
  &gt; 2016-04-14T01:42:50.6719494Z ##[debug]Loading module from path
  &gt; 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.97.1\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Internal\Microsoft.TeamFoundation.DistributedTask.Task.Internal.dll'.
  &gt; 2016-04-14T01:42:51.1184496Z ##[debug]Importing cmdlet
  &gt; 'Add-BuildAttachment'. 2016-04-14T01:42:51.1194518Z ##[debug]Importing
  &gt; cmdlet 'Convert-String'. 2016-04-14T01:42:51.1204518Z
  &gt; ##[debug]Importing cmdlet 'Get-IndexedSourceFilePaths'. 2016-04-14T01:42:51.1204518Z ##[debug]Importing cmdlet
  &gt; 'Get-JavaDevelopmentKitPath'. 2016-04-14T01:42:51.1214490Z
  &gt; ##[debug]Importing cmdlet 'Get-MSBuildLocation'. 2016-04-14T01:42:51.1214490Z ##[debug]Importing cmdlet
  &gt; 'Get-ServiceEndpoint'. 2016-04-14T01:42:51.1224478Z ##[debug]Importing
  &gt; cmdlet 'Get-TfsClientCredentials'. 2016-04-14T01:42:51.1224478Z
  &gt; ##[debug]Importing cmdlet 'Get-ToolPath'. 2016-04-14T01:42:51.1234489Z ##[debug]Importing cmdlet 'Get-TaskVariable'. 2016-04-14T01:42:51.1234489Z ##[debug]Importing cmdlet
  &gt; 'Get-VisualStudioPath'. 2016-04-14T01:42:51.1244823Z
  &gt; ##[debug]Importing cmdlet 'Get-VssConnection'. 2016-04-14T01:42:51.1244823Z ##[debug]Importing cmdlet 'Invoke-Ant'.
  &gt; 2016-04-14T01:42:51.1255789Z ##[debug]Importing cmdlet
  &gt; 'Invoke-BatchScript'. 2016-04-14T01:42:51.1255789Z ##[debug]Importing
  &gt; cmdlet 'Invoke-Maven'. 2016-04-14T01:42:51.1266037Z ##[debug]Importing
  &gt; cmdlet 'Invoke-MSBuild'. 2016-04-14T01:42:51.1266037Z
  &gt; ##[debug]Importing cmdlet 'Invoke-PublishSymbols'. 2016-04-14T01:42:51.1276045Z ##[debug]Importing cmdlet 'Invoke-Tool'.
  &gt; 2016-04-14T01:42:51.1276045Z ##[debug]Importing cmdlet
  &gt; 'Invoke-VSTest'. 2016-04-14T01:42:51.1286046Z ##[debug]Importing
  &gt; cmdlet 'Publish-BuildArtifact'. 2016-04-14T01:42:51.1286046Z
  &gt; ##[debug]Importing cmdlet 'Copy-BuildArtifact'. 2016-04-14T01:42:51.1296014Z ##[debug]Importing cmdlet
  &gt; 'Add-BuildArtifactLink'. 2016-04-14T01:42:51.1296014Z
  &gt; ##[debug]Importing cmdlet 'Register-XamarinLicense'. 2016-04-14T01:42:51.1306047Z ##[debug]Importing cmdlet
  &gt; 'Unregister-XamarinLicense'. 2016-04-14T01:42:51.1306047Z
  &gt; ##[debug]Importing cmdlet 'Get-X509Certificate'. 2016-04-14T01:42:51.3085527Z ##[debug]Loading module from path
  &gt; 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.97.1\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.DTA\Microsoft.TeamFoundation.DistributedTask.Task.DTA.dll'.
  &gt; 2016-04-14T01:42:51.4288417Z ##[debug]Importing cmdlet
  &gt; 'Invoke-DeployTestAgent'. 2016-04-14T01:42:51.4298713Z
  &gt; ##[debug]Importing cmdlet 'Invoke-RunDistributedTests'. 2016-04-14T01:42:51.4318712Z ##[debug]Getting the connection object
  &gt; 2016-04-14T01:42:51.6626731Z ##[debug]UnregisterTestAgent script Path 
  &gt; =  2016-04-14T01:42:51.6626731Z ##[debug]Calling Invoke-RunDistributedTests 2016-04-14T01:42:51.7435357Z
  &gt; ##[debug]Invoking Run Distributed Tests with Register Environment support 2016-04-14T01:42:52.5708848Z ##[warning]For troubleshooting,
  &gt; refer http://aka.ms/remotevstest. 2016-04-14T01:42:52.6509473Z
  &gt; ##[error]System.InvalidOperationException: Unable to get teamfoundation Collection Uri. Contact your administrator for more
  &gt; information. 2016-04-14T01:42:52.6519461Z ##[error]   at
  &gt; Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.RunTests.Run()
  &gt; 2016-04-14T01:42:52.6529465Z ##[error]   at
  &gt; Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.TaskRunner.Run(Dictionary`2
  &gt; arguments, VssConnection connection, TaskType taskType)
  &gt; 2016-04-14T01:42:52.6529465Z ##[error]   at
  &gt; Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.RundistributedTestsCmdLet.ProcessRecord()
  </code></pre>
  
  <p><strong>UPDATE - Added Screenshot</strong></p>
  
  <p><a href="https://i.stack.imgur.com/3a133.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3a133.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE 2 - More Details</strong></p>
  
  <p>The Azure VM is not on a domain, its in a WORKGROUP</p>
  
  <p><strong>UPDATE 3 - Recreated as a BUILD task</strong></p>
  
  <p>I created a new BUILD with a single task "Run Functional Tests".
  A similar error occurred.</p>
  
  <p><a href="https://i.stack.imgur.com/SinxJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SinxJ.png" alt="BUILD Task"></a></p>
  
  <p><strong>BUILD COMPLETE LOG</strong></p>
  
  <pre><code>2016-04-19T21:51:19.2143997Z Entering OnPrepareEnvironment
  2016-04-19T21:51:19.2613857Z Primary repository: SampleWebApiE2ERelease
  2016-04-19T21:51:19.2643916Z Calculating build folder hash key.
  2016-04-19T21:51:19.2683854Z Loading tracking config if exists: C:\a\SourceRootMapping\0898c6c5-1b24-4adf-945a-6859faaaf010\8\SourceFolder.json
  2016-04-19T21:51:19.2703915Z Creating new tracking config.
  2016-04-19T21:51:19.2719613Z Loading top-level tracking config if exists: C:\a\SourceRootMapping\Mappings.json
  2016-04-19T21:51:19.2752569Z Writing config to file: C:\a\SourceRootMapping\Mappings.json
  2016-04-19T21:51:19.3362720Z Writing config to file: C:\a\SourceRootMapping\0898c6c5-1b24-4adf-945a-6859faaaf010\8\SourceFolder.json
  2016-04-19T21:51:19.3452728Z Checking if artifacts directory exists: C:\a\1\a
  2016-04-19T21:51:19.3452728Z Creating artifacts directory.
  2016-04-19T21:51:19.3462731Z Checking if test results directory exists: C:\a\1\TestResults
  2016-04-19T21:51:19.3472726Z Creating test results directory.
  2016-04-19T21:51:19.3482737Z Creating binaries directory.
  2016-04-19T21:51:19.3482737Z Setting local variables.
  2016-04-19T21:51:19.3492744Z Create the initial timeline records for the tasks
  2016-04-19T21:51:19.3512737Z Preparing repositories
  2016-04-19T21:51:19.3522741Z repo clean = False
  2016-04-19T21:51:19.3522741Z Found 2 endpoints to consider
  2016-04-19T21:51:19.3692726Z Found 1 repositories to sync
  2016-04-19T21:51:19.3822789Z Starting: Get sources
  2016-04-19T21:51:19.3872730Z build.fetchtags=false
  2016-04-19T21:51:19.3922753Z Entering GitSourceProvider.PrepareRepositoryAsync
  2016-04-19T21:51:19.3932745Z Repository type=TfsGit
  2016-04-19T21:51:19.3932745Z localPath=C:\a\1\s
  2016-04-19T21:51:19.3942746Z clean=False
  2016-04-19T21:51:19.3942746Z sourceBranch=refs/heads/master
  2016-04-19T21:51:19.3952739Z sourceVersion=60e5e7f72e94016da7c2de37c839a015656f803c
  2016-04-19T21:51:19.3952739Z Syncing repository: SampleWebApiE2ERelease (Git)
  2016-04-19T21:51:19.3962739Z repository url=https://*******.visualstudio.com/DefaultCollection/_git/SampleWebApiE2ERelease
  2016-04-19T21:51:19.3982738Z checkoutSubmodules=False
  2016-04-19T21:51:19.6062900Z Starting clone
  2016-04-19T21:51:21.3684519Z Checking out 60e5e7f72e94016da7c2de37c839a015656f803c to C:\a\1\s
  2016-04-19T21:51:21.5500305Z Checked out branch refs/heads/master for repository SampleWebApiE2ERelease at commit 60e5e7f72e94016da7c2de37c839a015656f803c
  2016-04-19T21:51:21.5510565Z Leaving GitSourceProvider.PrepareRepositoryAsync
  2016-04-19T21:51:21.5720503Z Leaving OnPrepareEnvironment
  2016-04-19T21:51:21.7216514Z Running tasks
  2016-04-19T21:51:21.7586505Z Starting task: Run Tests bin\Release\AcceptanceTest.dll on *************************.australiaeast.cloudapp.azure.com
  2016-04-19T21:51:21.9697226Z Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\tasks\RunVisualStudioTestsusingTestAgent\1.0.33\RunDistributedTests.ps1
  2016-04-19T21:51:22.3211330Z ##[debug]Entering script RunDistributedTests.ps1
  2016-04-19T21:51:22.3241378Z ##[debug]TestMachineGroup = *************************.australiaeast.cloudapp.azure.com
  2016-04-19T21:51:22.3251318Z ##[debug]Test Drop Location = C:\AcceptanceTests\SampleWebApiE2ERelease
  2016-04-19T21:51:22.3251318Z ##[debug]Source Filter = bin\Release\AcceptanceTest.dll
  2016-04-19T21:51:22.3261325Z ##[debug]Test Filter Criteria = 
  2016-04-19T21:51:22.3271314Z ##[debug]RunSettings File = C:\AcceptanceTests\SampleWebApiE2ERelease\AcceptanceTest.runsettings
  2016-04-19T21:51:22.3271314Z ##[debug]Build Platform = 
  2016-04-19T21:51:22.3281422Z ##[debug]Build Configuration = 
  2016-04-19T21:51:22.3291320Z ##[debug]CodeCoverage Enabled = false
  2016-04-19T21:51:22.3291320Z ##[debug]TestRun Parameters to override = 
  2016-04-19T21:51:22.3301320Z ##[debug]TestConfiguration = 
  2016-04-19T21:51:22.3321302Z ##[debug]Application Under Test Machine Group = 
  2016-04-19T21:51:22.3531325Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.dll'.
  2016-04-19T21:51:22.3681296Z ##[debug]Importing cmdlet 'Complete-Task'.
  2016-04-19T21:51:22.3681296Z ##[debug]Importing cmdlet 'Get-LocalizedString'.
  2016-04-19T21:51:22.3691292Z ##[debug]Importing cmdlet 'Set-TaskVariable'.
  2016-04-19T21:51:22.3691292Z ##[debug]Importing cmdlet 'Set-TaskProgress'.
  2016-04-19T21:51:22.3691292Z ##[debug]Importing cmdlet 'Add-TaskIssue'.
  2016-04-19T21:51:22.3701295Z ##[debug]Importing cmdlet 'Write-TaskDetail'.
  2016-04-19T21:51:22.3701295Z ##[debug]Importing cmdlet 'Find-Files'.
  2016-04-19T21:51:22.3841314Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Internal\Microsoft.TeamFoundation.DistributedTask.Task.Internal.dll'.
  2016-04-19T21:51:22.3901295Z ##[debug]Importing cmdlet 'Add-BuildAttachment'.
  2016-04-19T21:51:22.3901295Z ##[debug]Importing cmdlet 'Convert-String'.
  2016-04-19T21:51:22.3911318Z ##[debug]Importing cmdlet 'Get-IndexedSourceFilePaths'.
  2016-04-19T21:51:22.3911318Z ##[debug]Importing cmdlet 'Get-JavaDevelopmentKitPath'.
  2016-04-19T21:51:22.3921318Z ##[debug]Importing cmdlet 'Get-MSBuildLocation'.
  2016-04-19T21:51:22.3921318Z ##[debug]Importing cmdlet 'Get-ServiceEndpoint'.
  2016-04-19T21:51:22.3931319Z ##[debug]Importing cmdlet 'Get-TfsClientCredentials'.
  2016-04-19T21:51:22.3941311Z ##[debug]Importing cmdlet 'Get-ToolPath'.
  2016-04-19T21:51:22.3941311Z ##[debug]Importing cmdlet 'Get-TaskVariable'.
  2016-04-19T21:51:22.3951312Z ##[debug]Importing cmdlet 'Get-VisualStudioPath'.
  2016-04-19T21:51:22.3951312Z ##[debug]Importing cmdlet 'Get-VssConnection'.
  2016-04-19T21:51:22.3961310Z ##[debug]Importing cmdlet 'Invoke-Ant'.
  2016-04-19T21:51:22.3961310Z ##[debug]Importing cmdlet 'Invoke-BatchScript'.
  2016-04-19T21:51:22.3971305Z ##[debug]Importing cmdlet 'Invoke-Maven'.
  2016-04-19T21:51:22.3971305Z ##[debug]Importing cmdlet 'Invoke-MSBuild'.
  2016-04-19T21:51:22.3981310Z ##[debug]Importing cmdlet 'Invoke-PublishSymbols'.
  2016-04-19T21:51:22.3981310Z ##[debug]Importing cmdlet 'Invoke-Tool'.
  2016-04-19T21:51:22.3991312Z ##[debug]Importing cmdlet 'Invoke-VSTest'.
  2016-04-19T21:51:22.3991312Z ##[debug]Importing cmdlet 'Publish-BuildArtifact'.
  2016-04-19T21:51:22.4001333Z ##[debug]Importing cmdlet 'Copy-BuildArtifact'.
  2016-04-19T21:51:22.4001333Z ##[debug]Importing cmdlet 'Add-BuildArtifactLink'.
  2016-04-19T21:51:22.4011309Z ##[debug]Importing cmdlet 'Register-XamarinLicense'.
  2016-04-19T21:51:22.4011309Z ##[debug]Importing cmdlet 'Unregister-XamarinLicense'.
  2016-04-19T21:51:22.4011309Z ##[debug]Importing cmdlet 'Get-X509Certificate'.
  2016-04-19T21:51:22.4141314Z ##[debug]Loading module from path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.DTA\Microsoft.TeamFoundation.DistributedTask.Task.DTA.dll'.
  2016-04-19T21:51:22.4351328Z ##[debug]Importing cmdlet 'Invoke-DeployTestAgent'.
  2016-04-19T21:51:22.4361318Z ##[debug]Importing cmdlet 'Invoke-RunDistributedTests'.
  2016-04-19T21:51:22.4381326Z ##[debug]Getting the connection object
  2016-04-19T21:51:23.2196120Z ##[debug]UnregisterTestAgent script Path  = 
  2016-04-19T21:51:23.2206119Z ##[debug]Calling Invoke-RunDistributedTests
  2016-04-19T21:51:23.3495532Z ##[debug]Invoking Run Distributed Tests with Register Environment support
  2016-04-19T21:51:23.5023828Z ##[warning]For troubleshooting, refer http://aka.ms/remotevstest.
  2016-04-19T21:51:23.5171330Z ##[error]System.InvalidOperationException: Unable to get teamfoundation Collection Uri. Contact your administrator for more information.
  2016-04-19T21:51:23.5181352Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.RunTests.Run()
  2016-04-19T21:51:23.5191312Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.TaskRunner.Run(Dictionary`2 arguments, VssConnection connection, TaskType taskType)
  2016-04-19T21:51:23.5201289Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.RundistributedTestsCmdLet.ProcessRecord()
  2016-04-19T21:51:23.5669478Z Finishing task: RunVisualStudioTestsusingTestAgent
  2016-04-19T21:51:23.5679492Z ##[error]System.Exception: Task RunVisualStudioTestsusingTestAgent failed. This caused the job to fail. Look at the logs for the task for more details.
  2016-04-19T21:51:23.5689495Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.Run(IJobContext jobContext, IJobRequest job, IJobExtension jobExtension, CancellationTokenSource tokenSource)
  2016-04-19T21:51:23.5719485Z Entering OnFinalizeJob
  2016-04-19T21:51:23.5739469Z Leaving OnFinalizeJob
  </code></pre>
  
  <p><strong>UPDATE 4</strong></p>
  
  <p>I changed the tasks in the BUILD so that the tasks are;</p>
  
  <pre><code>NuGet Installer
  
  Visual Studio Build
  
  Visual Studio Test (unit tests)
  
  Index Sources &amp; Publish Symbols
  
  Copy And Publish Build Artifacts
  
  Azure File Copy
  
  Visual Studio Test Agent Deployment
  
  Run Functional Tests
  </code></pre>
  
  <p>The "Run Functional Tests" worked.</p>
  
  <p>I then removed the 3 tasks Azure File Copy, Visual Studio Test Agent Deployment, Run Functional Tests from the BUILD, as I dont want the acceptance tests as part of the BUILD, but as part of the RELEASE.</p>
  
  <p>I then changed my RELEASE tasks so they are;</p>
  
  <pre><code>Azure File Copy
  
  Visual Studio Test Agent Deployment
  
  Run Functional Tests
  </code></pre>
  
  <p>That worked.</p>
  
  <p>I then disabled the task Visual Studio Test Agent Deployment because the agent is now deployed on the VM and the task takes a little while to run.</p>
  
  <p>That failed, it seems that Run Functional Tasks requires a preceding task Visual Studio Test Agent Deployment.</p>
  
  <p>Is that a bug with Run Functional Tests?  Should you be able to configure your own VM with a Test Agent already installed?</p>