可以从SQL Server调用Azure Pipeline吗?

huangapple go评论96阅读模式
英文:

Is it Possible to Call an Azure Pipeline from SQL Server

问题

类似于 'sp_start_job',是否有一种方法可以通过存储过程从SQL Server执行Data Factory管道?

我尝试进行了研究,似乎一切都指向在Azure Data Factory内使用存储过程。我对这方面很熟悉,但我想从SQL Server环境中执行它。

这可能是不可能的。另一种选择可能是根据SQL Server内的数据使用触发器,但我宁愿不选择这种方式。

英文:

Similar to 'sp_start_job', is there a way to execute a Data Factory Pipeline from SQL Server via a stored procedure?

I tried researching and everything seemed to come back to using stored procedures within Azure Data Factory. I'm familiar with that, but I want to execute it from the SQL Server environment.

It might not be possible. Another option could be to use a trigger based on data within SQL Server, but I'd rather not go that route.

答案1

得分: 1

你可以使用 Pipeline Create run REST API 来从 SQL 脚本调用 ADF 管道。

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines/{pipelineName}/createRun?api-version=2018-06-01

要从 SQL 中调用 REST API,请使用 OLE 自动化过程 sp_OACreatesp_OAMethod,它们允许我们在 SQL 服务器实例中调用 API。

生成上述 API 的身份验证令牌,使用服务主体。在使用 POST 方法调用 REST API 时,将该令牌用于其中。在其中提供您的凭据,如订阅 ID、资源组名称、数据工厂名称和管道名称。

您可以阅读这篇博客(https://www.zealousweb.com/calling-rest-api-from-sql-server-stored-procedure/)由 @Chandni Lakhani 撰写,了解有关OLE自动化过程的信息。

英文:

You can use the Pipeline Create run REST API to call the ADF pipeline from SQL script.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines/{pipelineName}/createRun?api-version=2018-06-01

To call the REST API from SQL, use the OLE automation procedures sp_OACreate, sp_OAMethod which allows us to call the API in SQL server instance.

Generate the Authentication token for the above API using Service principal. Use that token in calling the REST API with POST method. Give your credentials like subscription id, resource group name, Data factory name and pipeline name in it.

You can go through this blog by @Chandni Lakhani to understand about the OLE automation procedures.

huangapple
  • 本文由 发表于 2023年6月29日 01:48:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76575600.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定