In the previous post I showed how to work with Azure File Service directories and provided basic code samples. In this post I am going to continue with Azure File Service, I am going to show how to work with files.
Refer to previous posts to get started with Azure File Service.
Azure File Service files are Azure Page Blobs, they even have similar methods. Consider the following simple example:
var root = share.GetRootDirectoryReference(); var file = root.GetFileReference("file.txt"); file.UploadText("content");
You can also use similar Upload methods:
To download file content the following approach can be used:
var file = root.GetFileReference("file.txt"); var content = file.DownloadText(); Console.WriteLine(content);
Other Download methods are also available:
You may notice that Azure File Service file class has same methods as Azure Page Blob class. You can refer to Part 26: Azure Blob Service - Page Blobs to better understand what you can do with Azure File Service files. The main difference between Azure File Service files and Azure Page Blobs is that you can't use
leasing functionality to lock file for some time. Also, you can't make a file snapshot. All other operations work in the same or in almost the same way.
In this post I have showed how to work with Azure File Service files. To better understand Azure File Service, you need to be familiar with Azure Blob Service and Azure Table Service, because Azure File Service uses them internally. In the next post I am going to show how to work with Azure Storage Analytics from code.