How To Set Up Azure File Sync With PowerShell

File Sync is a service in Microsoft Azure that allows a user to automatically sync files in a specified folder on an on-prem Windows Server. To set up Azure File Sync, unfortunately, requires quite a few steps but by combining all of these steps together with a well-crafted PowerShell script, we can automate this entire process!

In this video, we’ll cover everything from creating the required Azure file share, installing the File Sync agent, creating the required storage sync service, registering the server, creating the sync group, cloud endpoint and server endpoint. That’s a lot of steps but by the end of this video, you’ll learn how to do all of that with a single PowerShell script.

Prerequisites include: An Azure subscription A Windows Server 2016 machine

Hi there, for this topic. We're going to look at how to set up and configure azure file sync. So here on our file server. We have a E drive, which is the shared drive and we've got a bunch of files here, pretending to be our file share. So a few things we need to set up on the file server. If we go to the server manager go into local server we’ll need to make sure that IE enhanced security configuration is switched off on the right hand side. And also in PowerShell. We need to make sure that we're running. PowerShell version 5.1 and we want to install the Azure. RM module so I've done that all beforehand. So this server is going to need Internet access as well in order to upload these files into Azure. So just to prove the point. If we go to the Azure portal here on the server. We know that we've already got Internet access. So, in the Azure portal. We've got a resource group set up beforehand. And if we go into storage accounts. Here we need to set up a storage account in order to sync the files to. So I click on add at the top. Going to give this a name. I'm going to select an account type, so I'm going to make this a V2. I'm going to select our location where our file servers are stored so W Europe. In this case, and a storage type I’m going to use locally redundant storage. So if we scroll down here. I need to give it a subscription. I've already created a resource group for this, I'm going to select that. And then click on create. Once the storage account is created for click on refresh to sit appear on the list. And we're going to need to click into that. And create a file share. So on the overview blade here if we scroll down a little bit to files and click on that. Click on the plus symbol at the top here for file share. So I'm going to give it a name and a quota. Click on OK. So once that's created I'm going to need to go and create a storage sync service. So if we go to create a resource here at the top left hand corner. And search for Azure File Sync. Right click on Azure File Sync in the list. Click on create. And we need to give us a name. And give it a subscription. And I'm going to put it in the resource group created earlier. And again select the location to be the region, where you got the file servers. So once the storage sync service is created if we click on storage sync service on the left hand side here. And click on our newly created sync service. So the first thing we need to do in here is create a new sync group. And, I'm going to call that sync group oh one. So we need to give it your subscription. On a storage account. So we're going to use the storage account were created earlier and select the file share that we created also. When I click on create. So once the single group is created. If we go back to our file server. And we need to download the storage sync agent from the Microsoft download site. And if we run that. We can run through the install. So once the install is finished, we can click on finish button at the bottom here. Here we can click on updates to make sure we got the latest version of the client. So then the update will get a warning about restarting the system. But we can do this later so click on OK. And it will start the setup wizard. So we need to click on sign in here in here and put in our credentials for Azure service. And here we need to select the subscription. And select the resource group. In the sync service that we've just created. And again we need to sign in. And click on OK to complete the process. So now we need to restart the server in order to apply the updates that it downloaded. So once the server is restarted we need to go back to the Azure portal. OK so our storage sync service. And click on our sync group that we created earlier. In here we need to add a server endpoint. So we'll click on the button at the top. So we should be able to select our registered server here. We need to give it the path of the file share where our data is. I'm going to click on enable for cloud tiering so the old files get moved up to Azure and leave space on the server. I'm going to select 50% free space needs to be kept and then click on create. As we seen down at the bottom one server endpoint has appeared and it's in the provisioning state. So after a short period of the server being provisioned we’ll see that the server end point at the bottom there goes to the state of pending. So, in resource monitor here if we go to network we’ll see the file sync service is creating a lot of traffic because it's uploading the files into Azure. So obviously this is going to take quite a long time to synchronize up to Azure. You just need to leave it to complete so once this is complete, your files will be safe up in azure but available on the local file server. So that has been how to set up and configure Azure file sync thanks for watching.