Development edition · 16 November 2026. Commands using repository paths, Make targets or sample projects require access to the Quinzee source checkout. No public installer is available. Examples use disposable local environments.
6. Store documents in Blob Storage
A storage account contains containers; a container contains named blobs. In
this example documents is private, and hello.txt is a block blob. The Azure
Blob client obtains a storage-audience token from the credential automatically.
Run the deployment chapter first so that outputs.json exists.
QHQ shows storage accounts and their Blob endpoints. This capture uses the
browser demo's resource names; your book resources use the bk… prefix.
Step 1: upload, read and list
Replace Program.cs with this complete example, then run it in the client
container with dotnet run --no-restore:
using Azure.Storage.Blobs;
var book = BookContext.Load();
var outputs = book.Outputs();
var service = new BlobServiceClient(new Uri(outputs["blobEndpoint"]), book.Credential);
var container = service.GetBlobContainerClient("documents");
await container.CreateIfNotExistsAsync();
var blob = container.GetBlobClient("hello.txt");
await blob.UploadAsync(BinaryData.FromString("Hello from Quinzee."), overwrite: true);
await blob.SetMetadataAsync(new Dictionary<string, string> { ["source"] = "book" });
var downloaded = await blob.DownloadContentAsync();
Console.WriteLine(downloaded.Value.Content.ToString());
await foreach (var item in container.GetBlobsAsync())
Console.WriteLine($"{item.Name}: {item.Properties.ContentLength} bytes");
Expect Hello from Quinzee. and a listing containing hello.txt. Rerunning
replaces that blob because overwrite: true is explicit. For a real file use
await blob.UploadAsync("/work/document.txt", overwrite: true); do not load a
large file into a string merely to upload it.
Metadata belongs to the blob, separately from its content. Blob names can
contain / to represent an application naming hierarchy. They are still blob
names, not host filesystem paths.
Step 2: share read access with a scoped SAS
A service SAS grants a limited operation on a named blob until an expiry time.
Constructing one requires an account key; a bearer credential alone cannot sign
it. Replace Program.cs with this example after creating hello.txt above:
using Azure.Storage;
using Azure.Storage.Blobs;
using Azure.Storage.Sas;
var book = BookContext.Load();
var outputs = book.Outputs();
var account = outputs["storageName"];
using var keyResponse = await book.PostArmAsync(
$"Microsoft.Storage/storageAccounts/{account}/listKeys", "2023-05-01");
var key = keyResponse.RootElement.GetProperty("keys")[0].GetProperty("value").GetString()!;
var signer = new StorageSharedKeyCredential(account, key);
var blob = new BlobServiceClient(new Uri(outputs["blobEndpoint"]), signer)
.GetBlobContainerClient("documents").GetBlobClient("hello.txt");
var sas = new BlobSasBuilder
{
BlobContainerName = "documents", BlobName = "hello.txt", Resource = "b",
StartsOn = DateTimeOffset.UtcNow.AddMinutes(-1),
ExpiresOn = DateTimeOffset.UtcNow.AddMinutes(5),
Protocol = SasProtocol.Https
};
sas.SetPermissions(BlobSasPermissions.Read);
var delegated = new BlobClient(blob.GenerateSasUri(sas));
Console.WriteLine((await delegated.DownloadContentAsync()).Value.Content.ToString());
The delegated client sends no bearer token. Possession of its signed URL grants
read access to hello.txt; it does not grant write access or access to another
blob. Do not print or log that URL or the account key. Both account keys work;
rotating the key used to sign a SAS invalidates signatures based on the old key.
Step 3: choose the right local limits
Quinzee supports block blobs, conditional operations with ETags, metadata, range reads and staged block uploads. Single PUT/block request bodies are limited to 256 MiB, and a committed block blob to 1 GiB. Large transfers stream through bounded buffers; these limits are not a global disk-space quota.
Use request conditions when several writers might update the same document.
An If-Match failure is a concurrency conflict, not a reason to disable the
condition and overwrite someone else's result blindly.
Page/append blobs, leases, snapshots, versions, user-delegation/account SAS,
stored access policies and Queue SAS are outside this implementation. The
supported service SAS permissions are r, w, d and l; do not assume that
every option exposed by BlobSasBuilder is implemented.
Delete a tutorial blob with await blob.DeleteIfExistsAsync() when it is no
longer needed. Account or resource-group deletion removes all of its Blob and
Queue data.