def synapse_spark_factory(cli_ctx, workspace_name, sparkpool_name): from azure.synapse.spark import SparkClient from azure.cli.core._profile import Profile 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) return SparkClient(credential=cred, endpoint='{}{}{}'.format( "https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint), spark_pool_name=sparkpool_name)
def __init__(self, synapse_dev_url, spark_pool_name, credential=None, executor_size='Small', executors=2): if credential is None: credential = DefaultAzureCredential() self.client = SparkClient(credential=credential, endpoint=synapse_dev_url, spark_pool_name=spark_pool_name) self._executor_size = executor_size self._executors = executors