在Powershell中使用callbackuri将错误消息发送到Azure数据工厂管道

时间:2020-05-24 16:00:33

标签: azure powershell azure-data-factory-2 runbook callbackurl

我正在使用Azure数据库工厂创建Webhook活动。如果Webhook在线,它将恢复Dataware House数据库。我正在使用ADF调用此Webhook活动。该Webhook链接到Azure Runbook,它将恢复Datawarehouse。

我正在尝试使用Callbackuri传输Runbook的错误消息。到现在为止我已经可以这样做了。

下面是我的Runbook。如果发生某些错误,它应该捕获并转移到ADF。

catch{
    Write-Error -Message $_.Exception
    $ExceptionMessage =  $_.Exception
    write-output "This is the exception encountered"$ExceptionMessage

    If ($callBackUri)
{
    # Create an error message
    # Message and statuscode will show up in ADF
    $body = [ordered]@{
    output= @{
                                    restoreStatus = "Failed"
                                }
                                error = @{
                                    ErrorCode = "Pause Error"
                                    Message = "Pausing the Database failed"
                                }
                                statusCode = "500"
    }
 
    # Convert the string into a real JSON-formatted string
    $bodyJson = $body | ConvertTo-Json
 
    # Call back with error message in body and a JSON contenttype
    Invoke-WebRequest -Uri $callBackUri -Method Post -Body $bodyJson -ContentType "application/json" -UseBasicParsing
}
throw $_.Exception
}

有人可以建议我如何使用callbackuri将错误转移到ADF。

0 个答案:

没有答案