如何使用Python在Azure Synapse中为Salesforce创建链接服务

cig3rfwq  于 2023-06-24  发布在  Python
关注(0)|答案(1)|浏览(110)

根据需求,我正在使用Python使用Azure Synapse环境。我需要为Salesforce创建一个链接服务,以便稍后在管道中使用。
但我面临着一个错误,不能从微软得到更好的文档。
简化代码-

from azure.synapse.artifacts import ArtifactsClient
from azure.synapse.artifacts.models import *

sf_ls_name = "testnotebookls"
sf_env_url = "https://login.salesforce.com"  
sf_user = "<username>"             
sf_pass = '<password>',
sf_security_token = '<security-token>', 
    
properties=SalesforceLinkedService(environment_url=sf_env_url,
                                           password=sf_pass,
                                           username=sf_user,
                                           security_token=sf_security_token)

client.linked_service.begin_create_or_update_linked_service(linked_service_name=sf_ls_name, properties=properties)

请注意,我已经创建了client对象,并且能够获得链接的服务并执行synapse相关操作。

错误

DeserializationError                      Traceback (most recent call last)
File c:\Users\Someuser\OneDrive - Company\Desktop\folder\folder\salesforce\.venv\lib\site-packages\azure\synapse\artifacts\_serialization.py:710, in Serializer.body(self, data, data_type, **kwargs)
    705         deserializer.key_extractors = [
    706             rest_key_case_insensitive_extractor,
    707             attribute_key_case_insensitive_extractor,
    708             last_rest_key_case_insensitive_extractor,
...
   1257         found_key = key
   1258         break
-> 1260 return data.get(found_key)

SerializationError: (', DeserializationError: (", AttributeError: \'tuple\' object has no attribute \'get\'", \'Unable to deserialize to object: type\', AttributeError("\'tuple\' object has no attribute \'get\'"))', 'Unable to build a model: (", AttributeError: \'tuple\' object has no attribute \'get\'", \'Unable to deserialize to object: type\', AttributeError("\'tuple\' object has no attribute \'get\'"))', DeserializationError(", AttributeError: 'tuple' object has no attribute 'get'", 'Unable to deserialize to object: type', AttributeError("'tuple' object has no attribute 'get'")))
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
hs1ihplo

hs1ihplo1#

最后我能够解决它,这是因为security_token和password应该是SecretBase类的一种类型(不能直接使用,使用子类SecureString)

示例

sf_ls_name = "testnotebookls"
sf_env_url = "https://login.salesforce.com"  
sf_user = "username"
sf_pass = SecureString(value='<password>')
sf_security_token = SecureString(value='<security-token>')

相关问题