@@ -105,17 +105,18 @@ def cf_kusto_pool(cli_ctx, *_):
105105def 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+ # Uncomment this line after SparkClient is fixed. See https://github.com/Azure/azure-cli/pull/30788
109+ # from azure.cli.core.auth.util import resource_to_scopes
108110 from azure .cli .core .commands .client_factory import get_subscription_id
109111 subscription_id = get_subscription_id (cli_ctx )
110112 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- )
113+ cred , _ , _ = profile .get_login_credentials (subscription_id = subscription_id )
115114 return SparkClient (
116115 credential = cred ,
117116 endpoint = '{}{}{}' .format ("https://" , workspace_name , cli_ctx .cloud .suffixes .synapse_analytics_endpoint ),
118- spark_pool_name = sparkpool_name
117+ spark_pool_name = sparkpool_name ,
118+ # Uncomment this line after SparkClient is fixed
119+ # credential_scopes=resource_to_scopes(cli_ctx.cloud.endpoints.synapse_analytics_resource_id)
119120 )
120121
121122
@@ -130,16 +131,15 @@ def cf_synapse_spark_session(cli_ctx, workspace_name, sparkpool_name):
130131def synapse_accesscontrol_factory (cli_ctx , workspace_name ):
131132 from azure .synapse .accesscontrol import AccessControlClient
132133 from azure .cli .core ._profile import Profile
134+ from azure .cli .core .auth .util import resource_to_scopes
133135 from azure .cli .core .commands .client_factory import get_subscription_id
134136 subscription_id = get_subscription_id (cli_ctx )
135137 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- )
138+ cred , _ , _ = profile .get_login_credentials (subscription_id = subscription_id )
140139 return AccessControlClient (
141140 credential = cred ,
142- endpoint = '{}{}{}' .format ("https://" , workspace_name , cli_ctx .cloud .suffixes .synapse_analytics_endpoint )
141+ endpoint = '{}{}{}' .format ("https://" , workspace_name , cli_ctx .cloud .suffixes .synapse_analytics_endpoint ),
142+ credential_scopes = resource_to_scopes (cli_ctx .cloud .endpoints .synapse_analytics_resource_id )
143143 )
144144
145145
@@ -160,16 +160,15 @@ def cf_graph_client_factory(cli_ctx, **_):
160160def cf_synapse_client_artifacts_factory (cli_ctx , workspace_name ):
161161 from azure .synapse .artifacts import ArtifactsClient
162162 from azure .cli .core ._profile import Profile
163+ from azure .cli .core .auth .util import resource_to_scopes
163164 from azure .cli .core .commands .client_factory import get_subscription_id
164165 subscription_id = get_subscription_id (cli_ctx )
165166 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- )
167+ cred , _ , _ = profile .get_login_credentials (subscription_id = subscription_id )
170168 return ArtifactsClient (
171169 credential = cred ,
172- endpoint = '{}{}{}' .format ("https://" , workspace_name , cli_ctx .cloud .suffixes .synapse_analytics_endpoint )
170+ endpoint = '{}{}{}' .format ("https://" , workspace_name , cli_ctx .cloud .suffixes .synapse_analytics_endpoint ),
171+ credential_scopes = resource_to_scopes (cli_ctx .cloud .endpoints .synapse_analytics_resource_id )
173172 )
174173
175174
@@ -216,16 +215,15 @@ def cf_synapse_library(cli_ctx, workspace_name):
216215def cf_synapse_client_managedprivateendpoints_factory (cli_ctx , workspace_name ):
217216 from azure .synapse .managedprivateendpoints import VnetClient
218217 from azure .cli .core ._profile import Profile
218+ from azure .cli .core .auth .util import resource_to_scopes
219219 from azure .cli .core .commands .client_factory import get_subscription_id
220220 subscription_id = get_subscription_id (cli_ctx )
221221 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- )
222+ cred , _ , _ = profile .get_login_credentials (subscription_id = subscription_id )
226223 return VnetClient (
227224 credential = cred ,
228- endpoint = '{}{}{}' .format ("https://" , workspace_name , cli_ctx .cloud .suffixes .synapse_analytics_endpoint )
225+ endpoint = '{}{}{}' .format ("https://" , workspace_name , cli_ctx .cloud .suffixes .synapse_analytics_endpoint ),
226+ credential_scopes = resource_to_scopes (cli_ctx .cloud .endpoints .synapse_analytics_resource_id )
229227 )
230228
231229
0 commit comments