Display job requests API ADO with includeCapabilities - azure-devops

does the ADO API allow me to get an answer that contains jobrequests but with &includeCapabilities=true&demands=key -equals value?
I tried https://dev.azure.com/org/project/_apis/distributedtask/pools/id/jobrequests?api-version=7.0&includeCapabilities=true&demands=key-equals value
and no project. Unfortunately, it didn't show what I wanted.

The demands for required agents are the properties defined on the pipeline rather than the agent pool (or agents).
Normally, the REST API for Requests is used to return when and which jobs have requested the agents in the pool. It would not return the demands defined on the pipeline.
To get the demands defined on the pipeline, you need to use the REST API for Pipelines "Pipelines - Get". From the response of this API, you can get the demands defined on the agent jobs in the pipeline.
For example:

Related

Is there anyway to query components in an Azure Pipeline?

I know one can use REST API to query Pipeline activities but is there anyway to query Pipeline components ( i.e, listing of linked services, sources, sinks, parameters, etc.)
Right now I'm manually recording all the components I see in the pipeline and querying these components would make this listing faster and more accurate
enter image description here
Thanks, Jeannie
I haven't found a way to get all the components of a pipeline directly. If the information you want to obtain is defined in the YAML file, you cannot directly obtain it, you may need to parse the YAML file to obtain it.
If the information you want to get is defined on the UI, such as variables, you can get it through the REST API Definitions - Get. And you can get the resources of the pipeline through Resources - List.

Create stage variable input in API Gateway (REST API) using CDK

I have created API Gateway using CDK and wanting to create a input for Stage Variables while sending request from API Gateway, I referenced the docs related to stage variables but could not find something that would help me in achieving this.
I am able to create predefined stage variables which are coming under stage variables tab but not being able to set them while creating request because they should be created runtime as per our need.
api = new RestApi(this, props.apiName, {
deployOptions: {
stageName: 'alpha',
variables: {
'name': 'value'
}
});
Refernced Docs :-
https://docs.aws.amazon.com/cdk/api/latest/docs/#aws-cdk_aws-apigateway.StageOptions.html
https://docs.aws.amazon.com/cdk/api/latest/docs/#aws-cdk_aws-apigateway.RestApi.html
This is not possible. Stage variables are for configuring a stage, and can only be set during the creation (or modification) of a stage, not on a per-request basis.
Refer to the documentation for details.
Depending on your use-case, you might find that regular request parameters suit your needs.

How to fail Azure Data Factory pipeline based on IF Task

I have a pipeline built on Azure data Factory. It has:
a "LookUp" task that has an SQL query that returns a column [CountRecs]. This columns holds a value 0 or more.
an "if" task to check this returned value. I want to fail the pipeline when the value of [CountRecs]>0
Is this possible?
You could probably achieve this by having a Web Activity when your IF Condition is true ([CountRecs]>0) in which the web activity should call the below REST API to cancel the pipeline run by using the pipelinerunID (you can get this value by using dynamic expression - #pipeline().RunId)
Sample Dynamic Expression for Condition: #greater(activity('LookupTableRecordCount').output.firstRow.COUNTRECS, 0)
REST API to Cancel the Pipeline Run: POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelineruns/{runId}/cancel?api-version=2018-06-01
MS Doc related to Rest API: ADF Pipeline Runs - Cancel
One other possible way is to have an invalid URL in your web activity which will fail the Web activity in-turn it will fail the IfCondition activity, which inturn will result in your pipeline to fail.
There is an existing feature request related to the same requirement in ADF user voice forum suggested by other ADF users. I would recommend you please up-vote and/or comment on this feedback which will help to increase the priority of the feature request implementation.
ADF User voice feedback related to this requirement: https://feedback.azure.com/forums/270578-data-factory/suggestions/38143873-a-new-activity-for-cancelling-the-pipeline-executi
Hope this helps.
As a sort-of hack-solution you can create a "Set variable" activity which incurs division by zero if a certain condition is met. I don't like it but it works.
#string(
div(
1
, if(
greater( int(variables('date_diff')), 100 )
, 0
, 1
)
)
)

How to find which activity called another activity in my ADF Pipeline

I have created a pipeline (LogPipeline) that logs other pipelines' status to a database. The idea is that every pipeline will call the LogPipeline at the start and at the end by passing pipeline name and pipeline ID along with other parameters like started/ended/failed.
The last parameter is "Reason" where I want to capture the error message of why a pipeline may have failed.
However, in a given pipeline there are multiple activities that could fail. So I want to direct any and all failed activities to my Execute Pipeline activity and pass the error message.
But on the Execute Pipeline when filling out the parameters, I can only reference an activity by its name, e.g. Reason = #activity['Caller Activity'].Error.Message.
However, since multiple activities are calling this Execute Pipeline, is there a way to say
Reason = #activity[activityThatCalledExecutePipeline].Error.Message?
If my understanding is correct,there are multiple activities call the LogPipeline and you want to get those failed activities' names so that you could know the names inside LogPipeline. Per my knowledge,your requirement is not supported in ADF.
I'm not sure why you have to construct such complex scenario,even though you just want to log the specific fail activities and error messages anyway which is common requirement.There are many monitor ways supported by ADF,please follow below links:
1.https://learn.microsoft.com/en-us/azure/data-factory/monitor-using-azure-monitor#alerts
2.https://learn.microsoft.com/en-us/azure/data-factory/monitor-programmatically
I would suggest you getting an idea of Alerts and Monitor in ADF portal:
And you could set the Target Criteria
It includes:

Get the list of skipped tasks on Azure DevOps Pipeline

Is there a way by which we can get the list of skipped tasks from the build?
For example, I have 2 tasks that run conditionally only based on external factors. So how can I see, whether the tasks were skipped or actually ran from Azure DevOps REST API?
I need to trigger another build conditionally based on the above factor.
Any help will be appreciated!
You should look into the Build Timeline REST API. If you issue the following GET request:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/timeline
where buildId is the ID of the build you're examining, it returns the Timeline object. It is essentially a collection of TimelineRecord objects, each representing an entry in a build's timeline. You should filter out this collection to leave only those, where "type": "Task" and "result": "skipped".