Trigger pipeline with HTTP Request or fromo Power Automate flow - azure-devops

Is there a way to trigger an Azure pipeline by using something similar to a POST call or from inside a Power Automate flow?
Similarly to how a Power Automate flow can be triggered from an HTTP Request.

Yes you can use Run API endpoint
POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1
as body if you want to trigger build on main branch use this json
{
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/main"
}
}
}
}
And if you don't know how to authenticate this documentation explain you how to use PAT token

Related

Get GitHub security alerts through notification API

I want to get GitHub notifications about a given repo’s Security alerts through the notification API, and I would like to know the JSON returned by this API.
Let say for a given repo I subscribed to the Release and Security alerts in GitHub UI:
When I publish a “Security advisory” on a given repo, I don’t receive any notification with the others account subscribed to this repo. I think this is because GitHub needs to validate this security advisory before it sends the notifications events.
So can someone please give me an example of JSON returned by the notification API for a Security event ?
Here is an example of JSON returned by the notification API for the Release events (as I can generate some by myself):
curl -su <me>:<token> https://api.github.com/notifications
[
{
"id": "3267365319",
"unread": false,
"reason": "subscribed",
"updated_at": "2022-03-14T16:07:41Z",
"last_read_at": null,
"subject": {
"title": "0.5.0",
"url": "https://api.github.com/repos/pfrayer/release-tester/releases/61780007",
"latest_comment_url": "https://api.github.com/repos/pfrayer/release-tester/releases/61780007",
"type": "Release"
},
"repository": {
...
I’m looking for the same kind of JSON, but for the Security events.

get pull request information for a workItem in DevOps API

I wanted to know the status of the pull request associated with a work item on the board. If possible able to filter on status.
Or
At minimum Is it possible to get the pull request details with WIQL.
get pull request information for a workItem in DevOps API
If you want to get the state of the workitem, which associated with the PR, you could use the REST API Pull Requests - Get Pull Request:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}?api-version=5.1
Then we could get the pull request details, which including following response body:
"workItems": {
"href": "https://dev.azure.com/xxx/xxx/_apis/git/repositories/0f1bc369-c105-435d-a443-9c933f9bd98f/pullRequests/112/workitems"
},
Next, we just get the href from above response body, we could get the workitem details:
GET https://dev.azure.com/xxx/xxx/_apis/git/repositories/0f1bc369-c105-435d-a443-9c933f9bd98f/pullRequests/112/workitems
The response body:
"value": [
{
"id": "145",
"url": "https://dev.azure.com/xxx/_apis/wit/workItems/145"
}
So, we get the workitem ID, then we use the REST API Work Items - Get Work Item to get the status of workitem:
Hope this helps.

Watson Assistant programmatic to Heroku webhook not working

I have created a Webhook (https://moviebotdf.herokuapp.com/get-movie-details), it is tested with postman and dialogflow and working properly.
I want to integrate it with IBM Watson Assistant via programmatic call, but this is not returning anything (i.e. the output is "").
I checked the IBM support (https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-actions&locale=en) and also other solutions as calling a function that could call the webhook but I am having even less succcess there. As I understand from the support, a direct call from the Assistant to the Webhook should be possible (and easier for newbies like me), hence is the solution I seek. Code in the Assistant is as follows:
{
"context": {
"skip_user_input": true,
"prodname": "$prodname"
},
"output": {
"text": {
"values": [
"$dataToSend"
],
"selection_policy": "sequential"
}
},
"actions": [
{
"name": "https://moviebotdf.herokuapp.com/get-movie-details",
"type": "client",
"parameters": {
"prodname": "$prodname"
},
"result_variable": "context.dataToSend"
}
]
}
So "prodname" is captured by Watson Assistant in the previous node (I checked that and it is working correctly) and sent to the Webhook. The variable used in the Webhook is also called "prodname". The expected output from the Webhook is stored in the variable "dataToSend", but as said above the answer in Watson is only "" as "$dataToSend" is "".
I tried also with "result_variable": "dataToSend" and "result_variable": "$dataToSend" without success, so what I guess is that the webhook is not being called...
I am new in the topic, so please do not hesitate to correct any problems in my post.
Thanks in any case in advance!
Adrià
IBM Watson Assistant lists three different options of making a programmatic call from within a dialog node:
client: your app is in charge of calling out to the action
server or cloud_function: IBM Cloud Functions action is invoked from Watson Assistant
web_action: The web action of an IBM Cloud Functions action is invoked from Watson Assistant
If you host your webhook on IBM Cloud Functions, then Watson Assistant can directly call it. With your current hosting and client specified, your app is in charge. In that case your app needs to check that the context includes the information about a client action, extract that related metadata, invoke the webhook and send the data back to Watson Assistant.
I have written an example for such a client action for my Watson conversation tool. See that repo for instructions.

Webhook integration with Watson Assistant?

I want to know whether IBM Watson Assistant has the feature of calling webhook.
It means when an intent of workspace is matched Watson Assistant need to send a post request to an external server including the intent in the request body.
Example for a webhook:
https://123.456.789.12:7788/myWebhook/testMethod
IBM Watson Assistant need to send a Post request to this service and that service will return a text string. Watson Assistant should get that text and show it to the user.
That is my usecase. Will it work with Watson Assistant?
i found the below documentation from IBM site.
https://console.bluemix.net/docs/services/conversation/dialog-actions.html
It says to update the json response. i.e. add another key value pair to json object as "action". in the action json array there is "name" parameter. I added above url to name parameter and checked by calling the intent whether a request comes to my web service but it didn't.
following is my json response. i assumed once the intent is matched a post request should go to my web service. but i checked my web service by printing the request body on the console. but no any request came to it. could you please tell me where did i miss?
{
"context": {
"skip_user_input": true
},
"output": {
"text": {
"values": [
"your current outstanding balance is $my_balance ."
],
"selection_policy": "sequential"
}
},
"actions": [
{
"name": "https://123.456.789.12:7788/myWebhook/testMethod",
"type": "client",
"parameters": {
"body": "$body"
},
"result_variable": "context.my_balance"
}
]
}
You found the correct method, i.e. dialog actions, to implement webhooks.
Watson Assistant supports server- or client-side actions:
For the server-side action you would set up an action with IBM Cloud Functions. That action would call the webhook.
For client side, you would pass the information similar to what you show in the question to the app (client). Your app would need to react and to call the webhook.
From what I read about your case I recommend checking out the server-side action. This tutorial about a database-driven bot implements a couple of those actions. Instead of calling the database, you would call out the webhook.
As of August 2019, there is now an integrated webhook feature in Watson Assistant.
Go to "Options" in the Assistant dialog and enable webhook. Paste the url you got after creating an action from cloud functions. Don't forget to add ".json" to the url you paste in the assistant webhook page. See more information here:
https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks

Azure Logic app with Google Cloud Storage connection

It was pretty straight forward setting up a connection to Google Drive since there was options for it in the Logic App Designer. But I can't find any similar options for connecting to Google Cloud Storage.
Am I missing something or do I have to go with a Function App in Azure and write my own code for connecting to GCP?
"actions": {
"Create_file": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['googledrive']['connectionId']"
}
},
"method": "post",
"body": "#body('Get_blob_content_using_path')",
"path": "/datasets/default/files",
"queries": {
"folderPath": "/GcpExportTest",
"name": "#triggerBody()?['Name']",
"queryParametersSingleEncoded": true
}
}
}
}
...
"parameters": {
"$connections": {
"value": {
"googledrive": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'googledrive')]",
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('googledrive_1_Connection_Name'))]",
"connectionName": "[parameters('googledrive_1_Connection_Name')]"
}
}
}
}
As of this writing, there isn't a built-in connector in Logic Apps yet for interacting with Google Cloud Services specifically, however, because Logic Apps is great with anything RESTful and Google Cloud Storage does provide REST API, there are multiple ways you can go about to accomplish what you want, and using Azure Functions is definitely one of them.
Alternatively, if your desired workflow is something simple and you'd rather work in the LA designer view like you did with Google Drive connector, you have HTTP connector in Logic Apps at your disposal too: you would include the authentication bearer token in your request and call the specific Google Storage endpoint that executes the desired task (get, list, delete etc..) against bucket/object.