Skip to content

Conversation

@akharit
Copy link
Member

@akharit akharit commented Jul 12, 2024

Use Azure Identity's TokenCredential for auth.
Remove older python package support

Will fix #332

This checklist is used to make sure that common guidelines for a pull request are followed.

Description of the change

General Guidelines

  • The PR has modified HISTORY.rst with an appropriate description of the change and a version increment.
  • [ x] The PR has supporting test coverage that confirm the expected behavior and protects against regressions, including necessary recordings.
  • Links to associated bugs, if any, are in the description.

Not checking in the recordings. Fix needed wrt some fields like lease id, session id, token etc. that are causing the test run with recording to fail.

Remove older python package support
@akharit akharit requested review from rayluo and xiangyan99 July 12, 2024 22:34
Copy link

@dylanw-oss dylanw-oss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the feature gap!

@dylanw-oss
Copy link

@akharit, thanks for fixing it! Do you have an ETA when a new package will be available?

@akharit akharit force-pushed the personal/akharit/azure_identity branch from 30826d6 to 0e5b5d5 Compare July 26, 2024 22:20
@akharit akharit merged commit 3d7df9d into master Jul 31, 2024
@akharit akharit deleted the personal/akharit/azure_identity branch July 31, 2024 19:04
@beansrowning
Copy link

Ha, well this is silly but I had been using lib.auth() for most of my applications because it worked so seamlessly for interactive auth via device code without having to install an additional dependency in azure CLI

from azure.datalake.store import lib
import polars as pl
token = lib.auth(
    tenant_id=os.environ["SP_TENANT_ID"],
    resource = 'https://storage.azure.com/'
)
# <interactive prompt for devicecode login>

# Ex. downstream, to read in data via polars
opts = {
    "tenant_id": token.token["tenant"],
    "client_id": token.token["client"],
    "token": token.token["access_token"],
    "account_name": "my_account"
}

lazy_data = pl.scan_parquet("az://some.path/here", storage_options=opts)

perusing the azure-identity documents and trying a couple dozen combinations, I finally figured out a replacement.

from azure.identity import DefaultAzureCredential

token_credential = DefaultAzureCredential(exclude_interactive_browser_credential=False, interactive_browser_tenant_id=os.environ["SP_TENANT_ID"])
access_token = token_credential.get_token('https://storage.azure.com/.default', tenant_id=os.environ["SP_TENANT_ID"])

Hopefully, this will save someone reading a couple of hours of headaches trying to get this working.

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

Successfully merging this pull request may close these issues.

Can't use Managed Identity and supply token for Auth

6 participants