Create deployments from Azure DevOps Pipelines
Notifying elmah.io about new deployments is possible as a build step in Azure DevOps Pipelines.
Using YAML
-
Edit your build definition YAML file.
-
If not already shown, open the assistant by clicking the Show assistant button.
-
Search for 'elmah.io deploy'.
-
Click the elmah.io Deployment Notification task
-
Replace
API_KEY
with an API key (Where is my API key?) with permission (How to configure API key permissions) to create deployments. If the deployment is specific to a single log, insert a log ID (Where is my log ID?) with the ID of the log instead ofLOG_ID
. Deployments without a log ID will show on all logs in the organization.The task uses the current build number (
BUILD_BUILDNUMBER
) as the version name on elmah.io. If you want to override this behavior, you can insert a value in the Version text box. -
Click the Add button and the new task will be added to your YAML definition. You typically want to move the deployment task to the last placement in tasks:
steps:
# other steps
- task: ElmahIoDeploymentNotification@4
inputs:
apiKey: 'API_KEY'
logId: 'LOG_ID'
Using Classic editor
The deployment task extension is not available in the Classic editor. Here, you can use PowerShell instead.
-
Edit the build definition currently building your project(s).
-
Click the Add task button and locate the PowerShell task. Click Add.
-
Fill in the details as shown in the screenshot.
... and here's the code from the screenshot above:
$ProgressPreference = "SilentlyContinue"
$url = "https://api.elmah.io/v3/deployments?api_key=API_KEY"
$body = @{
version = "$env:BUILD_BUILDNUMBER"
description = "$env:BUILD_SOURCEVERSIONMESSAGE"
userName = "$env:BUILD_REQUESTEDFOR"
userEmail = "$env:BUILD_REQUESTEDFOREMAIL"
logId = "LOG_ID"
}
[Net.ServicePointManager]::SecurityProtocol = `
[Net.SecurityProtocolType]::Tls12,
[Net.SecurityProtocolType]::Tls11,
[Net.SecurityProtocolType]::Tls
Invoke-RestMethod -Method Post -Uri $url -Body $body
Replace API_KEY
with your API key (Where is my API key?) and LOG_ID
(Where is my log ID?) with the id of the log representing the application deployed by this build configuration.
This article was brought to you by the elmah.io team. elmah.io is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening, and help you fix errors fast.
See how we can help you monitor your website for crashes Monitor your website