Skip to content

Azure Blob Storage

The azure driver wraps github.com/Azure/azure-sdk-for-go/sdk/storage/azblob’s *azblob.Client. It targets the Blob storage service (not Files / Queues / Tables).

  • Object storage on Microsoft Azure.
  • You need SAS pre-signed URLs and block-blob multipart uploads.
Terminal window
go get github.com/gobeaver/filekit/driver/azure
go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
import (
"context"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
"github.com/gobeaver/filekit/driver/azure"
)
ctx := context.Background()
accountName := "myaccount"
accountKey := "..." // base64 storage account key
cred, err := azblob.NewSharedKeyCredential(accountName, accountKey)
if err != nil {
panic(err)
}
serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName)
client, err := azblob.NewClientWithSharedKeyCredential(serviceURL, cred, nil)
if err != nil {
panic(err)
}
fs := azure.New(client, "my-container", accountName, accountKey,
azure.WithPrefix("uploads/"),
)
_, _ = fs.Write(ctx, "report.pdf", reader)
func New(
client *azblob.Client,
containerName string,
accountName string,
accountKey string,
options ...AdapterOption,
) *Adapter

The account name and key are required separately because the driver uses them to sign SAS URLs for SignedURL / SignedUploadURL — the *azblob.Client itself doesn’t expose the credential after construction.

If you authenticate via Azure AD / managed identity instead of a shared key, pass empty strings for accountName/accountKey and accept that signed URLs won’t work; everything else still does.

  • azure.WithPrefix(prefix string) — prepended to every blob name.
InterfaceImplementedNotes
FileSystemyes
CanCopyyesserver-side StartCopyFromURL
CanMoveyescopy + delete
CanSignURLyesservice SAS via shared key
CanChecksumyescomputes SHA-256 client-side on Write
CanWatchyespolling-based (default 30 s)
ChunkedUploaderyesblock-blob StageBlock / CommitBlockList
CanReadRangenonot implemented in this driver yet
  • Write reads the entire reader into memory before calling UploadBuffer — for large uploads use the ChunkedUploader API instead.
  • The driver always computes a SHA-256 checksum client-side and returns it in WriteResult.Checksum.
  • Azure metadata keys must be valid C# identifiers; the driver does not rewrite them, so passing keys with hyphens via WithMetadata will be rejected by Azure at request time.