-
Notifications
You must be signed in to change notification settings - Fork 8
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
Automatically inherit Azure credentials from environment #267
Comments
I'm on my phone but you should be able to set |
We could implement something like https://developmentseed.org/obstore/latest/api/store/aws/#obstore.store.S3Store.from_session for Azure that uses that azure Python library you mentioned. (I'm less familiar with azure myself) |
Polars provides a credential_provider argument as a standard interface for managing arbitrary credentials. It accepts a function with a specified return signature, which allows you to map in arbitrary credentials. Polars also provides a default wrapper class for the the different clouds to avoid needing to create your own custom This gets us half way. If I know I'm using Azure, I can initialise an Azure credential, then pass it in to the The second step is to setup defaults for each provider. For example in Polars, if it detects that a given URL is an Azure URL, then it automatically sets up a I'm most familiar with, but I'm guessing that this is generalisable to some extent, as Polars seems to be attempting to generalise for the common default case. |
Ok now I'm back at my computer. First, thanks for the issue! Especially with Azure I'm not as familiar.
I know Polars does use
We do have some docs on how environment variables are found and applied.
I think you can set
Yes, we'll have something similar soon: #234. The PR works (with either sync or async callbacks!), I just haven't implemented the caching yet (so that credentials aren't attempted to be fetched on every request)
As mentioned above, we can add something like
Does this mean that any time you use any Azure data sources, you need to have
In #234 we can also add
I'm inclined for the defaults to stick to whatever |
Regarding Regarding environment variables, thanks for the link. I can see that you automatically detect the standard I believe that The missing piece for me is automatically trying DefaultAzureCredential has a few more resolution steps than this, but this would at least solve my own usecase, without needing One option, which would avoid the hard requirement for |
Any env variable starting with
I think you should consider making an upstream issue in the
I don't think we want to automatically change behavior depending on whether a dependency is installed. But based on the polars API, I prototyped an opt-in API, which you can see in #269 and #234: import obstore as obs
from obstore.google.auth import GoogleAuthAsyncCredentialProvider
credential_provider = GoogleAuthAsyncCredentialProvider()
store = GCSStore("bucket", _credential_provider=credential_provider)
list_result = await obs.list(store).collect_async() We could do something similar for |
With Polars, which also uses the
object_store
crate, I can authenticate to Azure automatically, based on credentials found in my environment.For example, if a client secret environment variable exists, it will use that. If I am authenticated with Azure CLI, it will use that.
This means that my code looks like this, and works both for local testing and on the server with environment credentials:
This is handy, because it means that I can write code which is completely agnostic to the location of the file.
The code above works just as well if I swap out the filepath for a local file, because I didn't need to specify any Azure-specific parameters.
obstore
is getting much closer to this ideal.However, for Azure at least, I still need to give it a hint to detect my Azure CLI credentials:
Ideally, I would be able to do this instead:
Note that Polars uses azure.identity.DefaultAzureCredential as the default credential provider for Azure, as it automatically finds available credentials. This ensures consistent credential resolution across tools.
(It's not a hard dependency on
azure.identity
. An import error is only raised if you try to use Azure credential functionality and don't haveazure.identity
installed.)The text was updated successfully, but these errors were encountered: