英文:
How to create Linked Service for Salesforce in Azure Synapse using Python
问题
根据要求,我正在使用Python与Azure Synapse环境一起工作。我需要创建一个Salesforce的Linked Service,以便稍后在管道中使用。
但是我遇到了一个错误,而且无法从Microsoft获取更好的文档。
简化的代码 -
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...
希望这有所帮助。
英文:
As per the requirements, I am working with Azure Synapse Environment using Python. I need to create a Linked Service for Salesforce to be utilized in pipeline later.
But I'm facing an error and couldn't get better documentations from Microsoft.
Simplified code -
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)
Please note down that I've created client object and able to get linked services and perform synapse related operations.
Error
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...
答案1
得分: 0
Finally, I am able to solve it, it was because the security_token and password should be a type of SecretBase Class (Which can't be used directly, use child class SecureString)
Example
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>')
英文:
Finally I am able to solve it, it was because the security_token and password should be a type of SecretBase Class (Which can't be used directly, use child class SecureString)
Example
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>')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论