azuresim guide
Overview
azuresim compiles Floci-AZ 0.15.0 together with a semantics and authentication overlay into a single native executable listening on http://127.0.0.1:4577. It emulates Azure Blob Storage and Azure Queue Storage in process without Docker containers, a Java runtime, or external network access.
Architecture and real Azure semantics overlay
The build pipeline (scripts/build.py) verifies the pinned upstream source tarball against upstream.lock.json and applies SHA-256-verified handler overlays (overlay.lock.json) so the emulator matches real Azure Storage behavior expected by official Azure SDKs and lmcloud conformance suites:
- Existence and deletion semantics: deleting a non-existent container or queue returns HTTP 404 (ContainerNotFound / QueueNotFound) rather than silently succeeding; blob operations on missing containers fail with 404.
- Queue creation idempotency: creating a queue returns 201 when new, 204 when it already exists with identical metadata, and 409 QueueAlreadyExists when the metadata differs.
- Empty-body visibility updates: queue_nack visibility timeout updates (PUT /devstoreaccount1-queue/<queue>/messages/<id>?popreceipt=...&visibilitytimeout=...) succeed with an empty request body as sent by the Azure Go SDK.
- Sidecar suppression: Event Hubs startup and Service Bus boot sidecars are disabled by default so the binary binds only 127.0.0.1:4577 and never requires a Docker socket.
Open mode versus SharedKey and Bearer enforcement
By default, azuresim runs in open mode (--auth open), accepting standard development requests against devstoreaccount1. Passing --auth enforce --auth-config auth.json (or setting AZURESIM_AUTH=enforce and AZURESIM_AUTH_CONFIG=auth.json) enables cryptographic and policy enforcement:
- SharedKey verification: validates Authorization: SharedKey <account>:<signature> headers using HMAC-SHA256 over the canonicalized Azure headers and resource string, requiring x-ms-date / Date within 15 minutes of the server clock and checking account keys configured in auth.json.
- Bearer token verification: matches Authorization: Bearer <token> headers exactly against configured opaque dummy tokens mapped to local principal names; no JWT validation is performed.
- Allow and deny storage policies: evaluates action and resource wildcards across containers, blobs, and queues, enforcing default-deny when policies are attached and giving explicit Deny precedence over Allow.
Connecting lmazure and Azure SDK clients
Point lmazure at azuresim by calling cloud.set_endpoint("all", "http://127.0.0.1:4577") or exporting LMAZURE_ENDPOINT=http://127.0.0.1:4577. lmazure defaults to LMAZURE_SIM_ACCOUNT=devstoreaccount1 and the standard development SharedKey:
DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:4577/devstoreaccount1;QueueEndpoint=http://127.0.0.1:4577/devstoreaccount1-queue;
Standard lmcode_std_v3 REST and CLI interfaces
LMScript programs running on lmazure against azuresim can use the lmcode_std_v3 REST and CLI interfaces when the installed lmazure ships the 226-signature catalog (check lmazure --lmcode-signatures); these are RestGet..RestOptions, RestHandler, CliCommand, CliOption, rest_config, rest_route, rest_serve, rest_stop, rest_cli:
p = _lmcode_ cli="lmazure" install="github:lmctl-ai/lmazure@latest";
@"/queues/:queue/dequeue"
fn pop_msg(x: RestExchange) -> void implements RestPost {
let list = cloud.queue_receive(x.param("queue"), 1, 30, 0);
if (list.len() == 0) {
x.status(204);
return;
}
let m = list.at(0);
cloud.queue_ack(x.param("queue"), m.receipt());
x.send(m.body());
}
@"--port"
fn opt_port(x: RestExchange) -> void implements CliOption {
cloud.set_endpoint("all", "http://127.0.0.1:" + x.query("port"));
}
@"enqueue"
fn cmd_enq(x: RestExchange) -> void implements CliCommand {
cloud.queue_create("tasks");
cloud.queue_send("tasks", x.body());
x.send("enqueued");
}
rest_config("prefix", "/v1");
end _lmcode_