Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.44k stars 2.75k forks source link

AzureML | SDKv2 | MLClient | Pass proxy variables #36381

Open IliasAarab opened 1 month ago

IliasAarab commented 1 month ago

Is it possible to add proxy/ssl config to the MLClient?

from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential

ml_client = MLClient(
subscription_id=subscription_id,
resource_group_name=resource_group,
credential=DefaultAzureCredential(),
)
github-actions[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github.

mccoyp commented 1 month ago

Hi @IliasAarab, thank you for opening an issue. Proxy and pipeline configuration can be set in SDK clients through the mechanisms described in our Core client library developer reference documentation.

For proxies specifically, you can either use the HTTP_PROXY and HTTPS_PROXY environment variables or pass a azure.core.pipeline.policies.ProxyPolicy instance to your client constructor in a proxy_policy keyword argument.

github-actions[bot] commented 1 month ago

Hi @IliasAarab. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

IliasAarab commented 1 month ago

@mccoyp thank you for the guidance! I'm still having an issue when trying to initialize an MLClient instance when passing a credential object to the constructor:

from azure.ai.ml import MLClient
from azure.identity import InteractiveBrowserCredential
from azure.core.pipeline.policies import ProxyPolicy

proxies = {"http": "myproxy", "https":  "myproxy"}
proxy_policy = ProxyPolicy()
proxy_policy.proxies = proxies

credential = InteractiveBrowserCredential()
client = MLClient.from_config(
    credential=credential,
    proxy_policy=proxy_policy
)
client.compute.get("is-cpu")
InteractiveBrowserCredential.get_token failed: Authentication failed: <urllib3.connection.HTTPSConnection object at 0x000001F13531D810>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

ClientAuthenticationError: Authentication failed: <urllib3.connection.HTTPSConnection object at 0x000001F13531D810>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

Everything works fine when I set my proxies as global env variables. (but that's not a viable option for all use cases).

When I first set global env variables for the initial interactive authentication, and then continue work with the client (having passed proxy_policy) with global env variables deleted, everything still works fine. So the current problem resides with the initial auth.

Also, wondering how to pass requests_ca_bundle to the ProxyPolicy or to disable ssl verification (e.g., verify=False.


/unresolve

mccoyp commented 1 month ago

@IliasAarab thank you for the information. @xiangyan99, would you be able to take a look?

IliasAarab commented 1 month ago

Hi @xiangyan99, any updates on this ?

xiangyan99 commented 1 month ago

Could you help to clarify your request?

In your case, it failed because InteractiveBrowserCredential does not support proxy.

Do you ask to add proxy support for InteractiveBrowserCredential?

github-actions[bot] commented 1 month ago

Hi @IliasAarab. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

IliasAarab commented 1 month ago

@xiangyan99 yes I guess that's what it boils down to. Or alternatively, whether there is another Credential object similar to InteractiveBrowserCredential that supports proxies? Otherwise, I am confused as what the added value is of the proxy_policy arg into MLClient as the client also needs a Credential instance.

IliasAarab commented 1 month ago

@xiangyan99 let me know if there is an update please.

github-actions[bot] commented 3 weeks ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github.

IliasAarab commented 3 days ago

Please let me know if there is any update, or a decision on some course of action.