Server Version: 2018-11-09
Azure Files offers fully managed file shares in the cloud that are accessible via the industry standard Server Message Block (SMB) protocol. Azure file shares can be mounted concurrently by cloud or on-premises deployments of Windows, Linux, and macOS. Additionally, Azure file shares can be cached on Windows Servers with Azure File Sync for fast access near where the data is being used.
Source code | Package (NuGet) | API reference documentation | Product documentation
Install the Azure Storage Files client library for .NET with NuGet:
Install-Package Azure.Storage.Files
Prerequisites: You must have an Azure subscription, and a Storage Account to use this package.
To create a Storage Account, you can use the Azure Portal, Azure PowerShell or Azure CLI:
Azure file shares can be used to:
- Completely replace or supplement traditional on-premises file servers or NAS devices.
- "Lift and shift" applications to the cloud that expect a file share to store file application or user data.
- Simplify new cloud development projects with shared application settings, diagnostic shares, and Dev/Test/Debug tool file shares.
string connectionString = <connection_string>;
var service = new FileServiceClient(connectionString);
var share = service.GetShareClient("myshare");
await share.CreateAsync();
string connectionString = <connection_string>;
var service = new FileServiceClient(connectionString);
var share = service.GetShareClient("myshare");
var directory = share.GetDirectoryClient("mydirectory");
await directory.CreateAsync();
var file = directory.GetFileClient("myfile");
await file.CreateAsync(maxSize: 1024);
using (var data = File.OpenRead("Data.txt"))
{
await file.UploadRangeAsync(
writeType: FileRangeWriteType.Update,
range: new HttpRange(0, 1024),
content: data);
}
All Azure Storage File service operations will throw a
StorageRequestFailedException on failure with
helpful ErrorCode
s.
Get started with our File samples.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.