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:

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:

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_