简体   繁体   中英

How to trigger a single logic app for send different emails as per Azure Budget Action Group conditions

I have created an Azure Budget which is mapped to an Action group. I have created a Logic App to send different emails with different email structures on different budget threshold example 50%, 75% etc. Not able to understand, How to trigger a single logic app for sending different emails as per Azure Budget Action Group conditions.

In logic app flow, you can use multiple conditions to send different mails based on different budget conditions.

  1. Created logic app flow as shown below,在此处输入图像描述

  2. The body of Http request trigger is in below format,

     {
    "schemaId":"AIP Budget Notification",
    "data":{
        "SubscriptionName":"Subscriptiona",
        "SubscriptionId":"JKKLLLLLL",
        "SpendingAmount":"100",
        "BudgetStartDate":"6/1/2018",
        "Budget":"50","Unit":"USD",
        "BudgetCreator":"email@contoso.com",
        "BudgetName":"BudgetName",
        "BudgetType":"Cost",
        "ResourceGroup":"resorceg",
        "NotificationThresholdAmount":"0.8"
        }
    }
  1. Selecting body of Http request trigger as content in Parse JSON action and given above code in use sample payload to generate schema.在此处输入图像描述

  2. I am checking condition for NotificationThresholdAmount value from Parse JSON action.

  3. If NotificationThresholdAmount is greater than or equal to 0.8 and less than 1 , sending mail to one user with one format.在此处输入图像描述

  4. Added one parallel condition to check if NotificationThresholdAmount is greater than or equal to 1 and less than 2 , sending mail to another user with different format.在此处输入图像描述

  5. Mail format received in below format when NotificationThresholdAmount is 0.9 在此处输入图像描述在此处输入图像描述

  6. Mail format received in below format when NotificationThresholdAmount is 1.2. 在此处输入图像描述

在此处输入图像描述 Here is reference link

I followed the Microsoft article mentioned by Vijaya . What it lacks is you need to convert the NotificationThresholdAmount object from the incoming JSON data to integer as the conditions are going to want it as such for comparison with your defined threshold numbers.

For the same you can use Compose Action for converting the incoming NotificationThresholdAmount to integer which would come as string.

The condition i used was something like this int(body('Parse_JSON')['?']['NotificationThresholdAmount'])

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM