Azure DevOps Custom ServiceHook - azure

I am looking for a way to send a custom HTTP POST on service hook action. Kind of like the default WebHook functionality but with a customised body.
Is there a way to link a custom action to the consumer event?

You can add some proxy like azure function that will reformat your message and if need call Azure DevOps rest api and also get more information, and after reformatting message you send it to final consumer. You can use logic app also for that.

You can use azure logic app as suggested by #Janusz Nowak to send a custom http post on the event in azure devops.
You can check out Quickstart: Create your first workflow by using Azure Logic Apps - Azure portal.
After the logic app is created in your azure portal. In the Logic app designer page choose the Blank Logic App in templates.
In the search box type in azure devops and select a trigger event in azure devops.
Then you will be prompted to authorize the logic app to connect to your azure devops.
When you complete configuring your organization and project in the event trigger. Click ** + New Step** to add a HTTP action
You can customize your Http Request in the Http action.

Related

Can I call the Graph API within Azure functions?

I am new to azure functions.
I created a ReactApp and used the graph API to get information about users registered in Azure ADB2C.
At this time, a client credential flow was used, but user information could not be obtained due to a CORS error.
Previous Idea(CORS error): ReactApp↔graphAPI↔Azure ADB2C
So I thought of using Azure functions.
First, ReactApp calls azure functions as an API.
Next, call the graphAPI in the azure functions.
At this point, we want to use the client credential flow.
Then, the user data of Azure ADB2C can be obtained because the graphAPI was used.
This user data is returned to Azure functions so that it can be used in ReactApp.
My Idea: ReactApp↔Azure functions ↔ graph API ↔ Azure ADB2C
Is this feasible?
If it is possible and you have a sample, please let me know.
Thanks for reading.
• Yes, you can surely do the same as per what you have stated in your post. You can surely deploy a react app in Azure functions and trigger a graph API query from the function to an Azure AD B2C tenant. To do so, you will have to first deploy an Azure Static Web app in Azure, then build and deploy it through a workflow in Github by creating a repository there, then create an Azure function API for the react app deployed. This Azure function service provides serverless APIs which allows you to focus on your TypeScript code and not have to configure a full back-end web server.
• Once done, then connect the react client app to Azure function API. The Azure static web app resource deployed earlier provides a proxy between the react client and the Azure function API. Hence, while deploying the above, I would suggest you to please follow the below Microsoft documentation link and its subsequent article series for the said above resources.
https://learn.microsoft.com/en-us/azure/developer/javascript/how-to/with-web-app/static-web-app-with-swa-cli/introduction
Please follow the series of documentation articles stated above till the end of connecting the react client to Azure function API. Once done, then register an application in Azure AD B2C for authentication purposes and copy the application’s required credentials like the client ID, tenant ID, tenant name and client secret for inserting these details in the HTTP trigger function API created earlier. Also, give the registered application in Azure AD B2C the required application permissions of ‘User.ReadWrite.All’ for the Microsoft Graph API. Ensure that you are adding the ‘Microsoft.Identity.Client’, ‘Microsoft.Graph.Auth’ and ‘Microsoft.Graph.Beta’ nuget packages to your Azure function solution created earlier. Then modify the constant parameters and variables in the Azure solution code file as in the below snapshot: -
• Once the above has been done successfully, you can then test the deployed solution through ‘Postman’ application API as well as by redirecting to the react app page there by triggering a HTTP response in the function API which will ensure that you read the logged in Azure AD B2C user in the react app. For detailed information on the above-mentioned configuration, I would suggest you to please go through the video link below as it perfectly describes your condition in detail: -
https://www.youtube.com/watch?v=4uJHSwA-TZE

Azure Event Grid Webhook validation handshake

I would like to know if it is possible to have Azure Web Site (ASP.NET Core) and Azure Event Grid with Webhook to the Azure Web Site in the same ARM Template?
For the first time, there is no possibility to validate Webhook.
Of course, I can split it into the two ARM Templates and deploy 1st ARM with the Application, deploy the Application and add the Event Grid Webhook.
Is it some other workaround here? I can use Event Grid Schema or Cloud Events Schema.
another workaround can be used to create an event subscription with some destination resource handler (for instance: storage queue) and then updating for your webhook handler.

Azure Event Grid not sending events to webhook

I have an Azure media services account for which I want to be notified via webhook when encoding jobs are finished. I'm using v3 of the Media Service API.
I've added an event subscription to this account and have sucessfully validated the webhook endpoint.
Here's where the problem comes in. If I do something that should trigger an event(start an encoding job, create an asset, etc.) on the Azure Portal nothing happens event wise. Looking at the event subscription on the Portal shows no events detected as well.
Is this an Azure bug or am I missing something?
As it turns out, actions done through the Portal or v2 of the API does not trigger Events from Event Grid.
I used Azure Media Services Explorer to test out my webhooks instead.

Start/Stop Azure Function App using ADF Web Activity

Is there any provision to start/stop an azure function app via Azure Data Factory Web Activity.
Azure Logic Apps is the simplest way to achieve this.
You can call the below Management API to Start/Stop your Azure Function App:
START
POST https://management.azure.com/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroup>/providers/Microsoft.Web/sites/<FunctionAppName>/start?api-version=2015-08-01
STOP
POST https://management.azure.com/subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroup>/providers/Microsoft.Web/sites/<FunctionAppName>/stop?api-version=2015-08-01
You can use Managed Service Identity authentication to authenticate above request.
Below are some screenshots for your reference:
Once you enable the Managed Identity for your Logic App , It will create a AD Application with the same name of your Logic App Work Flow.
Now Got to your Function App --> Platform Settings --> All Settings --> Access Control (IAM) --> Click on Add(+) button.
Add AD Application (Created with your Logic App Name) and Provide Contributor role and save.
Function can be started based on its trigger. eg. Timer, webhoook etc.
It can be stopped by stopping the function App and existing functions will be stopped

Azure Create Resource Monitoring Webhooks using Rest API

In Azure is it possible to create an alert, with a webhook, if any of my resource goes up or down(not service, but resource)? I see many alert conditions but none of them do plain up/down monitoring.
Is it possible to create these alerts (with a webhook) programatically using REST API(without logging into Azure portal), once i get the required authorization? Currently I am unable to find any create alert REST API
Thanks.
Ok, I found out how to do this.
The REST API provided by Azure for monitoring can be used to create new Action Groups and create new Alerts.
The document here gives more details: https://learn.microsoft.com/en-us/rest/api/monitor/actiongroups
https://learn.microsoft.com/en-us/rest/api/monitor/alertrules/createorupdate

Resources