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

{Synapse} Set credential_scopes when creating clients #30788

Merged
merged 1 commit into from
Feb 13, 2025
Merged
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 @@ -105,17 +105,18 @@ def cf_kusto_pool(cli_ctx, *_):
def synapse_spark_factory(cli_ctx, workspace_name, sparkpool_name):
from azure.synapse.spark import SparkClient
from azure.cli.core._profile import Profile
# Uncomment this line after SparkClient is fixed. See https://github.com/Azure/azure-cli/pull/30788
# from azure.cli.core.auth.util import resource_to_scopes
from azure.cli.core.commands.client_factory import get_subscription_id
subscription_id = get_subscription_id(cli_ctx)
profile = Profile(cli_ctx=cli_ctx)
cred, _, _ = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
subscription_id=subscription_id
)
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
return SparkClient(
credential=cred,
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
spark_pool_name=sparkpool_name
spark_pool_name=sparkpool_name,
# Uncomment this line after SparkClient is fixed
# credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
)


Expand All @@ -130,16 +131,15 @@ def cf_synapse_spark_session(cli_ctx, workspace_name, sparkpool_name):
def synapse_accesscontrol_factory(cli_ctx, workspace_name):
from azure.synapse.accesscontrol import AccessControlClient
from azure.cli.core._profile import Profile
from azure.cli.core.auth.util import resource_to_scopes
from azure.cli.core.commands.client_factory import get_subscription_id
subscription_id = get_subscription_id(cli_ctx)
profile = Profile(cli_ctx=cli_ctx)
cred, _, _ = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
subscription_id=subscription_id
)
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
return AccessControlClient(
credential=cred,
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint)
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
)


Expand All @@ -160,16 +160,15 @@ def cf_graph_client_factory(cli_ctx, **_):
def cf_synapse_client_artifacts_factory(cli_ctx, workspace_name):
from azure.synapse.artifacts import ArtifactsClient
from azure.cli.core._profile import Profile
from azure.cli.core.auth.util import resource_to_scopes
from azure.cli.core.commands.client_factory import get_subscription_id
subscription_id = get_subscription_id(cli_ctx)
profile = Profile(cli_ctx=cli_ctx)
cred, _, _ = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
subscription_id=subscription_id
)
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
return ArtifactsClient(
credential=cred,
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint)
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
)


Expand Down Expand Up @@ -216,16 +215,15 @@ def cf_synapse_library(cli_ctx, workspace_name):
def cf_synapse_client_managedprivateendpoints_factory(cli_ctx, workspace_name):
from azure.synapse.managedprivateendpoints import VnetClient
from azure.cli.core._profile import Profile
from azure.cli.core.auth.util import resource_to_scopes
from azure.cli.core.commands.client_factory import get_subscription_id
subscription_id = get_subscription_id(cli_ctx)
profile = Profile(cli_ctx=cli_ctx)
cred, _, _ = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
subscription_id=subscription_id
)
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
return VnetClient(
credential=cred,
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint)
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
)


Expand Down