feat: runtime event subscription management (ARM control-plane facade)#293
Open
we4sz wants to merge 3 commits into
Open
feat: runtime event subscription management (ARM control-plane facade)#293we4sz wants to merge 3 commits into
we4sz wants to merge 3 commits into
Conversation
…agement Adds an optional ARM management API so the real Azure.ResourceManager.EventGrid client can create, get, list and delete topic-scoped WebHook event subscriptions against the simulator at runtime, simply by repointing the client at a new managementPort. Previously subscribers could only be configured at boot. - New `managementPort` setting hosts a dedicated HTTPS listener, isolated from the per-topic data-plane pipeline (EventGridMiddleware bypass), mirroring how Azure splits management.azure.com from the topic endpoint. - EventSubscriptionsManagementController speaks the exact HTTP the SDK emits (TopicEventSubscriptions, api-version 2025-02-15), with synchronous LRO-compatible responses so WaitUntil.Completed finalizes immediately. - ARM <-> HttpSubscriberSettings mapper (WebHook only); in-memory, thread-safe copy-on-write subscriber registry seeded from config; bearer token not validated. - Runtime-created subscriptions run the normal validation handshake before delivery (outbound handshake extracted into SubscriptionValidationSender, reused by the boot-time validator). Verified with integration tests driven by the real Azure.ResourceManager.EventGrid client: full create/get/list/delete round-trip, plus an end-to-end test proving a runtime-created subscription receives published events and stops after deletion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ement The ARM control-plane facade (management-port event-subscription PUT/GET/LIST/DELETE) previously accepted only WebHook destinations — a storage-queue eventSubscriptions PUT returned 400 (UnsupportedDestination) — even though the simulator already delivers to storage queues for statically-configured subscribers (StorageQueueEventDeliveryService + RetryDeliveryBackgroundService). Extend the four runtime operations to also handle StorageQueue destinations: a runtime storage-queue subscription is upserted into topic.Subscribers.StorageQueue (inheriting the topic-level storageQueueConnectionString) and then delivered by the existing path. No webhook validation handshake (that is webhook-only). List/Get/Delete now see both subscriber kinds. The ARM destination-properties bag carries resourceId/queueName alongside the webhook endpointUrl. +4 mapper unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…t-subscription-management
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.
Summary
Adds an optional ARM control-plane (management) API so the real
Azure.ResourceManager.EventGridclient can create, get, list and delete topic-scoped WebHook event subscriptions at runtime against the simulator — simply by repointing the client at a newmanagementPort. Today subscribers can only be configured at boot viaappsettings.json; this closes the gap for apps that register/unregister subscriptions programmatically (e.g. self-registering webhooks) and want local/CI parity without touching their business code.Disabled by default — if
managementPortis not set, nothing changes.Why
Azure Event Grid has two separate APIs: the data plane (the topic endpoint that receives events — already simulated) and the control plane (ARM,
management.azure.com, where subscriptions are managed at runtime). The simulator only had the data plane, so code that manages subscriptions viaAzure.ResourceManager.EventGridhad to be stubbed out locally. This adds a faithful-enough control-plane facade so that client works unmodified.How
managementPortsetting hosts a dedicated HTTPS listener, isolated from the per-topic data-plane pipeline via anEventGridMiddlewarebypass — mirroring how Azure splitsmanagement.azure.comfrom the topic endpoint.EventSubscriptionsManagementControllerspeaks the exact HTTP the SDK emits (theTopicEventSubscriptionsoperation group, api-version2025-02-15), with synchronous, LRO-compatible responses soWaitUntil.Completedfinalizes immediately without polling.HttpSubscriberSettingsmapper (WebHook destinations), plus an in-memory, thread-safe copy-on-write subscriber registry seeded from config at boot — so the existing delivery path picks up runtime changes with no change to delivery code.SubscriptionValidationEventhandshake before they receive events. The outbound handshake was extracted fromValidateAllSubscriptionsCommandHandlerinto a reusableSubscriptionValidationSender, now shared by the boot-time validator and the management API.[JsonPropertyName]settings, CSharpier,Constants.SupportedManagementApiVersion.Scope / fidelity
Intentionally pragmatic — covers exactly what real callers use:
endpointUrlis echoed back on GET (Azure treats it write-only) so the read-modify-write update pattern works against the simulator.Config
{ "managementPort": 60100, "topics": [ { "name": "MyTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=" } ] }Testing
Driven by the real
Azure.ResourceManager.EventGridclient against an actual running simulator instance:AzureResourceManagerEventGridTest— full create / get / list / delete round-trip (proves wire compatibility + LRO finalization).RuntimeSubscriptionDeliveryTest— end-to-end: create a subscription, publish an event, assert it is delivered to the runtime-created webhook, delete, assert delivery stops.managementPortvalidation.Full suite: 924 passing, 0 failing. README updated with a "Runtime subscription management" section.
Checklist
dotnet test)dotnet build)feat:,fix:,chore:, etc.)🤖 Generated with Claude Code