Using Azcopy and SAS to Transfer Files to Azure Files Share
Introduction
Got a project that requires to transfer large and binary files from on-premise to Azure Files Share so that Azure VMs can mount the Share with SMB and process the files directly.
Did some readings and research from the internet, using a scheduler to trigger a PowerShell script which uses Azcopy seems a simple and direct approach.
Small Proof of Concept …
- Connect to Azure and save a Profile in Json.
- Connect-AzAccount and sign on when prompted, and then save the context.
3. Connect-AzAccount in PowerShell script. Better use a Service Principal without MFA restriction.
4. Generate the Azure Storage SAS token. Adjust the permissions and constraints for the token.
5. Call Azcopy to transfer the file.
Another possible implementation is to use Shared Key but it requires bit more complicated logic to generate the Authorization Token. The implementation is better used with Azure Files REST API.