I'm trying to start with LogicApp - no prior experience.
I have a DevOps project and LogicApps workflow. Workflow is triggered by received mail and creates a new work item in DevOps.
If the email contains any attachments, workflow creates a blob, retrieves the blob, and then I'd like to attach the file to a work item, but I have no idea how.
Workflow diagram
How Can I do that? I couldn't find any option in 'Update a work item' action:
Work Item action block
Is there any way how to do it via 'Send an HTTP request to Azure DevOps' action block?
Sent an HTTP request to Azure DevOps action block
Yes this should be possible through the Azure DevOps REST API, using the Work Item - Create Attachment API.
You can use this URI format and replace the placeholders accordingly. The Microsoft document will give you more information about what each mean and also the value type expected there.
POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?fileName={fileName}&uploadType={uploadType}&areaPath={areaPath}&api-version=6.0
We're actually using the Azure DevOps API for other Pipeline actions but instead of using the built in Send an HTTP request to Azure DevOps, we're using the generic HTTP Connector. You will also need to authenticate using an account that has access to the project.
Related
I am using the Azure DevOps REST API to create a serviceendpoint/serviceconnection which works fine. I am using the following endpoint: https://learn.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/create?view=azure-devops-rest-6.0&tabs=HTTP
However we would like to specify a group of approvers as you can do via the Azure DevOps portal like shown in the attached image
Project Settings->Serviceconnections-> Approvals and check
Can this be done via the Azure DevOps REST API?
I reviewed the Microsoft docs with regard to Azure DevOps REST API.
Project Settings->Serviceconnections-> Approvals and check Can this be done via the Azure DevOps REST API?
Yes. We can achieve this via Rest API.
You can use the Rest API: Check Configurations - Add to add approvers to service endpoint.
Here is an example:
API URL:
POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/checks/configurations?api-version=7.1-preview.1
Request Body:
{
"type":{
"id":"8C6F20A7-A545-4486-9777-F762FAFE0D4D",
"name":"Approval"
},
"settings":{
"approvers":[{
"displayName":"UserName",
"id":"UserID",
"uniqueName":"emailaddress"
}],
"executionOrder":1,
"minRequiredApprovers":0,
"requesterCannotBeApprover":false},
"resource":{
"type":"endpoint",
"id":"ServiceEndpointID"
},
"timeout":43200
}
Result:
Have not tried this myself, but a little reverse engineering of the Azure DevOps UI leads me to believe there is a generic API object for checks and approvals used by various object types within ADO.
I think Check Configurations API for approvals and checks is what you need. This does use version 7.1 of the API though.
I have setup a flow where azure release definition makes to an agentless API call to azure build pipeline which performs a list of tasks which trigger a release.
I would like to add a condition to the azure build pipeline to differentiate between a user running the build pipeline manually (through portal) or if the pipeline was triggered via an api call.
What is the neatest way to do this? Ideally I expect a condition something like
eq(triggered-by, "Joe") -> not ideal, I don't want to attach condition based on a users name
eq(build-reason, "api") -> ideal but is there some in-build condition for something like this?
One other options which passes through my mind is passing a custom runtime variable through the api call, but I was wondering if there was a more in-built approach.
Thanks in advance.
Currently, there's no build-in feature in Azure DevOps to achieve this.
We cannot judge whether it is triggered by manually or API. If you are using an API call, the token also stands for a single user.
Also, you could raise a feedback ticket for your demand: Suggest a feature - Visual Studio (Windows) | Microsoft Docs
I know it's possible to create Logic App in Azure to send message in Teams after completing pipeline. I don't know how can I add hash with completed pipeline as clickable link to open.
I couldn't find any information how can I do this.
I will be grateful for your help.
Azure DevOps Pipelines already have official support to integrate into Microsoft Teams that you could use directly, even without a Logic App.
But if you still need to use a Logic App, then what you could do is use the Invoke a REST API task to call your Logic App, and then send an Adaptive Card which you can design to have a button which links to the pipline.
I'm creating a schedule-triggered Azure Function which will run tests once a day. If during the run any test fails, I want it to create a bug on a Azure DevOps project which includes a log of the failed tests.
I know I could create a PAT so that it can authenticates with the DevOps REST API but I don't like its downsides:
it can be valid for 1 year at maximum, I will need to remember to extend its expiration period
every bug created like this will have me as its creator
Edit:
I found out I could use a MS Flow - there's a DevOps connector that can create workitems, still it has a downside of having me as workitem's creator but it's not such a pain...
Still would much appreciate to learn about other options...
Is there any better way I can let my Azure Function to create bugs on my DevOps project?
An alternate option would be the use azure logic app along with azure function.
Here the azure function would directly call a azure logic app and the logic app would create a bug workitem .
Refer the following article by Stefan stranger
On how to create logic app which will create the bug. Here we will be using azure webhooks for the creating of bugs.
Now you can either send the data to a storage account where the logic app using some trigger to get the data and then use it to create bug, or you can directly connect to the logic app .
Refer the following article by Laura KokKarinen for this .
I've got an Azure Logic App that I want to run whenever a file is uploaded to a specific Azure Storage Account. The Logic App is deployed via an ARM template (which has also been configured to create the Event Grid and Blob Storage API connections).
When I deploy the ARM template, the Event Grid trigger isn't working as there's no event subscription in the Azure Storage Account.
FYI., I can get event subscriptions to work if I create a Logic App via the quick start option i.e. from my Azure Storage Account under Events > Get Started > Logic Apps > When a new blob is uploaded > Create.
^^ This creates a new Logic App with an Azure Event Grid trigger (When a resource event occurs), but I actually want to create/link the event subscription to an existing Logic App i.e. the one that I deployed via the ARM template, and I want to be able to automate this.
If I reverse engineer the event subscription that was created by the Logic App quick start; I can see it's got an endpoint type of WebHook with an endpoint of the form {logic-app-access-endpoint}/triggers/{name-of-trigger}/versions/{logic-app-version}/run. I can reconstruct this to something like the following by getting the params from my Logic App:
https://prod-24.australiaeast.logic.azure.com:443/workflows/12433cc68f0e916dc3048c1775333506/triggers/When_blah_blah_blah/versions/12345678901234567890/run
I can enter the Subscriber Endpoint and Confirm Selection, but when I try to create it; I'm getting the following error:
Deploying Event Subscription: Test123
Deployment has failed with the following error: {"code":"Url validation","message":"The attempt to validate the provided endpoint https://prod-24.australiaeast.logic.azure.com:443/workflows/12433cc68f0e916dc3048c1775333506/triggers/When_blah_blah_blah/versions/12345678901234567890/run failed. For more details, visit https://aka.ms/esvalidation."
What's strange is if I go into my logic app and change the event grid connection to a different one (but with the exact same properties) and then save my logic app; I can then create my event grid subscription without the error. It seems a bit temperamental...
I've tried a few things such as authorizing my event grid API connection, but it doesn't work...
Does anyone know if how set up event grid subscriptions to an existing Logic App without the errors / temperamental behavior... also how would one go about automating the creation of the event grid subscriptions (given there's some dynamic properties such as the logic app version).
TIA - Ryan.
It looks like your Logic App trigger endpoint is a bit off. It should look something like this:
https://prod-24.australiaeast.logic.azure.com:443/workflows/12433cc68f0e916dc3048c1775333506/triggers/When_blah_blah_blah/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers% When_blah_blah_blah%2Frun&sv=1.0&sig=1234567890abcdefghij
You can find the exact value by clicking See trigger history from your Logic App overview blade.
From the ARM template automated deployment standpoint, you can get the trigger endpoint using the following code:
[listCallbackUrl(concat(resourceId('Microsoft.Logic/workflows',variables('myLogicAppName')),'/triggers/When_blah_blah_blah'), '2016-10-01').value]
I highly recommend either deploying your Logic App and Event Grid subscriptions together or adding a "Logic App was changed" trigger to your Event Grid subscription deployment. You'll need this in case your Logic App trigger endpoint changes which should only happen at deployment time (friends don't let friends save in the portal).