3lc-compute-plugin-azure 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,78 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ push:
7
+ branches: [main]
8
+ workflow_call: # reused as the gate by release.yml
9
+
10
+ concurrency:
11
+ group: ci-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ # pyproject.toml routes the unreleased core and plugin SDK to the `staging` index; uv picks the index's
15
+ # credentials up from UV_INDEX_STAGING_*.
16
+ env:
17
+ UV_INDEX_STAGING_USERNAME: ${{ secrets.CLOUDREPO_READ_USERNAME || secrets.CLOUDREPO_USERNAME }}
18
+ UV_INDEX_STAGING_PASSWORD: ${{ secrets.CLOUDREPO_READ_PASSWORD || secrets.CLOUDREPO_PASSWORD }}
19
+
20
+ jobs:
21
+ ruff:
22
+ name: ruff (lint + format)
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v5
29
+ with:
30
+ version: "0.8.22"
31
+
32
+ # Ruff runs STANDALONE (uvx): linting must not require resolving the per-plugin
33
+ # dependency stacks — that would be slow and need extra indexes. Config lives in
34
+ # pyproject [tool.ruff]; pin matches 3lc-compute-plugin-sdk.
35
+ - name: Ruff lint
36
+ run: uvx --from 'ruff>=0.15,<0.16' ruff check .
37
+
38
+ - name: Ruff format check
39
+ run: uvx --from 'ruff>=0.15,<0.16' ruff format --check .
40
+
41
+ lockfile:
42
+ name: lockfile check
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+
47
+ - name: Install uv
48
+ uses: astral-sh/setup-uv@v5
49
+ with:
50
+ version: "0.8.22"
51
+
52
+ - name: Verify lockfile is up to date
53
+ run: uv lock --check
54
+
55
+ test:
56
+ name: pytest
57
+ runs-on: ubuntu-latest
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+
61
+ - name: Install uv
62
+ uses: astral-sh/setup-uv@v5
63
+ with:
64
+ version: "0.8.22"
65
+
66
+ - name: Set up Python
67
+ uses: actions/setup-python@v5
68
+ with:
69
+ python-version: "3.12"
70
+
71
+ - name: Install plugin runtime and test dependencies
72
+ run: uv sync --locked --group dev --extra azure
73
+
74
+ - name: Check distribution and manifest versions
75
+ run: uv run --no-sync python scripts/release_version.py
76
+
77
+ - name: Run tests
78
+ run: uv run --no-sync pytest -v
@@ -0,0 +1,138 @@
1
+ name: Release
2
+
3
+ # Tag (`v*`) pushes publish to public PyPI via Trusted Publishing (GitHub OIDC, no secrets).
4
+ # To cut a release: bump `version` in pyproject.toml AND every plugin's plugin.toml (they move
5
+ # together), regenerate uv.lock, update CHANGELOG.md, commit, then push
6
+ # a tag `vX.Y.Z` that matches the version.
7
+ #
8
+ # Manual runs build staging wheels for the private staging index. Publishing is an explicit input.
9
+ # Package and plugin-manifest versions are stamped together; staging builds never reach PyPI.
10
+ #
11
+ # NOTE: `uv build --no-sources` builds the plugin WHEEL only — it does not resolve or install
12
+ # the per-plugin dependency stacks. The wheel's metadata carries the SDK pin, resolved from
13
+ # the configured index at install time (the SDK's `staging` source is dropped by --no-sources).
14
+
15
+ on:
16
+ push:
17
+ tags: ["v*"]
18
+ workflow_dispatch:
19
+ inputs:
20
+ publish:
21
+ description: Publish the verified build to the private staging index
22
+ type: boolean
23
+ default: false
24
+
25
+ jobs:
26
+ # Gate the release on the full CI suite (ruff · lockfile · pytest).
27
+ test:
28
+ uses: ./.github/workflows/ci.yml
29
+ secrets: inherit
30
+
31
+ # Tag (`v*`) pushes → the real release, to public PyPI.
32
+ publish-pypi:
33
+ if: github.event_name == 'push'
34
+ needs: test
35
+ runs-on: ubuntu-latest
36
+ environment: release
37
+ permissions:
38
+ contents: write # create the GitHub Release (step below)
39
+ id-token: write # OIDC token for PyPI Trusted Publishing
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+
43
+ - name: Install uv
44
+ uses: astral-sh/setup-uv@v5
45
+ with:
46
+ version: "0.8.22"
47
+
48
+ - name: Verify tag matches pyproject version
49
+ run: |
50
+ PKG=$(uv version --frozen --output-format json | jq -r '.version')
51
+ TAG="${GITHUB_REF_NAME#v}"
52
+ echo "pyproject=$PKG tag=$TAG"
53
+ [ "$PKG" = "$TAG" ] || { echo "::error::tag $GITHUB_REF_NAME ($TAG) != pyproject version $PKG"; exit 1; }
54
+
55
+ - name: Verify plugin manifests match pyproject version
56
+ run: python scripts/release_version.py
57
+
58
+ # --no-sources strips [tool.uv.sources] so the released wheel never bakes in a dev
59
+ # index/path override (the published artifact resolves deps from PyPI).
60
+ - name: Build
61
+ run: |
62
+ uv build --no-sources
63
+ python scripts/release_version.py --wheel dist/*.whl
64
+
65
+ - name: Publish to PyPI
66
+ run: uv publish --trusted-publishing always
67
+
68
+ # Publish the tagged version's changelog section as a GitHub Release (curated notes,
69
+ # not GitHub's commit list). The Release stays editable after publish for touch-up.
70
+ - name: Extract changelog section
71
+ id: changelog
72
+ run: |
73
+ VER="${GITHUB_REF_NAME#v}"
74
+ awk -v v="$VER" '$0 ~ "^## \\[" v "\\]" {f=1; next} /^## \[/ && f {exit} f' \
75
+ CHANGELOG.md > notes.md
76
+ echo "ver=$VER" >> "$GITHUB_OUTPUT"
77
+ { echo "notes<<EOF"; cat notes.md; echo EOF; } >> "$GITHUB_OUTPUT"
78
+
79
+ - name: Create GitHub Release
80
+ uses: softprops/action-gh-release@v2
81
+ with:
82
+ tag_name: ${{ github.ref_name }}
83
+ name: ${{ github.ref_name }}
84
+ body: |
85
+ ${{ steps.changelog.outputs.notes }}
86
+
87
+ ## Installation
88
+ Available in the 3LC Hub — open the plugin shop and install it with one click; the
89
+ Hub provisions it into its own isolated environment for you. See https://docs.3lc.ai.
90
+ draft: false
91
+ generate_release_notes: false
92
+
93
+ # Manual runs exercise the same build whether or not publishing is requested.
94
+ publish-staging:
95
+ if: github.event_name == 'workflow_dispatch'
96
+ needs: test
97
+ runs-on: ubuntu-latest
98
+ environment: release
99
+ env:
100
+ UV_PUBLISH_URL: https://pypi.3lc.ai/repositories/prereleases
101
+ UV_PUBLISH_USERNAME: ${{ secrets.CLOUDREPO_USERNAME }}
102
+ UV_PUBLISH_PASSWORD: ${{ secrets.CLOUDREPO_PASSWORD }}
103
+ steps:
104
+ - uses: actions/checkout@v4
105
+
106
+ - name: Install uv
107
+ uses: astral-sh/setup-uv@v5
108
+ with:
109
+ version: "0.8.22"
110
+
111
+ - name: Verify the 'release' environment is configured
112
+ if: inputs.publish
113
+ run: |
114
+ : "${UV_PUBLISH_USERNAME:?set the CLOUDREPO_USERNAME secret}"
115
+ : "${UV_PUBLISH_PASSWORD:?set the CLOUDREPO_PASSWORD secret}"
116
+
117
+ # UTC ordering matches existing staging snapshots; run/attempt distinguish concurrent builds.
118
+ - name: Stamp distribution and plugin manifest versions
119
+ run: |
120
+ BASE=$(uv version --frozen --output-format json | jq -r '.version')
121
+ STAGED_VERSION="${BASE}.$(date -u +%Y%m%d%H%M%S).${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}"
122
+ python scripts/release_version.py --stamp "$STAGED_VERSION"
123
+
124
+ - name: Build
125
+ run: |
126
+ uv build --no-sources
127
+ python scripts/release_version.py --wheel dist/*.whl
128
+
129
+ - name: Retain build artifacts
130
+ uses: actions/upload-artifact@v4
131
+ with:
132
+ name: azure-staging-${{ github.run_number }}-${{ github.run_attempt }}
133
+ path: dist/*
134
+ if-no-files-found: error
135
+
136
+ - name: Publish to the staging index
137
+ if: inputs.publish
138
+ run: uv publish
@@ -0,0 +1,6 @@
1
+ .venv/
2
+ dist*/
3
+ __pycache__/
4
+ *.egg-info/
5
+ .pytest_cache/
6
+ .ruff_cache/
@@ -0,0 +1,134 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ### Added
6
+ - **The create answer says where the node lives.** `location` is the Azure region the VM was created in, so the
7
+ Hub's node list and history show it beside the VM size. An SDK that predates `CreateNodeResponse.location` drops it.
8
+ - `GET /infra/connection/check` names who the request's Connection acts as, read from the claims of a management
9
+ token Entra ID issues for it: a person signed in with `az login` by their sign-in name, a service principal or
10
+ managed identity as `application <client id>` (`checked: ["resolve", "get_token"]`). A Connection of a kind the
11
+ plugin does not honour answers the no-Connection 409.
12
+
13
+ ### Fixed
14
+ - **A second Create makes a new container instead of saying "Created" again.** After a create, the Name field
15
+ kept the name just used, and the server answers for an existing container as for a new one, so the next Create
16
+ made nothing and said "Created <url>" again. The field now gets a fresh name after a create, and a name already
17
+ in the list disables Create with the reason.
18
+ - **A row's Spin up launches even when its size cannot be made the default.** The default was saved without
19
+ reading the answer: a refused save still said "<size> is the default", and a failed request left the click
20
+ doing nothing. A refused save now puts the previous default back and says "Could not make <size> the default:
21
+ …", and the row's size launches either way.
22
+ - **A node runs the compute service's own build of the agent.** The VM installed the
23
+ `compute_dist_spec` setting (by default the newest `3lc-compute` on PyPI, which may predate the node
24
+ agent) instead of the version the create request pins. It now installs the request's pin, from the
25
+ extra package indexes the request names as well as PyPI, and authenticates an index the request
26
+ carries read credentials for (a staged host sends them for its staging index), so a staged
27
+ `3lc-compute` installs without a wheelhouse. The setting stays the fallback for a request with no pin.
28
+ When the request names extra indexes, `3lc>=0.0.0.dev0` is installed beside the pin, so a staged agent
29
+ that floors a core with no release yet (`3lc>=X.Y.Z.devN`) resolves: uv admits a pre-release only for a
30
+ package whose direct requirement names one, and this admits them for `3lc` alone.
31
+
32
+ ### Removed
33
+ - Every credential the plugin kept in its own settings: the `tlc_api_key`, `client_secret` and
34
+ `storage_account_key` secrets, the service principal's `tenant_id` and `client_id`, and the
35
+ `node_storage_credential` and `node_sas_hours` options. Nodes get no credential either: no `TLC_API_KEY`,
36
+ no `AZURE_STORAGE_SAS_TOKEN` minted at launch, no `AZURE_CLIENT_SECRET`; a node acts in Azure only as its
37
+ own system-assigned managed identity, and has no 3LC identity until node credentials arrive with the Config
38
+ Service. A settings file that still holds any of these keys loads with them ignored and is not rewritten;
39
+ the old values stay in it until the settings are next saved or removed by hand.
40
+ - Upgrading: GPU nodes created by an earlier version may not be deletable from the Hub without a
41
+ Connection. Delete Azure nodes before upgrading, or remove the leftovers in the Azure portal.
42
+ - The browser sign-in (`/auth/status`, `/auth/start`, `/auth/sign-out`, `/auth/subscriptions`, the
43
+ `sign_in_client_id` setting and the page's *Sign in with Microsoft*): its refresh token lived in a token
44
+ cache that is a plain file where the OS has no keyring (under `~/.IdentityService/` on a headless Linux
45
+ controller). The plugin no longer falls back to `DefaultAzureCredential` for a call that names no
46
+ Connection either.
47
+ - `GET /infra/workspaces` and `lists_workspaces` in capabilities: the plugin makes GPU nodes only, and the
48
+ host asks for workspaces only from a provider with the workspaces facet.
49
+ - `storage_account` on `POST /infra/storage`: a container goes into the configured storage account (or
50
+ creates it). To create containers in another region, clear the storage account in the settings; the next
51
+ container creates a new account there.
52
+ - The 501 answers for folder bundles and transfers on SDKs older than 0.3.3: the SDK this plugin needs
53
+ carries both engines.
54
+ - `POST /infra/nodes` no longer returns `worker_url_template`: the host reaches a node's workers through the
55
+ node agent, so the agent address is the only one a node exposes. Worker ports are no longer opened in the
56
+ security group; the request's `ports` are the browser-facing app ports, opened next to the agent port.
57
+ - The plugin no longer keeps a project root. The `project_root_url` setting, its `TLC_PROJECT_ROOT_URL`
58
+ node-environment export, the `storage.project_root_url` / `default_url` capabilities, the container
59
+ listing's `project_root` flag and `make_project_root` on `POST /infra/storage` are gone: the root a job
60
+ writes to is carried by the job and resolved by the host. A saved `project_root_url` is ignored.
61
+ - The `idle_ttl_s` setting and the plugin page's idle-teardown field: the host sends every node's
62
+ `idle_ttl_s` on create, so the setting was never read. A saved `idle_ttl_s` is ignored.
63
+
64
+ ### Changed
65
+ - **Spin up node is disabled while it cannot run, and says why.** On the line under it and in its tooltip:
66
+ "Wait while the settings load …", "Choose a VM size below …", "Choose another VM size to enable Spin up node:
67
+ <size> cannot start in eastus." and, on spot, "Choose On-demand or another VM size … has no spot price in
68
+ eastus." Readiness is left to the Hub's create flow, which offers the fix; a Hub without that flow gates on it
69
+ too. It is also disabled while its create runs, so a second click starts no second node.
70
+ - **A row's Spin up says what would enable it**: "Choose another location under Account to enable Spin up: …"
71
+ or "Choose On-demand to enable Spin up: no spot price is listed for this size in eastus."
72
+ - **Create (a container) waits for the regions and a name Azure accepts**, and says so under it: "Enter a
73
+ container name …", "Use 3 to 63 lowercase letters, digits and single hyphens, starting and ending with a
74
+ letter or digit, to enable Create." The name is marked required in the Hub's style. A bad name was refused only
75
+ by the server, and a double click could send two creates.
76
+ - **Save settings waits for the settings and an OS disk from 64 to 2048 GB**, and says so under it. The field is
77
+ marked required. A blank disk was ignored and one outside the range saved, and a Save before the settings
78
+ loaded would have written blanks over them.
79
+ - Capabilities say `requires_connection: true`: every Azure call acts through the Connection a request names, so a
80
+ host that takes its Connections from the Config Service asks for one before it creates a node.
81
+ - **Nodes are the Hub's own node list.** The page mounts `PLUGIN_API.mountNodes` (this provider's nodes and
82
+ their History ledger, the list the Deployments page draws) instead of its own renderer. That renderer is gone:
83
+ its chips, click-to-expand GPU stats and Tear down/Dismiss buttons; the Hub list carries the same per node. A Hub
84
+ that predates `mountNodes` gets a link to Deployments. The page no longer polls `/api/infra/status`, and the
85
+ capabilities refresh drops from every 5 s to every 30 s while the tab is visible (and after Spin up and Save).
86
+ The Fleet card becomes "New nodes" (readiness and Spin up), with the list below it.
87
+ - **Spin up** on the plugin page runs the Hub's node-create flow (`PLUGIN_API.createNode`, sending `node_type`)
88
+ when the Hub offers it, so the node gets a Connection (asked for when there are several) on a host that requires
89
+ one. Older Hubs keep the direct create.
90
+ - The manifest requires compute service 1.2 (`min_service_version`), the first with the `/api/infra` routes the
91
+ plugin is served through; an older host shows the plugin with an update badge.
92
+ - Lock the staged `3lc` 3.5.0.dev149866 and SDK 0.5.0.20261007121635.34.1, and require the staged core
93
+ directly (`3lc>=3.5.0.dev149866,<4.0.0`, routed to the staging index like the SDK): uv admits a pre-release
94
+ only for a direct requirement that names one.
95
+ - The plugin is an `InfrastructurePlugin` on the SDK's typed contract with the storage, catalog and legacy
96
+ owner-credentials facets. The SDK serves every `/infra/*` route and `/settings` from the plugin's typed
97
+ methods and its settings dataclass; the plugin keeps only its private region route (`/infra/regions`).
98
+ Capabilities gain `facets` and the `node_types` alias of `gpu_types`.
99
+ - Settings are one `AzureSettings` dataclass behind the SDK's `PluginSettings`: the same checks as before,
100
+ and no secret field.
101
+ - The plugin acts in Azure only through the Connection a call names. `AMBIENT` — the controller's own
102
+ `az login`, managed identity or `AZURE_*` environment, through `DefaultAzureCredential` — is the one kind
103
+ honoured today. A call that names no Connection is answered in words: capabilities with `ready: false` and
104
+ `not_ready_reason`, every management route (nodes, storage, `/infra/regions`) with 409, and the catalogs and
105
+ preflight in their answer. Cached Azure clients are keyed by the Connection. The legacy owner-credentials
106
+ calls still act with the service principal a request carries.
107
+ - `DELETE /infra/nodes/{id}` and `POST /infra/nodes/{id}/terminate` answer `{state: "terminated"}`, so the
108
+ host reads the node's state from them; the `terminated` flag is gone.
109
+ - A container created with request-carried `credentials` goes into the requester's subscription instead of
110
+ the plugin's own, and nothing about it is saved: into a storage account this plugin created there before
111
+ (tag `3lc=storage` in the resource group), else a new one. The answer's `account` and `https_url` address
112
+ the container. The container carries the request's `owner` in its metadata, accents folded to ASCII; an
113
+ owner that cannot be written as a header value is left out rather than failing the create.
114
+ - Request-carried `credentials` must name their `subscription_id` (container create, discover, terminate):
115
+ a requester's service principal never acts in the plugin's own subscription.
116
+ - `POST /infra/nodes` with request-carried `credentials` answers 400: nodes run in the plugin's own
117
+ subscription. An all-empty `credentials` object counts as none, on node and container create alike.
118
+ - An Azure failure a route did not word is answered through the SDK's `describe_error` hook, without ids,
119
+ scopes, principals, request ids or endpoints; a transfer dry run's plan, which the SDK runs, no longer
120
+ answers the raw Azure text.
121
+ - `GET /infra/gpu-catalog` and `GET /infra/cpu-catalog` answer an empty list with `error` for any failure,
122
+ never an error status.
123
+ - A storage discover answers the storage flags and an empty `regions` next to `subscription` and `storage`,
124
+ as every storage listing does.
125
+ - `GET /infra/preflight` also takes `?node_type=`; `GET /infra/datacenters` answers an empty list.
126
+ - The first container, which creates the plugin's storage account, also sets the plugin's location to the
127
+ account's.
128
+ - Require SDK `>=0.5.0,<0.6.0` and use locked POC dependencies in CI.
129
+ - Resolve the plugin SDK from the `staging` index declared in `pyproject.toml`; set
130
+ `UV_INDEX_STAGING_USERNAME` / `UV_INDEX_STAGING_PASSWORD` locally (CI: the `CLOUDREPO_READ_*` secrets,
131
+ falling back to `CLOUDREPO_*`).
132
+ - Add CI-gated manual builds with opt-in private CloudRepo publication.
133
+ - Validate matching distribution and plugin-manifest versions before private or tagged PyPI publication.
134
+
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.5
2
+ Name: 3lc-compute-plugin-azure
3
+ Version: 0.1.1
4
+ Summary: Microsoft Azure infrastructure plugin for the 3LC compute service: disposable GPU virtual machines and Blob containers as storage.
5
+ License: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: 3lc-compute-plugin-sdk<0.6.0,>=0.5.0
8
+ Requires-Dist: 3lc<4.0.0,>=3.5.0.dev149866
9
+ Provides-Extra: azure
10
+ Requires-Dist: azure-identity>=1.17; extra == 'azure'
11
+ Requires-Dist: azure-mgmt-compute>=30; extra == 'azure'
12
+ Requires-Dist: azure-mgmt-network>=25; extra == 'azure'
13
+ Requires-Dist: azure-mgmt-resource-subscriptions>=1.0.0; extra == 'azure'
14
+ Requires-Dist: azure-mgmt-resource>=23; extra == 'azure'
15
+ Requires-Dist: azure-mgmt-storage>=21; extra == 'azure'
16
+ Requires-Dist: azure-storage-blob>=12.19; extra == 'azure'
17
+ Requires-Dist: requests>=2.31; extra == 'azure'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # 3lc-compute-plugin-azure
21
+
22
+ Microsoft Azure infrastructure plugin for the 3LC compute service (`kind = "infrastructure"`). It creates
23
+ disposable **GPU virtual machines** in your Azure subscription for the Hub and tears them down, and it
24
+ offers **Azure Blob containers** as storage. It answers the plugin SDK's typed `InfrastructurePlugin`
25
+ contract, so the Hub drives it as it drives every other provider.
26
+
27
+ - **GPU nodes** — Azure VMs (`Standard_NC…`, `ND…`, `NV…` sizes) running the 3LC node agent; the host
28
+ dispatches training jobs to them and deletes them when idle. The image is the Data Science VM (Ubuntu
29
+ 22.04, NVIDIA drivers and CUDA preinstalled), `image` in the settings overrides it (a URN or an image id).
30
+ Each node gets a static public IP, a NIC and an OS disk that are deleted with the VM, a system-assigned
31
+ managed identity, no password and a throwaway SSH key (port 22 is never opened). A managed network
32
+ security group (`3lc-gpu-nodes`) opens the agent port 8800 and the app ports the host asks for (8888) to this
33
+ controller's current egress IP only; SDK workers listen on the node's loopback and are reached through the
34
+ agent's proxy, so no worker port is opened. There is one rule per controller (replaced on every launch, so a
35
+ moved controller never locks itself out and two controllers sharing a group leave each other alone).
36
+ Azure's default rules deny everything else inbound. Nodes attach to a managed VNet (`3lc-gpu-nodes`,
37
+ 10.42.0.0/16) unless `subnet_id` names one of yours.
38
+ - **Storage** — one storage account (`storage_account`); its containers are the plugin's storage, as
39
+ `abfs://<container>/<path>` URLs, which is the form `tlc` reads (it takes the account from
40
+ `AZURE_STORAGE_ACCOUNT_NAME`). Nodes land in the storage account's region.
41
+
42
+ **Credentials.** The plugin keeps no credential in its settings and acts in Azure only through the
43
+ **Connection** a call names (the host sends its binding; the SDK resolves it before the plugin runs).
44
+ `AMBIENT` is the one kind honoured today: this deployment's own identity through `DefaultAzureCredential` —
45
+ `az login`, a managed identity or the `AZURE_*` environment on the controller. The plugin never falls back to
46
+ that identity for a call that names no Connection: such a call is answered with "No Connection named — Azure
47
+ acts only through a Connection, and this deployment's own identity (AMBIENT) is the one kind honoured today"
48
+ — capabilities with `ready: false` and that sentence as `not_ready_reason`, every management route with 409,
49
+ and the catalogs and preflight in their answer, as they carry every failure. Cached Azure clients are keyed
50
+ by the Connection's kind and id, so one Connection never reuses another's. The one other path is the legacy
51
+ owner-credentials facet: a request that carries a service principal
52
+ (`credentials: {tenant_id, client_id, client_secret, subscription_id}`) acts in that subscription with it,
53
+ and nothing it carries is stored. `subscription_id` names the plugin's subscription
54
+ (`AZURE_SUBSCRIPTION_ID` in the environment when empty); `resource_group` (default `3lc-compute`) is created
55
+ in `location` when missing.
56
+
57
+ A settings file saved by an earlier version that kept credentials (`tlc_api_key`, `tenant_id`, `client_id`,
58
+ `client_secret`, `sign_in_client_id`, `storage_account_key`, `node_storage_credential`, `node_sas_hours`)
59
+ still loads: those keys are ignored. Their old values — plaintext secrets among them — stay in
60
+ `~/.3lc-plugin-configs/azure/default.json` until the settings are next saved (a save writes only the current
61
+ fields) or you remove them by hand. The browser sign-in is gone too: `signin.json` next to the settings and
62
+ azure-identity's `3lc-azure` token cache (kept by msal-extensions: under `~/.IdentityService/` as a plain file
63
+ on a headless Linux controller, in the OS keyring elsewhere) are no longer read; delete them to forget that
64
+ sign-in.
65
+
66
+ **Upgrading.** GPU nodes created by an earlier version may not be deletable from the Hub without a
67
+ Connection: delete your Azure nodes before upgrading, or remove the leftovers (VM, NIC, public IP, OS disk,
68
+ all named `3lc-<node id>…`) in the Azure portal.
69
+
70
+ **What the plugin's identity needs.** To run nodes: `Microsoft.Compute/*`, `Microsoft.Network/*` on the
71
+ resource group (Contributor on the group is the simple answer), `Microsoft.Compute/skus/read` and
72
+ `Microsoft.Compute/locations/usages/read` for the size table. For storage: Storage Account Contributor on the
73
+ account (or `listKeys`), or Storage Blob Data Contributor plus Storage Blob Delegator when the plugin signs
74
+ links with a user delegation key instead of the account key. The plugin never assigns roles itself.
75
+
76
+ ## Trust model
77
+
78
+ - The node's environment carries no credential: the storage account name, `extra_env` (not for secrets) and
79
+ the agent's own control values (`TLC_NODE_*`) from the host. It is the same trust class as the VM itself:
80
+ anything running on the VM can read its own environment, and Azure's Instance Metadata Service hands custom
81
+ data back to any process on the VM. The agent gives its workers everything but its own control secrets.
82
+ - **A node has no 3LC identity and no Blob credential.** It acts in Azure only as its own system-assigned
83
+ managed identity, which is created with the VM and has no role until one is granted to it; the plugin grants
84
+ none. Until node credentials arrive with the Config Service, a node cannot sign in to 3LC, and it reads and
85
+ writes Blob storage only if its identity has been given Storage Blob Data Contributor on the account.
86
+ - **Self-termination.** When idle, the agent runs `/opt/3lc-agent/terminate.py`: IMDS names the VM, and
87
+ `DefaultAzureCredential` — the VM's own system-assigned managed identity — asks Compute to delete it
88
+ (`force_deletion`; disk, NIC and IP go with it). That needs **Virtual Machine Contributor** on the resource
89
+ group for the VM's identity. Without it the agent exits and the VM keeps billing, which is why the
90
+ controller's idle teardown and heartbeat handling are the other two layers.
91
+ - Browser uploads and downloads use per-blob SAS links (one hour; upload links allow create + write only,
92
+ download links read only). Server-side copies pass the source as a URL with a one-hour read SAS.
93
+ - Error text shown to people has subscription, tenant and object ids, resource scopes, principals, request
94
+ ids and endpoints removed; the code and the action stay. The plugin's `describe_error` does this for every
95
+ failure the SDK answers, a transfer or bundle job's included. Request values (container and account names,
96
+ locations, GUIDs, VM sizes and names, resource ids, environment keys and values) are checked before they
97
+ reach Azure and answer 400 with what to change.
98
+
99
+ ## Routes
100
+
101
+ `AzurePlugin` is an `InfrastructurePlugin` with the SDK's **storage**, **catalog** and legacy
102
+ **owner-credentials** facets (`capabilities.facets: ["storage", "catalog", "legacy-owner-credentials"]`). The
103
+ SDK mounts the `/infra/*` routes and `/settings` from its typed methods and its settings dataclass; the plugin
104
+ adds its own region route. A call that names no Connection is answered 409 with the sentence under
105
+ *Credentials* by every route below except these: `GET /infra/capabilities` and `GET /ui` (200; capabilities
106
+ report `ready: false` with `not_ready_reason`), `/settings`, the catalogs and preflight (200 with the sentence
107
+ in their answer), `/infra/datacenters`, and the legacy owner-credentials calls
108
+ (`POST /infra/nodes/{id}/terminate`, `POST /infra/storage/discover`, and `POST /infra/storage` with
109
+ `credentials`), which act with the service principal they carry. Everything is mounted under `/api/plugins/azure/`; the host forwards
110
+ storage routes as `/api/infra/storage/azure/...`.
111
+
112
+ | Route | What it does |
113
+ | --- | --- |
114
+ | `GET /infra/capabilities` | `provider: "azure"`, `ready` (never true for a call that names no Connection; `not_ready_reason` then says so), `node_types` (and `gpu_types`) = the configured VM sizes, `flavors: ["gpu"]`, `pricing: ["on_demand", "spot"]`, `region`, `credential_keys`, `missing_fields` (each with `help` and `href`), `facets`, and `storage` (`kind: "bucket"`, `label: "Azure Blob container"`, `creatable/upload/browse/download/bundle/delete/transfer/rename`) |
115
+ | `POST /infra/nodes` | Create a VM: `{node_id, node_type (or gpu_type; a VM size), token, env, ports, idle_ttl_s, pricing?, owner?, project_storage?}` → `{provider_id, agent_url, pricing}`; `agent_url` is `http://<public ip>:8800`; `ports` are the browser-facing app ports opened next to the agent port. A request whose `credentials` carry any value is refused: nodes run in the plugin's own subscription |
116
+ | `GET /infra/nodes/{id}` | `{state, detail}` with state `pending`, `running`, `exited`, `gone` (from the instance view); `?diagnostics=true` answers the same |
117
+ | `DELETE /infra/nodes/{id}` | Delete the VM (not found counts as done) → `{state: "terminated"}`; leftovers are removed once the VM is gone |
118
+ | `POST /infra/nodes/{id}/terminate` | Delete a VM in another subscription with the `credentials` in the body (a service principal and its `subscription_id`) |
119
+ | `GET /infra/gpu-catalog` | GPU VM sizes in the location with vCPUs, RAM, GPU model and VRAM, family quota, restrictions, pay-as-you-go and spot prices (`?region=` overrides); a failure is an empty list with `error` |
120
+ | `GET /infra/cpu-catalog` | CPU sizes with live prices (`?region=` overrides); a failure is an empty list with `error` |
121
+ | `GET /infra/datacenters` | Always empty: Azure places a VM in the location |
122
+ | `GET /infra/preflight` | Credential, offering and family quota checks before a VM is requested (`?node_type=` or `?gpu_type=`) |
123
+ | `GET /infra/storage` | The account's containers with region, by name; `account`; `regions` = the account's region (every region when no account exists yet) |
124
+ | `POST /infra/storage` | Create a container `{name, region?}` in the plugin's storage account; the first container creates the account (StorageV2, LRS, HTTPS only, no public access) and sets the plugin's account and location. With `credentials` (a service principal and its `subscription_id`; an all-empty object counts as none) the container is created in the requester's subscription, in a storage account this plugin tagged `3lc=storage` in the resource group there, else a new one; the answer's `account` and `https_url` address it, and nothing is saved. The request's `owner` goes into the container's metadata when it can be written as ASCII |
125
+ | `DELETE /infra/storage/{container}` | Delete an empty container; one with blobs is a 409 |
126
+ | `POST /infra/storage/discover` | The containers in the requester's subscription, with the `credentials` in the request (a service principal and its `subscription_id`) |
127
+ | `GET /infra/storage/list?url=abfs://c/prefix` | One level: sub-folders and blobs (`truncated` past 500) |
128
+ | `POST /infra/storage/presign` | `mode: "upload"` (default): PUT URLs for `files: [{path, size, content_type}]` with the `x-ms-blob-type: BlockBlob` header the browser must send; `mode: "download"`: GET URLs saved as attachments |
129
+ | `POST /infra/storage/delete` | Delete files and folders under a prefix, counted first (`dry_run`); the open folder and `..` paths are refused |
130
+ | `POST /infra/storage/transfer`, `GET/DELETE …/transfer/{id}` | Copy, move or rename inside the account as a job (server-side Copy Blob; SDK `TransferRegistry`) |
131
+ | `POST /infra/storage/bundle`, `GET/DELETE …/bundle/{id}` | Zip a folder in the background to `.3lc/downloads/` with a 24-hour link (SDK `BundleRegistry`) |
132
+ | `GET/POST /settings` | The plugin page's settings (no secrets; `extra_env` as `extra_env_keys`) |
133
+ | `GET /infra/regions` | Private: the subscription's regions `[{id, name}]` and the current one |
134
+
135
+ **Settings.** One `AzureSettings` dataclass behind the SDK's `PluginSettings`, with no secret field. The
136
+ location, resource group, image, pricing model and spot eviction policy are checked before they are saved and
137
+ an empty value keeps the current one; the subscription id, the storage account, subnet and network security
138
+ group ids are checked and may be cleared. `extra_env` keys must be environment variable names, and its values
139
+ are not for secrets (they ride the VM's custom data). Capabilities prompt for what is missing in the
140
+ dataclass's field order: the subscription id, the storage account. A node's idle teardown is the host's `idle_ttl_s`; the
141
+ plugin keeps no setting for it. A settings file that exists but does not parse answers 409 instead of being
142
+ read as defaults.
143
+
144
+ ## Pricing
145
+
146
+ A GPU node is pay-as-you-go or spot: `pricing: "on_demand" | "spot"` on `POST /infra/nodes`, the `pricing`
147
+ setting when the request names none, and `capabilities.pricing` tells the host it may offer spot. A spot VM is
148
+ created with `priority: Spot`, the configured eviction policy (`Delete` by default — nothing keeps billing;
149
+ `Deallocate` keeps the disk, billed) and `max_price: -1`, which means the current spot price with the
150
+ pay-as-you-go price as the only cap. Azure may evict a spot VM with thirty seconds' notice; the node dies, the
151
+ job running on it fails, and it has to be started again. A launch that finds no capacity (`AllocationFailed`,
152
+ `SkuNotAvailable`, `OverconstrainedAllocationRequest`) fails with a sentence naming the size, the location and
153
+ the code; a quota refusal points at Subscriptions → Usage + quotas. Prices come from the public
154
+ [Retail Prices API](https://prices.azure.com/api/retail/prices) (Linux meters; Windows and Low Priority meters
155
+ skipped; the `Spot` meter is the spot price), cached an hour per size and region.
156
+
157
+ ## Dev setup
158
+
159
+ ```bash
160
+ uv sync --extra azure
161
+ uv run pytest
162
+ uvx --from 'ruff>=0.15,<0.16' ruff check . && uvx --from 'ruff>=0.15,<0.16' ruff format --check .
163
+ ```
164
+
165
+ Every Azure client, the Blob service, the Retail Prices API and the IP echo are fakes in the tests; nothing
166
+ reaches Azure. The SDK's conformance kit (`assert_conformant`) runs against the plugin with and without the
167
+ node lifecycle.
168
+
169
+ Point a dev compute service at this checkout via `TLC_COMPUTE_EXTERNAL_PLUGIN_DIRS=.../src`, open the Azure
170
+ page in the Hub and enter the subscription id. The plugin page's own calls name no Connection, so it shows the
171
+ sentence above and its management calls answer 409; nodes created through the Hub with this deployment's own
172
+ identity (AMBIENT) act through `az login` on the controller. The tests stand an AMBIENT Connection in to
173
+ exercise the provider.
174
+
175
+ ## Host changes needed
176
+
177
+ None for the routes and shapes: the Hub reads `storage.label`, the capability flags, `regions`, node records
178
+ and `pricing` exactly as the AWS plugin reports them. One cosmetic gap noticed while mirroring:
179
+
180
+ - The Data page's upload progress and error text say "bucket"; with `storage.label` it could say "container".
181
+
182
+ ## Phase 2
183
+
184
+ 1. **Workspaces on Azure** — a CPU VM running the person's Object Service and compute service (Caddy, TLS
185
+ under sslip.io names), the `flavor: "workspace"` branch, `workspace_credentials`, and the workspace wizard's
186
+ storage step; `cpu-catalog` and `regions` exist for it already.
187
+ 2. **Automatic role assignment for nodes** — grant the VM's managed identity Virtual Machine Contributor on
188
+ the resource group and Storage Blob Data Contributor on the storage account at launch
189
+ (`azure-mgmt-authorization`), so idle nodes delete themselves and reach Blob storage with no credential
190
+ on the VM.
191
+ 3. **More than one storage account** — list containers across the 3LC-tagged accounts of the resource group
192
+ and resolve `abfs://` URLs to their account; today one account per plugin.
193
+ 4. **Marketplace image plans and the NVIDIA driver extension** — `plan` on the VM for images that need one, and
194
+ the `NvidiaGpuDriverLinux` extension for plain Ubuntu images.
195
+ 5. **Spot eviction notice** — read the Scheduled Events endpoint on the node so the agent can fail the job
196
+ cleanly before Azure evicts the VM.
197
+ 6. **Placement scores and zone selection** — Azure's Spot Placement Scores API for the "availability" column,
198
+ and zonal placement for sizes that require it.
199
+ 7. **Multipart browser uploads** — block uploads for files above the single-request ceiling (5000 MiB), and
200
+ Blob Batch for large deletes across containers.
201
+ 8. **Live e2e** — run the plugin against a real subscription (the API-drift gate the fakes cannot be).
202
+
203
+ ## Staging development and publishing
204
+
205
+ The plugin SDK 0.5 and the 3.5 core it is locked against are not on PyPI yet; `pyproject.toml` routes both
206
+ to the private `staging` index
207
+ (CloudRepo `prereleases`). Set that index's credentials in your shell (keep them out of source files):
208
+
209
+ ```bash
210
+ export UV_INDEX_STAGING_USERNAME="<account email>"
211
+ export UV_INDEX_STAGING_PASSWORD="<read token>"
212
+ uv sync --locked --group dev --extra azure
213
+ uv run --no-sync pytest
214
+ ```
215
+
216
+ The Release workflow builds verified artifacts on manual runs. `publish=true` uploads them
217
+ to the private staging index; publishing is disabled by default. The timestamp, run and
218
+ attempt suffix stamps the distribution and manifest together.
219
+
220
+ The separate `v*` tag path provides PyPI Trusted Publishing plumbing. Configure the PyPI
221
+ project's trusted publisher before using that path; no public release is needed while the SDK is staged.