mnj
mnj

Reputation: 3433

Windows Machine File Copy - DevOps task and IP address

I am building a Release Pipeline on Azure DevOps. Part of my release is to copy a bunch of files to the Azure VM. As far as I understand, the target machine needs to have PowerShell 5986 port open.

I have a VM with port 5986 open (I verified that by invoking remotely some commands on this VM with "PowerShell on Target Machines" task). I added "Windows Machine File Copy" task and filled fields: - Source - Machines - Admin Login - Password - Destination Folder

In "Machines" field, I put IP of the target machine.

As a result of running the release, I'm getting an error:

Failed to Create PSDrive with Destination: '\\11.11.11.11\C$\TargetDirectory', ErrorMessage: 'The network path was not found' The network path was not found

I also tried to put IP address with a port, in this form: 11.11.11.11:5986

Then, I got this error:

Cannot convert value "\23.97.151.221:5986" to type "System.Uri". Error: "Invalid URI: The hostname could not be parsed."

Documentation (https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/windows-machine-file-copy?view=azure-devops) says that IP address with a port is allowed.

What's the issue here?

Upvotes: 7

Views: 17879

Answers (6)

PaAl
PaAl

Reputation: 1

I solved it! You must use "down level user name" under "Admin Login": domain/username

Hier is "domain" from User account, not Web-domain ;)

And now you can copy files across Windows Domain boundary :)

Good luck!

Upvotes: 0

venkatesh guggilla
venkatesh guggilla

Reputation: 21

go to the destination folder, right-click the folder select properties,share option is there, click that one and share everyone option is there

Upvotes: 2

Yusuff Sodiq
Yusuff Sodiq

Reputation: 945

I was getting the exact same error while doing these:

  • Initially in my release pipeline, I had an agent job and I created a Windows machine file copy task under the job and filled in all details correctly. I set the Machines field with the public IP address of my target server (a Windows azure VM) and I always got this error you reported.

  • I tried to use the Azure file copy task instead but I was faced with another problem (error message: Unable to get FQDN for all resources in ResourceGroup: {resourceGroupName}) which I couldn't get to fix after a lot of efforts.

This is the solution that worked for me:

  • Instead of running an agent job, I ran a Deployment Group Job. With deployment groups, I didn't need an IP address to connect to my VM. Setting up a deployment group for your Azure VM is very simple and well explained here

  • I created a Windows Machine File Copy task under the Deployment Group job I added. I filled same details for the task except that instead of the IP address of the Windows VM, I entered the computer name in the Machines field and the file copy task ran successfully!

I hope this helps

Upvotes: 10

Robert
Robert

Reputation: 2208

The problem is because you can't use that task to copy files across Windows Domain boundary! That is to say, if you build on host A and want to copy files to host B, then A and B must be in the same Windows Domain, otherwise you'll get the error like

##[error]Failed to Create PSDrive with Destination: '\\your-server-name-or-ip\some\path', ErrorMessage: 'The network path was not found'

That is to say, if you're using a hosted agent, then you're not able to copy files with that task to any host you have, no matter it has a public IP or not, or a FQDN, because they are not in the same Windows Domain!

You have two options to work around it:

  • Use Azure File Copy task if your target is an Azure VM or Azure Storage
  • Use private hosted agent and make sure your target host and your private agent are in the same Windows Domain

Last but not least, the document should really make it clear! It wasted me a lot of time on solving the problem!

Upvotes: 10

mnj
mnj

Reputation: 3433

The solution is to go to the target server and SHARE the directory where the files would be copied. In Windows, just go to Properties of the directory, Sharing tab, and Share it to the user which is used in the VSTS task.

Upvotes: -2

Vikas Goyal
Vikas Goyal

Reputation: 467

The answer is pretty simple, the DevOps Tasks are actually running PowerShell on you VM and trying to create a PSDrive.

Try using the task mentioned in the screenshot below:

Upvotes: -3

Related Questions