我想知道我是否可以创建Azure管道并让它运行一个清除我的Azure SQL表的proc。
我仍然对数据工厂的概念不熟悉,我发现数据工厂通常都有管道将数据从blob复制到azure SQL /内部SQL,反之亦然。
我正在尝试编写一个数据工厂管道,它将清除我的Azure SQL DB中的旧记录,并希望有人能指出我正确的方向。我还可以使用Azure数据工厂吗?
答案 0 :(得分:3)
我的建议是使用Azure Automation而不是ADF来安排存储过程执行。您会找到示例here和here。以下是您需要在Azure自动化上实现的代码:
workflow NAME-OF-YOUR-WORKFLOW
{
Write-Output "JOB START BEFORE INLINESCRIPT"
inlinescript
{
Write-Output "JOB START"
# Create connection to Master DB
$MasterDatabaseConnection = New-Object System.Data.SqlClient.SqlConnection
$MasterDatabaseConnection.ConnectionString = "Data Source=YOUR-DATABASE-SERVER-NAME.database.windows.net;Initial Catalog=YOUR-DATABASE-NAME;Integrated Security=False;User ID=YOUR-DATABASE-USERNAME;Password=YOUR-DATABASE-PASSWORD;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False"
$MasterDatabaseConnection.Open()
Write-Output "CONNECTION OPEN"
# Create command
$MasterDatabaseCommand = New-Object System.Data.SqlClient.SqlCommand
$MasterDatabaseCommand.Connection = $MasterDatabaseConnection
$MasterDatabaseCommand.CommandText = "YOUR-PROCEDURE-NAME"
Write-Output "DATABASE COMMAND TEXT ASSIGNED"
# Execute the query
$MasterDatabaseCommand.ExecuteNonQuery()
Write-Output "EXECUTING QUERY"
# Close connection to Master DB
$MasterDatabaseConnection.Close()
Write-Output "CONNECTION CLOSED"
}
Write-Output "WORK END - AFTER INLINESCRIPT"
}
要了解有关Azure自动化的更多信息,请单击here。
希望这有帮助。