Copy a File to an Azure VM

This Azure Automation runbook copies a file from the local runbook host to an Azure virtual machine. This runbook is intended to run after a file is copied to the local host so ensure that you have copied the file to the runbook host before calling this.

 
 
 
 
 
4.7 Star
(6)
5,876 times
Add to favorites
Windows Azure
8/22/2014
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Local Path file not found
    2 Posts | Last post August 19, 2014
    • Ken I am having the same issue. I have tried all kinds of combos. Running with just a param of c:\testinput.txt and the file is there but it is not found.
    • Hi Mike & Ken.  Ken - you are correct that your Automation jobs are run in an Azure Automation host server.  So you will not have access to files on the local host where your runbook is running unless you copy them in.  The other runbook that we created with this example is http://gallery.technet.microsoft.com/scriptcenter/Copy-and-Item-from-an-c283405d  which shows how to copy a file to the Azure Automation host:
      Copy-ItemFromAzureVM -AzureConnectionName "AzureConnection" -ServiceName "myService" -VMName "myVM" -VMCredentialName "myVMCred" -LocalPath ".\myFileCopy.txt" -RemotePath "C:\Users\username\myFile.txt" 
      
      The other thing that you should be aware of when you are writing runbooks that access and copy files to the local host is that if for some reason a server goes down or you have an unexpected error in your runbook, it will likely not start on the same host.   You would want to checkpoint before you copy the file so that if you crash, the file will exist on the new runbook host.  
      
      Do keep us posted if this resolves your issue & if you have any other questions.
  • What is the "local path" the context of this script?
    1 Posts | Last post August 07, 2014
    • It's not clear to me what the "local path" is in the context of this script. I assume that the script itself is running on some kind of Azure Automation host server...but I also assume that I don't have any access to the host server.
      
      I setup the script to run in an Azure Automation account and everything seems to be working great except that the local file (the source file) to be copied can't be found.