Skip to content

Commit dffed0c

Browse files
committed
synapse-credential-scopes
1 parent 5814523 commit dffed0c

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

src/azure-cli/azure/cli/command_modules/synapse/manual/_client_factory.py

+16-20
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,16 @@ def cf_kusto_pool(cli_ctx, *_):
105105
def synapse_spark_factory(cli_ctx, workspace_name, sparkpool_name):
106106
from azure.synapse.spark import SparkClient
107107
from azure.cli.core._profile import Profile
108+
from azure.cli.core.auth.util import resource_to_scopes
108109
from azure.cli.core.commands.client_factory import get_subscription_id
109110
subscription_id = get_subscription_id(cli_ctx)
110111
profile = Profile(cli_ctx=cli_ctx)
111-
cred, _, _ = profile.get_login_credentials(
112-
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
113-
subscription_id=subscription_id
114-
)
112+
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
115113
return SparkClient(
116114
credential=cred,
117115
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
118-
spark_pool_name=sparkpool_name
116+
spark_pool_name=sparkpool_name,
117+
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
119118
)
120119

121120

@@ -130,16 +129,15 @@ def cf_synapse_spark_session(cli_ctx, workspace_name, sparkpool_name):
130129
def synapse_accesscontrol_factory(cli_ctx, workspace_name):
131130
from azure.synapse.accesscontrol import AccessControlClient
132131
from azure.cli.core._profile import Profile
132+
from azure.cli.core.auth.util import resource_to_scopes
133133
from azure.cli.core.commands.client_factory import get_subscription_id
134134
subscription_id = get_subscription_id(cli_ctx)
135135
profile = Profile(cli_ctx=cli_ctx)
136-
cred, _, _ = profile.get_login_credentials(
137-
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
138-
subscription_id=subscription_id
139-
)
136+
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
140137
return AccessControlClient(
141138
credential=cred,
142-
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint)
139+
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
140+
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
143141
)
144142

145143

@@ -160,16 +158,15 @@ def cf_graph_client_factory(cli_ctx, **_):
160158
def cf_synapse_client_artifacts_factory(cli_ctx, workspace_name):
161159
from azure.synapse.artifacts import ArtifactsClient
162160
from azure.cli.core._profile import Profile
161+
from azure.cli.core.auth.util import resource_to_scopes
163162
from azure.cli.core.commands.client_factory import get_subscription_id
164163
subscription_id = get_subscription_id(cli_ctx)
165164
profile = Profile(cli_ctx=cli_ctx)
166-
cred, _, _ = profile.get_login_credentials(
167-
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
168-
subscription_id=subscription_id
169-
)
165+
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
170166
return ArtifactsClient(
171167
credential=cred,
172-
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint)
168+
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
169+
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
173170
)
174171

175172

@@ -216,16 +213,15 @@ def cf_synapse_library(cli_ctx, workspace_name):
216213
def cf_synapse_client_managedprivateendpoints_factory(cli_ctx, workspace_name):
217214
from azure.synapse.managedprivateendpoints import VnetClient
218215
from azure.cli.core._profile import Profile
216+
from azure.cli.core.auth.util import resource_to_scopes
219217
from azure.cli.core.commands.client_factory import get_subscription_id
220218
subscription_id = get_subscription_id(cli_ctx)
221219
profile = Profile(cli_ctx=cli_ctx)
222-
cred, _, _ = profile.get_login_credentials(
223-
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
224-
subscription_id=subscription_id
225-
)
220+
cred, _, _ = profile.get_login_credentials(subscription_id=subscription_id)
226221
return VnetClient(
227222
credential=cred,
228-
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint)
223+
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint),
224+
credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
229225
)
230226

231227

0 commit comments

Comments
 (0)