I am trying to convert a release pipeline into a multi-stage YAML pipeline and I am running into an issue with the AzureFileCopy@4 task. When I run the task in a release pipeline, the task succeeds and files are copied to the remote VM. When I run the task in a multi-stage YAML pipeline, the task fails. Specifically, the following command within the task fails:
New-PSSession -ComputerName 'vmname.eastus.cloudapp.azure.com' -Port 5986 -Authentication Default -Name '68fe512f-477d-4d56-9217-5ab84517a53b' -Credential $credential -UseSSL -ErrorAction 'SilentlyContinue' -ErrorVariable sessionErrors -ConfigurationName 'microsoft.powershell'
The error message that is generated is:
Connecting to remote server vmname.eastus.cloudapp.azure.com failed with the following error message : Access is denied.
I don't suspect a problem with the WinRM configuration, since I am connecting just fine in the Release Pipeline. Given the error and the command, I would say that it is the credentials, but I have looked at them over and over and they are exactly the same.
The inbound rules on the NSG have the WinRM port 5986 open to any source, so it doesn't appear that there is a restriction on which machines can start a new pssession.
UPDATE 12/22/20
Below is a sanitized version of the stage that is failing. The filecopy mostly works when it is in my build stage, but not when it is part of a deployment stage using a deploy job
- stage: deploy
jobs:
- deployment: DeployR50
displayName: Deploy R50 App
pool:
vmImage: 'windows-latest'
environment:
name: 'QA'
resourceName: 'Test'
resourceType: virtualMachine
strategy:
runOnce:
deploy:
steps:
- task: AzureFileCopy@4
inputs:
SourcePath: '$(Pipeline.Workspace)\R50\*'
azureSubscription: 'Joe MSDN Azure'
Destination: 'AzureVMs'
storage: 'mytest'
resourceGroup: 'TEST'
MachineNames: 'Test'
vmsAdminUserName: '***'
vmsAdminPassword: $(VM_PASSWORD)
TargetPath: 'c:\R50'
According to your description, you can successfully run this task in the release pipeline, so the VM settings are correct.
Based on my test, I try to export the pipeline to Yaml and it still could work fine.
You can try the following steps to check your Yaml pipeline:
Then when you create the Yaml Pipeline, you could use the existing YAML file.
This issue could be caused by incorrect username and password.