feat(core,azure): poll Azure ARM long-running operations#341
Open
Joehoel wants to merge 3 commits into
Open
Conversation
Core gains a `longRunning` Http trait and an optional `pollLongRunning` client hook: when an operation carries the trait and the server returns a 201/202 ack, core delegates to the hook and decodes its resolved body through the output schema. Azure implements the hook as an Effect-native ARM poller (Effect.repeat + Schedule honoring per-response Retry-After; Data.taggedEnum strategy + provisioning-state classification via Match). Supports azure-async-operation, location, and original-uri final-state resolution. Terminal Failed/Canceled surfaces as AzureLongRunningOperationFailed (uncategorized, so it is not auto-retried). Tested account-free with a scripted fake HttpClient (incl. Retry-After via TestClock).
The shared Swagger emitter now detects `x-ms-long-running-operation` (+
`-options.final-state-via`) on each operation and bakes
`longRunning: { finalStateVia }` into the generated `T.Http` trait — the
same place `apiVersion` is injected. Regenerated all Azure services: 3783
long-running operations across 182 service files now poll to completion.
The ARM `final-state-via: location` for a resource create points to an
operationResults URL that returns only a stub (`{id, name, type}`); the
provisioned resource lives at the original request URI. Mirror
@azure/core-lro's `findResourceLocation`: PUT/PATCH (and any `original-uri`
op) resolve via the original URI; POST/DELETE use the terminal poll body.
Caught by a live smoke test (real storage-account create on the non-profit
account, free Standard_LRS, torn down) — now included.
3a7679e to
2ed7c35
Compare
LuuOW
reviewed
Jun 17, 2026
LuuOW
left a comment
There was a problem hiding this comment.
Technical audit: code patterns and implementation verified for alignment with modern software engineering standards.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Azure ARM long-running-operation (LRO) polling so async mutating operations resolve to the provisioned resource instead of the intermediate
202ack.ARM PUT/PATCH/POST/DELETE operations frequently return
201/202and finish asynchronously. Before this change the SDK decoded that ack body and returned it — so e.g.StorageAccountsCreatehanded back an un-provisioned resource. Now the operation polls to completion transparently.How it works
Two layers, keeping
coreprotocol-agnostic and the ARM specifics inazure:longRunningmarker on theHttptrait and an optionalpollLongRunningclient hook. When an operation carries the marker and the server returns201/202, the core client delegates to the hook and decodes its resolved body through the output schema.packages/azure/src/lro.ts):Effect.repeat+Schedulehonoring each response'sRetry-After, aData.TaggedEnummonitor strategy, and provisioning-state classification viaMatch. It supports theAzure-AsyncOperation/Operation-LocationandLocationmonitor styles, and resolves the final resource per ARM's rules (mirroring@azure/core-lro'sfindResourceLocation):PUT/PATCHresolve from the original request URI;POST/DELETEuse the terminal poll body. A terminalFailed/Canceledsurfaces as a typedAzureLongRunningOperationFailed(uncategorized, so it is not auto-retried).Generated change
The shared Swagger emitter now detects
x-ms-long-running-operation(+-options.final-state-via) and bakeslongRunning: { finalStateVia }into each operation'sT.Httptrait — the same placeapiVersionis injected. Regenerated all Azure services: 3783 long-running operations across 182 service files now poll to completion.Testing
packages/core/test/lro-delegation.test.ts) and the ARM poller (packages/azure/test/lro-poller.test.ts) driven by a scripted fakeHttpClient, including per-pollRetry-AfterviaTestClock.packages/azure/test/storage-lro.test.ts) that creates a realStandard_LRSstorage account, polls it to completion, and tears it down — verified green end-to-end against a live subscription.