lmazure guide
Overview
lmazure brings typed Azure scripting to LMScript. Built on Go hostkit and the official Azure SDK for Go (azcore, azblob, azqueue) for the shared lmcloud schema, alongside a 72-example ARM inventory gallery, lmazure lets scripts run offline against in-process fakes or against the local azuresim emulator on 127.0.0.1:4577 with zero Azure subscription charges.
Architecture and endpoint precedence
The lmazure Go host resolves storage and queue endpoints in the following order:
1. cloud.set_endpoint(service | "all", url)
2. LMCLOUD_<SVC>_ENDPOINT
3. LMAZURE_<SVC>_ENDPOINT
4. LMCLOUD_ENDPOINT
5. LMAZURE_ENDPOINT
6. AZURE_STORAGE_BLOB_ENDPOINT / AZURE_STORAGE_QUEUE_ENDPOINT
7. AZURE_STORAGE_ENDPOINT / AZURE_ENDPOINT
When no endpoint is set, lmazure runs in-process against hostkit/fakeadapter. When a loopback endpoint such as http://127.0.0.1:4577 is provided, the Azure adapter targets azuresim using LMAZURE_SIM_ACCOUNT (default devstoreaccount1), LMAZURE_SIM_KEY (default Azurite/azuresim SharedKey), or LMAZURE_SIM_TOKEN for Bearer token authentication. The compatibility flag LMAZURE_COMPAT_PROBE_EXISTENCE=1 performs pre-operation existence probes for older azuresim builds.
Azure Blob, Queue, and Table mapping
Under the shared lmcloud schema, portable operations map cleanly to Azure Storage wire concepts:
- Object storage to Azure Blob Storage: buckets map to Blob containers under the storage account (/devstoreaccount1/<container>), and objects map to block blobs (/devstoreaccount1/<container>/<blob>) with custom x-ms-meta-* metadata and ETag tracking.
- Queues to Azure Queue Storage: queue_create and queue_delete manage queues under /devstoreaccount1-queue/<queue>; queue_send posts XML message envelopes; queue_receive dequeues messages with visibility timeouts and encodes messageId:popReceipt into the portable receipt handle used by queue_ack and queue_nack.
- Tables and permissions: key-only and sorted tables map partition keys and sort keys to Table entities with optimistic concurrency ETag checks, while policy linting and attachment validate RBAC and storage permission statements.
ARM metadata gallery and cost ledgers
The 72 illustrated examples in examples/ cover 12 read-only ARM metadata categories (resources, compute, storage, network, identity, database, queues, serverless, monitoring, dns, vaults, containers) plus 16 owned container/queue lifecycle stories and 1 budget-rejection probe:
- Metadata views inspect VMs, Storage Accounts, VNets/NSGs/Public IPs/DNS, Managed Identities, SQL/PostgreSQL/Cosmos, Functions/App Service plans, Service Bus namespaces, Application Insights/Log Analytics, Key Vault, AKS, ACR, and Backup vaults without executing log queries or reading secret values.
- Exported resource IDs and subscription IDs are masked in all CSV and JSON outputs.
- Every mutating run uses an autogenerated lmazure-<run-id>- prefix, enforces a $0.05 default cost cap ($0.25 ceiling), and tears down all owned resources before exit.
Standard lmcode_std_v3 REST and CLI interfaces
lmazure includes all 226 lmcode_std_v3 standard signatures and the 10 standard REST and CLI SAM interfaces (RestGet, RestPost, RestPut, RestDelete, RestPatch, RestHead, RestOptions, RestHandler, CliCommand, CliOption). Programs can declare HTTP endpoints with :param path placeholders and CLI commands/flags in the same _lmcode_ block:
p = _lmcode_ cli="lmazure" install="github:lmctl-ai/lmazure@latest";
@"/containers/:name/objects/:key"
fn put_blob(x: RestExchange) -> void implements RestPut {
let c = x.param("name");
cloud.bucket_create(c);
let m = cloud.object_put(c, x.param("key"), x.body());
x.status(201);
x.json("{\"size\":" + str(m.size()) + "}");
}
@"--account"
fn opt_acct(x: RestExchange) -> void implements CliOption {
x.set("account", x.query("account"));
}
@"status"
fn cmd_status(x: RestExchange) -> void implements CliCommand {
x.send("account=" + x.get("account") + " buckets=" + str(cloud.bucket_list().len()));
}
rest_config("prefix", "/v1");
cloud.bucket_create("logs-c");
let s = rest_cli(str_split("--account devstoreaccount1 status", " "));
print(s);
end _lmcode_