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

{Batch} Set credential_scopes when creating BatchClient #30785

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def batch_data_client_factory(cli_ctx, kwargs):
if not token_credential and not account_key:
from azure.cli.core._profile import Profile
profile = Profile(cli_ctx=cli_ctx)
resource = cli_ctx.cloud.endpoints.batch_resource_id
token_credential, _, _ = profile.get_login_credentials(resource=resource)
token_credential, _, _ = profile.get_login_credentials()

if account_key:
from azure.core.credentials import AzureNamedKeyCredential
Expand All @@ -64,4 +63,6 @@ def batch_data_client_factory(cli_ctx, kwargs):
account_endpoint.startswith('http://')):
account_endpoint = 'https://' + account_endpoint

return BatchClient(credential=credential, endpoint=account_endpoint.rstrip('/'))
from azure.cli.core.auth.util import resource_to_scopes
return BatchClient(credential=credential, endpoint=account_endpoint.rstrip('/'),
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.batch_resource_id))
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ def validate_client_parameters(cmd, namespace):
# check to see if we are using the default credentials
from azure.cli.core._profile import Profile
profile = Profile(cli_ctx=cmd.cli_ctx)
resource = cmd.cli_ctx.cloud.endpoints.batch_resource_id
token_credential, _, _ = profile.get_login_credentials(resource=resource)
token_credential, _, _ = profile.get_login_credentials()
Copy link
Member Author

Choose a reason for hiding this comment

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

token_credential is not actually used to create a client, so specifying the resource is unnecessary.


# if not we query for the account key
if token_credential is None:
Expand Down