Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managing the HttpClient for Cosmos #724

Closed
martinjt opened this issue Apr 27, 2021 · 6 comments
Closed

Managing the HttpClient for Cosmos #724

martinjt opened this issue Apr 27, 2021 · 6 comments

Comments

@martinjt
Copy link

I'm attempting to get CosmosDbTriggers working against the cosmos emulator. Specifically, this is a problem when the emulator runs with a different hostname (i.e. part of a docker-compose).

This details how to do disable SSL validation, however, this isn't an access level we have in the CosmosDbTrigger attribute.
https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=cli%2Cssl-netstd20#disable-ssl-validation

I can see 4 distinct ways that this could be fixed, and I'm happy to do the work if you're happy to accept the changes.

Option 1: Parameter on the Attribute for Disabling SSL Validation
Provide a bool on the attribute properties that will generate a DocumentClient with SSL validation disabled (overriding the handlers).

Option 2: Unseal/make public the ICosmosDbService interfaces
If these were opened up, we could inject our own at startup.

Option 3: Make the trigger support
This would be then specifically optimised to use against the emulator. This is potentially more work to maintain, but encapulat

Option 4: Make the DocumentClient get it's HttpClient from the services HttpClientFactory
If this uses a named httpclient from the HttpClientFactory, then we can override this in the Client factory to return one that bypasses the SSL validation. This is potentially dangerous as "Global" HttpClient changes could inadvertently affect the Trigger client without intending to.

My preference is Option 2 as it's obscure enough that it wouldn't be used by everyone as a simple property change, but powerful enough to give us an extension point for testing. It doesn't tie anything to the emulator scenario and introduces other interesting scenarios I think.

What I need to know is, would that be accepted by the maintainers? I have noticed that there's an upgrade to the V3 SDK in there, so maybe it's a fast follower after that?

@ghost ghost added the Needs: Triage 🔍 label Apr 27, 2021
@v-anvari v-anvari self-assigned this May 6, 2021
@v-anvari
Copy link

v-anvari commented May 6, 2021

cc @ealsur , Do you have any insights here, is this supported.

@ealsur
Copy link
Member

ealsur commented May 6, 2021

No, this is not possible, the internal HttpClient or configuration is not accessible.

@v-anvari
Copy link

v-anvari commented May 6, 2021

Thank you @ealsur

Hi @martinjt , Let us know if you have any further queries

@martinjt
Copy link
Author

martinjt commented May 6, 2021

Thanks both,. The question isn't whether it's possible though, it's whether you'd accept a PR that makes it possible.

There are some options in the ticket that would make it accessible using the HttpClientFactory approach that the underlying Cosmos SDK providers (which the webjobs ask is hiding right now)

@ealsur
Copy link
Member

ealsur commented May 6, 2021

@martinjt DocumentClient does not allow you to inject the HttpClient instance. For that, it would require #717 to be merged and the new extension to be released/integrated in Azure.

@ghost
Copy link

ghost commented May 11, 2021

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants