How to Automate File Transfers with Azure using MOVEit

How to Automate File Transfers with Azure using MOVEit

For those of you who use MOVEit Automation to automate the transfer of files between different hosts, you will know that while there are a number of supported hosts from SFTP servers to Amazon S3, there is no current native connector for Microsoft Azure blobs at the time of writing.

It has been rumoured that there will be a native connector for Microsoft Azure blobs in 2020, however this has not been confirmed. So, how can we bring Azure blobs into our MOVEit Automation workflows today, despite there not being a native connector?

 

MOVEit Automation Scripting

 

The answer lies in the MOVEit Automation scripting interface which opens up the application to endless possibilities where a PowerShell or VBScript can be created to perform functionality, not offered in the GUI.

This method of creating custom connector is something we have written about before, specifically in the context of Google Drive - you can read that blog here.

To create a new script, you will need to either create the script using the native operating system tools - for example Notepad++; or you can use the editor built into the MOVEit Automation administrative interface.

A sample script using PowerShell is below:

try {
#Import Azure modules. Your location may be different.
Import-Module -name "c:\program files\windowspowershell\modules\AzureRM.Profile"
Import-Module -name "c:\program files\windowspowershell\modules\Azure.Storage"

#get some of the Azure information from MOVEit Automation Parameters
$storageaccountname = $miaclient.MIGetTaskParam("AzStorageAccount")
$storagekey = $miaclient.MIGetTaskParam("AzStorageKey")
$containername = $miaclient.MIGetTaskParam("AzContainer")

#authenticate against azure account
$ctx = New-AzureStorageContext $storageaccountname $storagekey

#get a cachefile name
$cachefile = $miaclient.MICacheFilename()

#use original name from Automation for the file on Azure
$destfile = $miaclient.MIGetOriginalFilename()

#send content to Azure
Set-AzureStorageBlobContent -Context $ctx -Container $containername -File $cachefile -Blob $destfile

} catch {
$miaclient.MISetErrorCode(10000)
$miaclient.MISetErrorDescription("Error: " + $Error)
}

 

Task Parameters and Finalising

 

First and foremost, you will need to ensure that the locations of the AzureRM.Profile and Azure.Storage modules are correct on your operating system; and replace them with the correct paths, should they be different.

Secondly, you will need to create some task parameters in the task which will be hosting this script.

  • AzStorageAccount - The Azure blob account to be used.
  • AzStorageKey - The storage key associated with the above account.
  • AzContainer - The container to upload the file to.

The remainder of the script collects the files from the task source location and then uploads them to the Azure blob location.

We have over eleven years' of experience with MOVEit Automation, helping companies and organisations of various sizes and types automate file transfers. If you think you could benefit from our assistance, please book a call with one of our solutions specialists today.

 

New call-to-action