Can the release be triggered whenever there is a new artifact is available (either the build artifact or the azure git repos artifact)? Is this possible in Azure DevOps.
Sorry for any inconvenience.
Build/Release definitions currently only support a single trigger.
As workaround, you could set the Azure Repos Git artifact as primary artifacts to trigger Azure DevOps release definition.
For the build artifact, we could trigger the release definition from a build task in either build definition through REST API.
Check this ticket for some more details.
Update:
Detail how to use Rest API trigger release from build pipeline.
As I answered above, We could use the Rest API Releases - Update Release to trigger the release:
PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}?api-version=5.1-preview.6
When you open a release pipeline, then switch to log tab, you could get the releaseId and environmentId

Then, we add a Inline Powershell task in the build pipeline to invoke the API to trigger the release. The scripts like:
$url = "https://vsrm.dev.azure.com/<OrganizationName>/<ProjectName>/_apis/Release/releases/285/environments/370?api-version=5.1-preview.6"
$connectionToken="Your PAT Here"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }
$body=@"
{
"status":"inProgress",
"scheduledDeploymentTime":null,
"comment":""
}
"@
Write-Host "$url"
$response= Invoke-RestMethod -Uri $url -ContentType "application/json" -Body $body -headers @{authorization = "Basic $base64AuthInfo"} -Method PATCH
If you execute this build pipeline, it will trigger the release pipeline.
As test, it works fine on my side.
Note:
When you use above scripts, you need go to the Agent Phase and select Allow Scripts to Access OAuth Token. See Use the OAuth token to access the REST API
Update2:
Powershell script work, but it downloads the old build artifact.
However, we need to associate the release with latest build artifact,
how can this be accomplished?
You could use another REST API to get the latest Release ID and the environmentId:
Definitions - Get
We could get the all Release ID for the definitionId:
"isDeleted": false,
"lastRelease": {
"id": 285,
"name": "xxxxxx",
"artifacts": [],
"_links": {},
Then use Select-Object -first 1 get the latest Release ID.
Next, we could use another API Releases - Get Release with releaseId, which we get by above Rest API, we could get the environmentId:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=5.1
The output like:
"environments": [
{
"id": 370,
"releaseId": 285,
"name": "Dev",
"status": "succeeded",
"variables": {
Now, we get the latest release ID, we could get use the first REST API to trigger the release.
Hope this helps.