Build an Azure Logic App to send an alert when the provisioning state changes for your Azure VWAN
Published Jan 25 2024 11:30 PM 3,549 Views
Microsoft

Prerequisites:

Before diving into the implementation, make sure you have the following in place:

Step 1:

Begin by navigating to the Azure portal and creating a new Logic App. Select a resource group, provide a unique name, choose the appropriate region, select the plan (Standard or Consumption), and leave the Zone redundancy to ‘disabled’. You should have something like this:

 

Mo_Elaryan_0-1706225225228.png

 

Step 2:

Set up a System-Assigned Managed Identity to allow the logic app to query the provisioning status for the Virtual WAN.

Step 3:

Configure and run your Logic App by navigating to the code view of your Logic App within the Azure Portal and paste the following:

{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"HTTP_2": {
"inputs": {
"authentication": {
"type": "ManagedServiceIdentity"
},
"body": {
"query": "resources | where type == 'microsoft.network/virtualwans' | extend provisioningState = tostring(properties.provisioningState) | project name,provisioningState"
},
"headers": {
"Content-Type": "application/json"
},
"method": "POST",
"queries": {
"api-version": "2021-03-01"
},
"uri": "https://management.azure.com/providers/Microsoft.ResourceGraph/resources"
},
"runAfter": {},
"type": "Http"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Minute",
"interval": 1
},
"type": "Recurrence"
}
}
},
"parameters": {}
}

Note: If you would like to monitor the provisioning state of your virtual hubs instead, you can change the query line above to be the following:

"query": "resources | where type == 'microsoft.network/virtualhubs' | extend provisioningState = tostring(properties.provisioningState) | project name,provisioningState"

Step 4:

After you have run your Logic App, navigate to the run history, click on the recent run, click on the “HTTP” step, scroll down to copy the “body” section and paste it in a Notepad (We will need it in the next step to Parse the output of the HTTP response). See image below:

 

Mo_Elaryan_1-1706225225315.png

 

Step 5:

Navigate to the Logic app designer, click on new step and search for “Parse JSON” (You should be able to see it as the first option under Actions). Click on Parse JSON. In the Content field, select “Body” and in the Schema field, click on “Use Sample Payload to generate Schema” and paste the body you copied from the previous step in the box as shown below:

 

Mo_Elaryan_2-1706225225101.png

 

Step 6:

Click on new step and search for “Condition” under the Built-in connectors. Under Condition, select “Provisioning State” is not equal to “Succeeded”. Under “True”, search for Send an email (V2), fill out the necessary fields for example: Body, Subject, To, etc. as shown below then hit save.

 

Mo_Elaryan_3-1706225225076.png

 

At the end, your logic app designer should look similar to this:

 

Mo_Elaryan_4-1706225225114.png

 

Step 7:

Let’s test the Azure Logic App and simulate a “Failed” state for your Azure Virtual WAN.

Note: You may need to repeat steps 3 & 4 again but this time you will enable the branch-to-branch configuration and hit save.

5. You should be able to see the status changes to “Failed” for your Azure Virtual WAN and an alert has been sent to the email you specified in the Logic App.

Note: This is only for testing purposes, please use caution while testing this in your production environment.

6. If you would like to bring your Azure Virtual WAN to the “Succeeded” provisioning state, please run the following PowerShell command after making the necessary changes to the name, and the resource group name:

Get-AzVirtualWan -Name "your_resource_name" -ResourceGroupName "your_resource_group_name" | Update-AzVirtualWan

Conclusion:

Using the Azure Logic App to notify you when a provisioning state changes in your Azure Virtual WAN can help you to proactively address potential issues and minimize downtime. This automated approach enhances your operational efficiency and allows you to monitor your Azure Virtual WAN estate. To learn more about Azure VWAN monitoring, please refer to Monitoring Virtual WAN - Best practices - Azure Virtual WAN | Microsoft Learn.

Version history
Last update:
‎Jan 26 2024 06:54 AM
Updated by: