我们使用Azure自动化按计划执行Azure SQL Server存储过程。
以下是脚本之一:
workflow ExecuteSP1
{
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 = "Connection String"
$MasterDatabaseConnection.Open()
Write-Output "CONNECTION OPEN"
# Create command
$MasterDatabaseCommand = New-Object System.Data.SqlClient.SqlCommand
$MasterDatabaseCommand.Connection = $MasterDatabaseConnection
$MasterDatabaseCommand.CommandText = "dbo.StoredProcedure1"
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自动化会在每次运行时通知我们该脚本成功运行。但是,在我们的SQL Server中产生的效果并未反映为已发生。所以我只能想象这意味着存储过程正在超时。我已经确认直接在SQL Server上运行SP时,SP可以正常运行,但是确实需要很长时间才能运行。
我可以在上述脚本中添加以下内容吗?
-
在脚本中还是在SQL Server端上将任何超时期限增加到无限或至少4小时?
-
如果存储过程未成功完成执行,实际上会在AA中引发错误吗?