创建 SQLServerLinkedService 时"Bad Request"



我试图从Python内创建Azure数据工厂的SQL Server链接服务。导入所有依赖项,并成功创建数据工厂。创建链接服务失败。

下面是我在Python中运行的伪代码:
ls_name = 'Blah'

properties = SqlServerLinkedService(
connection_string="blahblah.database.windows.net",
connect_via={"referenceName": "AutoResolveIntegrationRuntime", "type": "IntegrationRuntimeReference"},
user_name="my-user-name",
password=SecureString("my-plaintext-password")
)

ls = adf_client.linked_services.create_or_update( resource_group_name=rg_name, factory_name=df_name, linked_service_name=ls_name, linked_service=properties)

首先,如果我保持SecureString的格式如上所述,我会得到关于2个位置参数的错误,其中只需要1个,如果我完全取出密码行,我会得到"错误请求";当create_or_update函数在底部运行时。微软Python SDK文档非常缺乏。有人能帮我弄清楚如何正确地编写代码吗?

File "/usr/local/lib/python3.8/dist-packages/azure/mgmt/datafactory/operations/_linked_services_operations.py",第190行,在create_or_update抛出HttpResponseError(response=response, error_format=ARMErrorFormat)azure.core.exceptions.HttpResponseError:操作返回一个无效状态'Bad Request'

我们在创建Azure数据工厂链接服务时遇到了同样的问题;当创建一个链接服务时,你需要创建一个LinkedServiceResource:

ls_name = 'Blah'

properties = LinkedServiceResource(properties=SqlServerLinkedService(
connection_string="blahblah.database.windows.net",
connect_via={"referenceName": "AutoResolveIntegrationRuntime", "type": "IntegrationRuntimeReference"},
user_name="my-user-name",
password=SecureString("my-plaintext-password")
))

ls = adf_client.linked_services.create_or_update( resource_group_name=rg_name, factory_name=df_name, linked_service_name=ls_name, linked_service=properties)

最新更新