Skip to content

Commit

Permalink
{Batch} Set credential_scopes when creating BatchClient (#30785)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli authored Feb 12, 2025
1 parent 13c5203 commit 853ff0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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))
3 changes: 1 addition & 2 deletions src/azure-cli/azure/cli/command_modules/batch/_validators.py
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()

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

0 comments on commit 853ff0b

Please sign in to comment.