How to force Azure File Sync on demand

Share on linkedin
LinkedIn
Share on twitter
Twitter
Share on facebook
Facebook

Azure File Sync

Microsoft Azure File Sync is a great way to send your on-premises Server files to the cloud.  The only shortcoming is that file changes made directly from the Azure Storage Account can take up to 24 hours to replicate back to the on-premises Server.

In this article I will show a way to replicate more frequently and even on demand. 

Please note that at this point in time,
Invoke-AzStorageSyncChangeDetection
is limited to datasets less then 10K objects!  In other words, this article won’t work for directories with more then ten thousand objects.

  1. Login to your Azure Portal.
  2. Create a new resource in Azure,  All Services > ‘automation’ > Automation Accountsazure file sync
  3. ‘Add’ a new Account, give it a name and choose options suited to your environmentazure storage sync
  4. Go into your the newly created AutomationAccount, under Shared Resources click Modules > Browse gallery
  5. Search for Az.Accounts, then Click Import
  6. Search for Az.StorageSync  , again Import.   Please wait for the modules to import, once done they will appear as Available.azure storage sync
  7. Under Process Automation, click Runbooks > Create a runbook
  8. Give it a name, the Runbook type is Powershellazure storage sync
  9. Go into the Runbook and Edit it
  10. Paste the following into CMDLETS  Sync  This script comes from Charbel Nemnom, you can check out his other work at https://charbelnemnom.com azure storage sync
  11. Save, then Publish the Runbook
  12. Click Schedules > Add schedule
  13. Give the Schedule a name and set Recurring optionsazure storage sync
  14. Configure the Parameters, pay attention to the Path*   .  The Path refers to the directory in which you wish to force sync. 
    i.e. if your Azure FileSync is syncing everything in c:\Shares  and you wish to force sync c:\Shares\Clients  you would enter the PATH as   Clientsazure storage sync

So now that its all done, you can test it by uploading a file directly AzureStorage, run the Playbook manually or wait for the next sync.  The file you uploaded directly to Azure will now appear on the on-premises server.

Want to stay up to date with useful tech-tips?  

Follow us on LinkedIn, Facebook or Twitter to be notified when we post new content. Or, even better, scroll down to the very bottom of this page to sign up for our Newsletter. We only send them once a month and you can always unsubscribe.