How-to
Use Azure Blob for swarm storage
Pattern
Implement IQuorumStorage with the Azure SDK. TryCreateNewAsync must use UploadAsync with IfNoneMatch: "*" access conditions for atomic create:
public sealed class AzureBlobQuorumStorage : IQuorumStorage
{
private readonly BlobContainerClient _container;
public async Task<bool> TryCreateNewAsync(string path, byte[] data)
{
var blob = _container.GetBlobClient(path);
try
{
await blob.UploadAsync(new MemoryStream(data),
new BlobUploadOptions {
Conditions = new BlobRequestConditions { IfNoneMatch = ETag.All }
});
return true;
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
return false;
}
}
} See also
- The scaling model (swarm) Concept
- Use AWS S3 for swarm storage How-to