在 Azure Runbook 方面需要帮助吗?

Need help me with azure runbooks?

我想安排一个简单的任务来使用 Runbook 截断 table。数据库是 Azure SQL 数据库。

对于您的情况,您可以创建一个 powershell runbook 来执行 TRUNCATE TABLE

要通过powershell调用sql命令,可以参考这个link.

样本:

function Invoke-SQL {
    param(
        [string] $dataSource = ".\SQLEXPRESS",
        [string] $database = "MasterData",
        [string] $sqlCommand = $(throw "Please specify a query.")
      )

    $connectionString = "Data Source=$dataSource; " +
            "Integrated Security=SSPI; " +
            "Initial Catalog=$database"

    $connection = new-object system.data.SqlClient.SQLConnection($connectionString)
    $command = new-object system.data.sqlclient.sqlcommand($sqlCommand,$connection)
    $connection.Open()

    $adapter = New-Object System.Data.sqlclient.sqlDataAdapter $command
    $dataset = New-Object System.Data.DataSet
    $adapter.Fill($dataSet) | Out-Null

    $connection.Close()
    $dataSet.Tables

}

有关Azure runbook的更多详细信息,您可以参考此doc