Retrieve Build Cause/Reason from Azure Pipelines? - azure

I am using the Azure DevOps REST API, for example:
curl -X GET 'https://dev.azure.com/MyOrg/MyProject/_apis/pipelines/ID/runs/ID?api-version=6.0-preview.1'
In the result, there does not seem to be any mention of the parameters passed into the pipeline, or the build cause/reason. I've tried setting variables to the value of the parameters and that doesn't seem to show up either, and fiddling with the API version string hasn't yielded anything.
Is there a way to programmatically retrieve information about trigger reason and parameters using the API? Without this, it seems impossible to build any backend data (for example, to show the % of users using your pipeline via the azure portal or via PR triggers).

You could use Builds - Get api instead:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=6.0
You would get triggerInfo and reason in the response.

Related

Azure Pipelines conditions

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

Deleting an Azure Active Directory Device via API

I am working on an automation to remove devices from InTune and Azure for single users when the laptop or device is being retired. I am trying to make DELETE requests via the graph API to remove the device from AutoPilot, InTune, and Azure Active Directory (AAD).
Currently, this is working for everything except AAD. I am attempting to use the API: https://graph.microsoft.com/beta/admin/windows/updates/updatableAssets based on information from https://learn.microsoft.com/en-us/graph/api/windowsupdates-updatableasset-delete?view=graph-rest-beta&tabs=http.
There doesn't seem to be an equivalent that I can find outside of beta. I am able to make a GET request to list items but trying to retrieve or delete a single item keeps giving me a 404.
Does anyone have any solutions for removing an Azure AD Device via API?
Have to tried Version selector as shown in the MSDN?
although i don't have similar scenario to test, but URl might be like
https://graph.microsoft.com/v1.0/admin/windows/updates/updatableAssets/{updatableAssetId}
One more way, if you have the option of using GraphServiceClient, then you can use this
https://learn.microsoft.com/en-us/graph/api/windowsupdates-updatableasset-delete?view=graph-rest-beta&tabs=csharp
Best part of the GraphServiceClient is default it will prepare a General Release version Api to call.
MSDN:-Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version
Please check at your end, if the GA is providing the operation you are looking for.

Azure services overview

I have many services on the azure plateform .instead of going on azure portal always and checking which services are running i want main parameters of azure services on my dashboard like pipelines successfully ran in data factory,storage used in data lake.so is there any api which can do or fetch this data?
Almost all the Azure resources have REST API exposed to get their status and key metric/attributes, so you need to write some script or code to pull these and display in your UI(may be simple javascript based). For example to get the pipeline run details, refer this

Azure DevOps & Logic Apps: Attach file to work item

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.

How to configure Action Group on Azure Monitor Alert to use compilable (C# or F#) Azure Function

I was trying to figure out how to configure Action Group to use Azure Function. Documentation says that:
Calls an existing HTTP trigger endpoint in Azure Functions.
You may have a limited number of Function actions in an Action Group.
So what I tried already:
C# script file created on the portal - works
Powershell script created on the portal - works
Powershell script deployed to Azure Function - works
compiled Function App in C# deployed to Azure Function - doesn't work
compiled Function App in F# deployed to Azure Function - doesn't work
My preference is actually to use F# here and this is the reason why I'm trying to figure out (I know that I can use fsx and then it probably goes fine, however I want use compiled app and if it is not possible know why)
Each app I tested calling and endpoint from postman and each time it was fine. I tried also Function and Anonymous AuthorizationLevel.
And by saying that action doesn't work I mean following:
no evidence of calling that function (on Azure Function or App Insights)
no error or warning regardless the side
I also tried to configure a Webhook action by putting Azure Function endpoint but it also doesn't work. Did you understand why it is happening like this?
I figure out that and the issue was that in compilable version I didn't handle post verb. After adding it, all works as expected.

Resources