Repository navigation
Add Aspire recording commands via DevProxy API client - #55
hansmbakker wants to merge 4 commits into
Conversation
|
I enabled |
|
I see the API key authorization still needs to be added |
|
Also it is still possible to add icons to the commands |
Will do! Thank you! I appreciate you working with us |
- Generate the Dev Proxy API token in the AppHost and pass it to Dev Proxy via DEV_PROXY_API_TOKEN instead of reading token files from disk - Call the API with HttpClient + System.Net.Http.Json and drop Refit - Keep the API client types and command extension internal - Disable the commands unless the resource is running and add icons - Remove assets/openapi.yaml Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Thanks again for picking this up, @hansmbakker. Using custom resource commands is exactly the right way to do this, and your work made it easy to see what we need. I pushed a commit to your branch (dd80162) with a few changes. Here's what changed and why: API token Instead, we'll add support in Dev Proxy for a HTTP client Public API Dashboard OpenAPI spec Next steps |
|
@waldekmastykarz Thank you so much for your help and for thinking along! I like the I understand your preference for avoiding a dependency, but I did like having a (generated) API client rather than manually coded HttpClient calls - to me the code looked a bit easier to read, and I think it would help with adding commands for the other interactive features (fetching the logs, generating a JWT, sending a mock request). |
|
I think we should make it easy for folks to generate clients that communicate with the Dev Proxy API, but I was hesitant including a dependency that would end up in everyone's applications. Since we own the API, we can take the "hit" and implement the client ourselves. |
There was a problem hiding this comment.
🟡 Changes recommended
The linked Dev Proxy implementation ignores the supplied token environment variable, causing both recording commands to fail authentication.
1 open issue
What changed in this PR
This PR adds Aspire dashboard controls for Dev Proxy recording, addressing the recording workflow raised in issue #54.
Changes:
- Registers start and stop recording commands for executable and container resources.
- Sends authenticated API requests with endpoint checks and error handling.
- Documents the commands and their token-support requirement.
| File | Description |
|---|---|
| README.md | Documents recording commands and required token support. |
| DevProxy.Hosting/DevProxyResourceBuilderExtensions.cs | Enables recording commands for both resource types. |
| DevProxy.Hosting/DevProxyCommandExtensions.cs | Implements command registration, token setup, and recording API requests. |
Review effort: Balanced
| var apiToken = Convert.ToHexString(RandomNumberGenerator.GetBytes(32)); | ||
|
|
||
| builder.WithEnvironment(ApiTokenEnvironmentVariable, apiToken); |


This is a suggested approach for #54.
It defines custom Aspire resource commands that will make calls to the DevProxy API.
An OpenAPI spec was generated from https://github.com/dotnet/dev-proxy/blob/main/DevProxy/ApiControllers/ProxyController.cs and based on that the DevProxyApiClient was generated.
An interface was defined to have both resource types (executable and container-based) behave the same since they expose the same API.
Currently the WithDevProxyRecordingCommands is called always.